[1] | 1 | 'string.sbp
|
---|
| 2 | '文字列変数の操作用
|
---|
| 3 |
|
---|
| 4 | #ifndef _INC_BASIC_STRING
|
---|
| 5 | #define _INC_BASIC_STRING
|
---|
| 6 |
|
---|
[119] | 7 | Function StrPtr(buf As *Char) As *Char
|
---|
[1] | 8 | StrPtr = buf
|
---|
| 9 | End Function
|
---|
| 10 |
|
---|
| 11 | Function ZeroString(length As Long) As String
|
---|
| 12 | Dim str As String
|
---|
| 13 | str.ReSize(length)
|
---|
| 14 | Return str
|
---|
| 15 | End Function
|
---|
| 16 |
|
---|
[142] | 17 | Function MakeStr(pBuf As PSTR) As String
|
---|
[1] | 18 | Dim temp As String(pBuf)
|
---|
| 19 | Return temp
|
---|
| 20 | End Function
|
---|
| 21 |
|
---|
[142] | 22 | Function MakeStr(pBuf As PWSTR) As String
|
---|
| 23 | Dim temp As String(pBuf)
|
---|
| 24 | Return temp
|
---|
| 25 | End Function
|
---|
| 26 |
|
---|
| 27 | Dim _System_AllocForConvertedString As *Function(size As SIZE_T) As VoidPtr
|
---|
| 28 | _System_AllocForConvertedString = AddressOf (GC_malloc_atomic)
|
---|
| 29 |
|
---|
| 30 | Function GetStr(psz As PSTR, ByRef wcs As PWSTR) As SIZE_T
|
---|
| 31 | If psz <> 0 Then
|
---|
| 32 | Return GetStr(psz, lstrlenA(psz), wcs)
|
---|
| 33 | Else
|
---|
| 34 | Return 0
|
---|
| 35 | End If
|
---|
| 36 | End Function
|
---|
| 37 |
|
---|
| 38 | Function GetStr(psz As PSTR, len As SIZE_T, ByRef wcs As PWSTR) As SIZE_T
|
---|
| 39 | If psz = 0 Then Return 0
|
---|
| 40 | Dim sizeWCS = MultiByteToWideChar(CP_THREAD_ACP, 0, psz, len, 0, 0)
|
---|
| 41 | wcs = _System_AllocForConvertedString(SizeOf (WCHAR) * sizeWCS) As PWSTR
|
---|
[149] | 42 | GetStr = MultiByteToWideChar(CP_THREAD_ACP, 0, psz, len, wcs, sizeWCS)
|
---|
| 43 | wcs[GetStr] = 0
|
---|
[142] | 44 | End Function
|
---|
| 45 |
|
---|
| 46 | Function GetStr(psz As PWSTR, ByRef wcs As PWSTR) As SIZE_T
|
---|
| 47 | wcs = psz
|
---|
| 48 | If psz <> 0 Then
|
---|
| 49 | Return lstrlenW(psz)
|
---|
| 50 | Else
|
---|
| 51 | Return 0
|
---|
| 52 | End If
|
---|
| 53 | End Function
|
---|
| 54 |
|
---|
| 55 | Function GetStr(psz As PWSTR, len As SIZE_T, ByRef wcs As PWSTR) As SIZE_T
|
---|
| 56 | wcs = psz
|
---|
| 57 | If psz <> 0 Then
|
---|
[149] | 58 | Return len
|
---|
[142] | 59 | Else
|
---|
| 60 | Return 0
|
---|
| 61 | End If
|
---|
| 62 | End Function
|
---|
| 63 |
|
---|
| 64 | Function GetStr(psz As PWSTR, ByRef mbs As PSTR) As SIZE_T
|
---|
| 65 | If psz = 0 Then
|
---|
| 66 | Return 0
|
---|
| 67 | Else
|
---|
| 68 | Return GetStr(psz, lstrlenW(psz), mbs)
|
---|
| 69 | End If
|
---|
| 70 | End Function
|
---|
| 71 |
|
---|
| 72 | Function GetStr(psz As PWSTR, len As SIZE_T, ByRef mbs As PSTR) As SIZE_T
|
---|
| 73 | If psz = 0 Then Return 0
|
---|
| 74 | Dim sizeMBS = WideCharToMultiByte(CP_THREAD_ACP, 0, psz, len, 0, 0, 0, 0)
|
---|
| 75 | mbs = _System_AllocForConvertedString(SizeOf (SByte) * (sizeMBS + 1)) As PSTR
|
---|
| 76 | GetStr = WideCharToMultiByte(CP_THREAD_ACP, 0, psz, len, mbs, sizeMBS, 0, 0) As SIZE_T
|
---|
| 77 | mbs[GetStr] = 0
|
---|
| 78 | End Function
|
---|
| 79 |
|
---|
| 80 | Function GetStr(psz As PSTR, ByRef mbs As PSTR) As SIZE_T
|
---|
| 81 | mbs = psz
|
---|
| 82 | If psz <> 0 Then
|
---|
| 83 | Return lstrlenA(psz)
|
---|
| 84 | Else
|
---|
| 85 | Return 0
|
---|
| 86 | End If
|
---|
| 87 | End Function
|
---|
| 88 |
|
---|
| 89 | Function GetStr(psz As PSTR, len As SIZE_T, ByRef mbs As PSTR) As SIZE_T
|
---|
| 90 | mbs = psz
|
---|
[149] | 91 | If psz <> 0 Then
|
---|
| 92 | Return len
|
---|
| 93 | Else
|
---|
| 94 | Return 0
|
---|
| 95 | End If
|
---|
[142] | 96 | End Function
|
---|
| 97 |
|
---|
| 98 | Function GetStr(ByRef s As String, ByRef mbs As PSTR) As SIZE_T
|
---|
| 99 | Return GetStr(s.Chars, s.Length As SIZE_T, mbs)
|
---|
| 100 | End Function
|
---|
| 101 |
|
---|
| 102 | Function GetStr(ByRef s As String, ByRef wcs As PWSTR) As SIZE_T
|
---|
| 103 | Return GetStr(s.Chars, s.Length As SIZE_T, wcs)
|
---|
| 104 | End Function
|
---|
| 105 |
|
---|
| 106 | Function GetWCStr(psz As PSTR, ByRef wcs As PWSTR) As SIZE_T
|
---|
| 107 | Return GetStr(psz, wcs)
|
---|
| 108 | End Function
|
---|
| 109 |
|
---|
| 110 | Function GetWCStr(psz As PSTR, len As SIZE_T, ByRef wcs As PWSTR) As SIZE_T
|
---|
| 111 | Return GetStr(psz, len, wcs)
|
---|
| 112 | End Function
|
---|
| 113 |
|
---|
| 114 | Function GetWCStr(psz As PWSTR, ByRef wcs As PWSTR) As SIZE_T
|
---|
| 115 | Return GetStr(psz, wcs)
|
---|
| 116 | End Function
|
---|
| 117 |
|
---|
| 118 | Function GetWCStr(psz As PWSTR, len As SIZE_T, ByRef wcs As PWSTR) As SIZE_T
|
---|
| 119 | Return GetStr(psz, len, wcs)
|
---|
| 120 | End Function
|
---|
| 121 |
|
---|
| 122 | Function GetWCStr(ByRef s As String, ByRef wcs As PWSTR) As SIZE_T
|
---|
| 123 | Return GetStr(s.Chars, s.Length, wcs)
|
---|
| 124 | End Function
|
---|
| 125 |
|
---|
| 126 | Function GetMBStr(psz As PWSTR, ByRef mbs As PSTR) As SIZE_T
|
---|
| 127 | Return GetStr(psz, mbs)
|
---|
| 128 | End Function
|
---|
| 129 |
|
---|
| 130 | Function GetMBStr(psz As PWSTR, len As SIZE_T, ByRef mbs As PSTR) As SIZE_T
|
---|
| 131 | Return GetStr(psz, len, mbs)
|
---|
| 132 | End Function
|
---|
| 133 |
|
---|
| 134 | Function GetMBStr(psz As PSTR, ByRef mbs As PSTR) As SIZE_T
|
---|
| 135 | Return GetStr(psz, mbs)
|
---|
| 136 | End Function
|
---|
| 137 |
|
---|
| 138 | Function GetMBStr(psz As PSTR, len As SIZE_T, ByRef mbs As PSTR) As SIZE_T
|
---|
| 139 | Return GetStr(psz, len, mbs)
|
---|
| 140 | End Function
|
---|
| 141 |
|
---|
| 142 | Function GetMBStr(ByRef s As String, ByRef mbs As PSTR) As SIZE_T
|
---|
| 143 | Return GetStr(s.Chars, s.Length, mbs)
|
---|
| 144 | End Function
|
---|
| 145 |
|
---|
| 146 | Function GetTCStr(psz As PSTR, ByRef tcs As PCTSTR) As SIZE_T
|
---|
| 147 | Return GetStr(psz, tcs)
|
---|
| 148 | End Function
|
---|
| 149 |
|
---|
| 150 | Function GetTCStr(psz As PSTR, len As SIZE_T, ByRef tcs As PCTSTR) As SIZE_T
|
---|
| 151 | Return GetStr(psz, len, tcs)
|
---|
| 152 | End Function
|
---|
| 153 |
|
---|
| 154 | Function GetTCStr(psz As PWSTR, ByRef tcs As PCTSTR) As SIZE_T
|
---|
| 155 | Return GetStr(psz, tcs)
|
---|
| 156 | End Function
|
---|
| 157 |
|
---|
| 158 | Function GetTCStr(psz As PWSTR, len As SIZE_T, ByRef tcs As PCTSTR) As SIZE_T
|
---|
| 159 | Return GetStr(psz, len, tcs)
|
---|
| 160 | End Function
|
---|
| 161 |
|
---|
| 162 | Function GetTCStr(ByRef s As String, ByRef wcs As PCTSTR) As SIZE_T
|
---|
[149] | 163 | Return GetStr(s.Chars, s.Length As SIZE_T, tcs)
|
---|
[142] | 164 | End Function
|
---|
| 165 |
|
---|
| 166 | Function GetSCStr(psz As PSTR, ByRef ss As *StrChar) As SIZE_T
|
---|
| 167 | Return GetStr(psz, ss)
|
---|
| 168 | End Function
|
---|
| 169 |
|
---|
| 170 | Function GetSCStr(psz As PSTR, len As SIZE_T, ByRef ss As *StrChar) As SIZE_T
|
---|
| 171 | Return GetStr(psz, len, ss)
|
---|
| 172 | End Function
|
---|
| 173 |
|
---|
| 174 | Function GetSCStr(psz As PWSTR, ByRef ss As *StrChar) As SIZE_T
|
---|
| 175 | Return GetStr(psz, ss)
|
---|
| 176 | End Function
|
---|
| 177 |
|
---|
| 178 | Function GetSCStr(psz As PWSTR, len As SIZE_T, ByRef ss As *StrChar) As SIZE_T
|
---|
| 179 | Return GetStr(psz, len, ss)
|
---|
| 180 | End Function
|
---|
| 181 |
|
---|
| 182 | Function GetSCStr(ByRef s As String, ByRef wcs As *StrChar) As SIZE_T
|
---|
[149] | 183 | Return GetStr(s.Chars, s.Length As SIZE_T, ss)
|
---|
[142] | 184 | End Function
|
---|
| 185 |
|
---|
| 186 | Function ToWCStr(psz As PSTR) As PWSTR
|
---|
[149] | 187 | GetStr(psz, ToWCStr)
|
---|
[142] | 188 | End Function
|
---|
| 189 |
|
---|
| 190 | Function ToWCStr(psz As PSTR, len As SIZE_T) As PWSTR
|
---|
[149] | 191 | GetStr(psz, len, ToWCStr)
|
---|
[142] | 192 | End Function
|
---|
| 193 |
|
---|
| 194 | Function ToWCStr(psz As PWSTR) As PWSTR
|
---|
[149] | 195 | GetStr(psz, ToWCStr)
|
---|
[142] | 196 | End Function
|
---|
| 197 |
|
---|
| 198 | Function ToWCStr(psz As PWSTR, len As SIZE_T) As PWSTR
|
---|
[149] | 199 | GetStr(psz, len, ToWCStr)
|
---|
[142] | 200 | End Function
|
---|
| 201 |
|
---|
| 202 | Function ToWCStr(ByRef s As String) As PWSTR
|
---|
[149] | 203 | GetStr(s.Chars As PWSTR, s.Length As SIZE_T, ToWCStr)
|
---|
[142] | 204 | End Function
|
---|
| 205 |
|
---|
| 206 | Function ToMBStr(psz As PSTR) As PSTR
|
---|
[149] | 207 | GetStr(psz, ToMBStr)
|
---|
[142] | 208 | End Function
|
---|
| 209 |
|
---|
| 210 | Function ToMBStr(psz As PSTR, len As SIZE_T) As PSTR
|
---|
[149] | 211 | GetStr(psz, len, ToMBStr)
|
---|
[142] | 212 | End Function
|
---|
| 213 |
|
---|
| 214 | Function ToMBStr(psz As PWSTR) As PSTR
|
---|
[149] | 215 | GetStr(psz, ToMBStr)
|
---|
[142] | 216 | End Function
|
---|
| 217 |
|
---|
| 218 | Function ToMBStr(psz As PWSTR, len As SIZE_T) As PSTR
|
---|
[149] | 219 | GetStr(psz, len, ToMBStr)
|
---|
[142] | 220 | End Function
|
---|
| 221 |
|
---|
| 222 | Function ToMBStr(ByRef s As String) As PSTR
|
---|
[149] | 223 | GetStr(s.Chars, s.Length As SIZE_T, ToMBStr)
|
---|
[142] | 224 | End Function
|
---|
| 225 |
|
---|
| 226 | Function ToTCStr(psz As PSTR) As PCTSTR
|
---|
[149] | 227 | GetStr(psz, ToTCStr)
|
---|
[142] | 228 | End Function
|
---|
| 229 |
|
---|
| 230 | Function ToTCStr(psz As PSTR, len As SIZE_T) As PCTSTR
|
---|
[149] | 231 | GetStr(psz, len, ToTCStr)
|
---|
[142] | 232 | End Function
|
---|
| 233 |
|
---|
| 234 | Function ToTCStr(psz As PWSTR) As PCTSTR
|
---|
[149] | 235 | GetStr(psz, ToTCStr)
|
---|
[142] | 236 | End Function
|
---|
| 237 |
|
---|
| 238 | Function ToTCStr(psz As PWSTR, len As SIZE_T) As PCTSTR
|
---|
[149] | 239 | GetStr(psz, len, ToTCStr)
|
---|
[142] | 240 | End Function
|
---|
| 241 |
|
---|
| 242 | Function ToTCStr(ByRef s As String) As PCTSTR
|
---|
[149] | 243 | GetStr(s.Chars, s.Length As SIZE_T, ToTCStr)
|
---|
[142] | 244 | End Function
|
---|
| 245 |
|
---|
| 246 | Function ToSCStr(psz As PSTR) As *StrChar
|
---|
[149] | 247 | GetStr(psz, ToSCStr)
|
---|
[142] | 248 | End Function
|
---|
| 249 |
|
---|
| 250 | Function ToSCStr(psz As PSTR, len As SIZE_T) As *StrChar
|
---|
[149] | 251 | GetStr(psz, len, ToSCStr)
|
---|
[142] | 252 | End Function
|
---|
| 253 |
|
---|
| 254 | Function ToSCStr(psz As PWSTR) As *StrChar
|
---|
[149] | 255 | GetStr(psz, ToSCStr)
|
---|
[142] | 256 | End Function
|
---|
| 257 |
|
---|
| 258 | Function ToSCStr(psz As PWSTR, len As SIZE_T) As *StrChar
|
---|
[149] | 259 | GetStr(psz, len, ToSCStr)
|
---|
[142] | 260 | End Function
|
---|
| 261 |
|
---|
| 262 | Function ToSCStr(ByRef s As String) As *StrChar
|
---|
[149] | 263 | GetStr(s.Chars, s.Length As SIZE_T, ToSCStr)
|
---|
[142] | 264 | End Function
|
---|
| 265 |
|
---|
[1] | 266 | #endif '_INC_BASIC_STRING
|
---|