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