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