Changeset 395 for trunk/Include/system
- Timestamp:
- Dec 10, 2007, 11:59:48 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Include/system/string.sbp
r386 r395 31 31 _System_AllocForConvertedString = AddressOf (GC_malloc_atomic) 32 32 33 Function GetStr(psz As PSTR, ByRef wcs As PWSTR) As SIZE_T 34 If psz <> 0 Then 35 Return GetStr(psz, lstrlenA(psz) As SIZE_T, wcs) 36 Else 37 Return 0 38 End If 39 End Function 40 41 Function GetStr(psz As PSTR, len As SIZE_T, ByRef wcs As PWSTR) As SIZE_T 42 If psz = 0 Then Return 0 43 Dim lenWCS = MultiByteToWideChar(CP_THREAD_ACP, 0, psz, (len As DWord) As Long, 0, 0) 44 wcs = _System_AllocForConvertedString(SizeOf (WCHAR) * (lenWCS + 1)) As PWSTR 45 GetStr = MultiByteToWideChar(CP_THREAD_ACP, 0, psz, (len As DWord) As Long, wcs, lenWCS) 46 wcs[GetStr] = 0 47 End Function 48 49 Function GetStr(psz As PWSTR, ByRef wcs As PWSTR) As SIZE_T 50 wcs = psz 51 If psz <> 0 Then 52 Return lstrlenW(psz) As SIZE_T 53 Else 54 Return 0 55 End If 56 End Function 57 58 Function GetStr(psz As PWSTR, len As SIZE_T, ByRef wcs As PWSTR) As SIZE_T 59 wcs = psz 60 If psz <> 0 Then 33 Namespace Detail 34 Function GetWCStr(mbsSrc As PSTR, len As SIZE_T, ByRef wcsDst As PWSTR) As SIZE_T 35 Dim lenWCS = MultiByteToWideChar(CP_THREAD_ACP, 0, mbsSrc, (len As DWord) As Long, 0, 0) 36 wcsDst = _System_AllocForConvertedString(SizeOf (WCHAR) * (lenWCS + 1)) As PWSTR 37 GetWCStr = MultiByteToWideChar(CP_THREAD_ACP, 0, mbsSrc, (len As DWord) As Long, wcsDst, lenWCS) 38 wcsDst[GetWCStr] = 0 39 End Function 40 41 Function GetWCStr(wcsSrc As PWSTR, len As SIZE_T, ByRef wcsDst As PWSTR) As SIZE_T 42 wcsDst = wcsSrc 43 GetWCStr = len 44 End Function 45 46 Function GetMBStr(wcsSrc As PWSTR, len As SIZE_T, ByRef mbsDst As PSTR) As SIZE_T 47 Dim lenMBS = WideCharToMultiByte(CP_THREAD_ACP, 0, wcsSrc, (len As DWord) As Long, 0, 0, 0, 0) 48 mbsDst = _System_AllocForConvertedString(SizeOf (SByte) * (lenMBS + 1)) As PSTR 49 GetMBStr = WideCharToMultiByte(CP_THREAD_ACP, 0, wcsSrc, (wcsSrc As DWord) As Long, mbsDst, lenMBS, 0, 0) As SIZE_T 50 mbsDst[GetMBStr] = 0 51 End Function 52 53 Function GetMBStr(mbsSrc As PSTR, len As SIZE_T, ByRef mbsDst As PSTR) As SIZE_T 54 mbsDst = mbsSrc 55 GetMBStr = len 56 End Function 57 End Namespace 58 59 /* 60 変換の組み合わせは、 61 入力引数: wcsz, wcs + len, mbsz, mbs + len, str 62 出力関数: wcs(z)出力GetStr, mbs(z)出力GetStr, 63 wcs(z)出力GetStrNT, mbs(z)出力GetStrNT, 64 GetWCStr, GetMBStr, GetTCStr, GetSCStr, 65 ToWCStr, ToMBStr, ToTCStr, ToSCStr 66 で、5 * 12 = 60通り。 67 */ 68 69 Function GetStr(mbszSrc As PSTR, ByRef wcsDst As PWSTR) As SIZE_T 70 If mbszSrc = 0 Then 71 wcsDst = 0 72 Return 0 73 Else 74 Return Detail.GetWCStr(mbszSrc, lstrlenA(mbszSrc) As SIZE_T, wcsDst) 75 End If 76 End Function 77 78 Function GetStr(mbsSrc As PSTR, len As SIZE_T, ByRef wcsDst As PWSTR) As SIZE_T 79 If mbsSrc = 0 Then 80 wcsDst = 0 81 Return 0 82 Else 83 Return Detail.GetWCStr(mbsSrc, len, wcsDst) 84 End If 85 End Function 86 87 Function GetStr(wcszSrc As PWSTR, ByRef wcsDst As PWSTR) As SIZE_T 88 If wcszSrc = 0 Then 89 wcsDst = 0 90 Return 0 91 Else 92 wcsDst = wcszSrc 93 Return lstrlenW(wcszSrc) As SIZE_T 94 End If 95 End Function 96 97 Function GetStr(wcsSrc As PWSTR, len As SIZE_T, ByRef wcsDst As PWSTR) As SIZE_T 98 If wcsSrc = 0 Then 99 wcsDst = 0 100 Return 0 101 Else 102 wcsDst = wcsSrc 61 103 Return len 62 Else 63 Return 0 64 End If 65 End Function 66 67 Function GetStr(psz As PWSTR, ByRef mbs As PSTR) As SIZE_T 68 If psz = 0 Then 69 Return 0 70 Else 71 Return GetStr(psz, lstrlenW(psz) As SIZE_T, mbs) 72 End If 73 End Function 74 75 Function GetStr(psz As PWSTR, len As SIZE_T, ByRef mbs As PSTR) As SIZE_T 76 If psz = 0 Then Return 0 77 Dim lenMBS = WideCharToMultiByte(CP_THREAD_ACP, 0, psz, (len As DWord) As Long, 0, 0, 0, 0) 78 mbs = _System_AllocForConvertedString(SizeOf (SByte) * (lenMBS + 1)) As PSTR 79 GetStr = WideCharToMultiByte(CP_THREAD_ACP, 0, psz, (len As DWord) As Long, mbs, lenMBS, 0, 0) As SIZE_T 80 mbs[GetStr] = 0 81 End Function 82 83 Function GetStr(psz As PSTR, ByRef mbs As PSTR) As SIZE_T 84 mbs = psz 85 If psz <> 0 Then 86 Return lstrlenA(psz) As SIZE_T 87 Else 88 Return 0 89 End If 90 End Function 91 92 Function GetStr(psz As PSTR, len As SIZE_T, ByRef mbs As PSTR) As SIZE_T 93 mbs = psz 94 If psz <> 0 Then 104 End If 105 End Function 106 107 Function GetStr(wcszSrc As PWSTR, ByRef mbsDst As PSTR) As SIZE_T 108 If wcszSrc = 0 Then 109 mbsDst = 0 110 Return 0 111 Else 112 Return Detail.GetMBStr(wcszSrc, lstrlenW(wcszSrc) As SIZE_T, mbsDst) 113 End If 114 End Function 115 116 Function GetStr(wcsSrc As PWSTR, len As SIZE_T, ByRef mbsDst As PSTR) As SIZE_T 117 If wcsSrc = 0 Then 118 mbsDst = 0 119 Return 0 120 Else 121 Return Detail.GetMBStr(wcsSrc, len As SIZE_T, mbsDst) 122 End If 123 End Function 124 125 Function GetStr(mbszSrc As PSTR, ByRef mbsDst As PSTR) As SIZE_T 126 If mbszSrc = 0 Then 127 mbsDst = 0 128 Return 0 129 Else 130 mbsDst = mbszSrc 131 Return lstrlenA(mbszSrc) As SIZE_T 132 End If 133 End Function 134 135 Function GetStr(mbsSrc As PSTR, len As SIZE_T, ByRef mbsDst As PSTR) As SIZE_T 136 If mbsSrc = 0 Then 137 mbsDst = 0 95 138 Return len 96 139 Else 97 Return 0 98 End If 99 End Function 100 101 Function GetStr(s As String, ByRef mbs As PSTR) As SIZE_T 102 Return GetStr(s.StrPtr, s.Length As SIZE_T, mbs) 103 End Function 104 105 Function GetStr(s As String, ByRef wcs As PWSTR) As SIZE_T 106 Return GetStr(s.StrPtr, s.Length As SIZE_T, wcs) 107 End Function 108 109 Function GetWCStr(psz As PSTR, ByRef wcs As PWSTR) As SIZE_T 110 Return GetStr(psz, wcs) 111 End Function 112 113 Function GetWCStr(psz As PSTR, len As SIZE_T, ByRef wcs As PWSTR) As SIZE_T 114 Return GetStr(psz, len, wcs) 115 End Function 116 117 Function GetWCStr(psz As PWSTR, ByRef wcs As PWSTR) As SIZE_T 118 Return GetStr(psz, wcs) 119 End Function 120 121 Function GetWCStr(psz As PWSTR, len As SIZE_T, ByRef wcs As PWSTR) As SIZE_T 122 Return GetStr(psz, len, wcs) 123 End Function 124 125 Function GetWCStr(s As String, ByRef wcs As PWSTR) As SIZE_T 126 Return GetStr(s.StrPtr, s.Length As SIZE_T, wcs) 127 End Function 128 129 Function GetMBStr(psz As PWSTR, ByRef mbs As PSTR) As SIZE_T 130 Return GetStr(psz, mbs) 131 End Function 132 133 Function GetMBStr(psz As PWSTR, len As SIZE_T, ByRef mbs As PSTR) As SIZE_T 134 Return GetStr(psz, len, mbs) 135 End Function 136 137 Function GetMBStr(psz As PSTR, ByRef mbs As PSTR) As SIZE_T 138 Return GetStr(psz, mbs) 139 End Function 140 141 Function GetMBStr(psz As PSTR, len As SIZE_T, ByRef mbs As PSTR) As SIZE_T 142 Return GetStr(psz, len, mbs) 143 End Function 144 145 Function GetMBStr(s As String, ByRef mbs As PSTR) As SIZE_T 146 Return GetStr(s.StrPtr, s.Length As SIZE_T, mbs) 147 End Function 148 149 Function GetTCStr(psz As PSTR, ByRef tcs As PCTSTR) As SIZE_T 150 Return GetStr(psz, tcs) 151 End Function 152 153 Function GetTCStr(psz As PSTR, len As SIZE_T, ByRef tcs As PCTSTR) As SIZE_T 154 Return GetStr(psz, len, tcs) 155 End Function 156 157 Function GetTCStr(psz As PWSTR, ByRef tcs As PCTSTR) As SIZE_T 158 Return GetStr(psz, tcs) 159 End Function 160 161 Function GetTCStr(psz As PWSTR, len As SIZE_T, ByRef tcs As PCTSTR) As SIZE_T 162 Return GetStr(psz, len, tcs) 163 End Function 164 165 Function GetTCStr(s As String, ByRef tcs As PCTSTR) As SIZE_T 166 Return GetStr(s.StrPtr, s.Length As SIZE_T, tcs) 167 End Function 168 169 Function GetSCStr(psz As PSTR, ByRef ss As *StrChar) As SIZE_T 170 Return GetStr(psz, ss) 171 End Function 172 173 Function GetSCStr(psz As PSTR, len As SIZE_T, ByRef ss As *StrChar) As SIZE_T 174 Return GetStr(psz, len, ss) 175 End Function 176 177 Function GetSCStr(psz As PWSTR, ByRef ss As *StrChar) As SIZE_T 178 Return GetStr(psz, ss) 179 End Function 180 181 Function GetSCStr(psz As PWSTR, len As SIZE_T, ByRef ss As *StrChar) As SIZE_T 182 Return GetStr(psz, len, ss) 183 End Function 184 185 Function GetSCStr(s As String, ByRef ss As *StrChar) As SIZE_T 186 Return GetStr(s.StrPtr, s.Length As SIZE_T, ss) 187 End Function 188 189 Function ToWCStr(psz As PSTR) As PWSTR 190 GetStr(psz, ToWCStr) 191 End Function 192 193 Function ToWCStr(psz As PSTR, len As SIZE_T) As PWSTR 194 GetStr(psz, len, ToWCStr) 195 End Function 196 197 Function ToWCStr(psz As PWSTR) As PWSTR 198 GetStr(psz, ToWCStr) 199 End Function 200 201 Function ToWCStr(psz As PWSTR, len As SIZE_T) As PWSTR 202 GetStr(psz, len, ToWCStr) 140 mbsDst = mbsSrc 141 Return 0 142 End If 143 End Function 144 145 Function GetStr(strSrc As String, ByRef wcsDst As PWSTR) As SIZE_T 146 If ActiveBasic.IsNothing(strSrc) Then 147 wcsDst = 0 148 Return 0 149 Else 150 Return Detail.GetWCStr(strSrc.StrPtr, strSrc.Length As SIZE_T, wcsDst) 151 End If 152 End Function 153 154 Function GetStr(strSrc As String, ByRef mbsDst As PSTR) As SIZE_T 155 If ActiveBasic.IsNothing(strSrc) Then 156 mbsDst = 0 157 Return 0 158 Else 159 Return Detail.GetMBStr(strSrc.StrPtr, strSrc.Length As SIZE_T, mbsDst) 160 End If 161 End Function 162 163 Sub GetStrNT(mbszSrc As PSTR, ByRef mbszDst As PSTR) 164 mbszDst = mbszSrc 165 End Sub 166 167 Sub GetStrNT(mbsSrc As PSTR, len As SIZE_T, ByRef mbszDst As PSTR) 168 mbszDst = mbsSrc 169 End Sub 170 171 Sub GetStrNT(mbszSrc As PSTR, ByRef wcszDst As PWSTR) 172 GetStr(mbszSrc, wcszDst) 173 End Sub 174 175 Sub GetStrNT(mbsSrc As PSTR, len As SIZE_T, ByRef wcszDst As PWSTR) 176 GetStr(mbsSrc, len, wcszDst) 177 End Sub 178 179 Sub GetStrNT(wcszSrc As PWSTR, ByRef mbszDst As PSTR) 180 GetStr(wcszSrc, mbszDst) 181 End Sub 182 183 Sub GetStrNT(wcsSrc As PWSTR, len As SIZE_T, ByRef mbszDst As PSTR) 184 GetStr(wcsSrc, len, mbszDst) 185 End Sub 186 187 Sub GetStrNT(wcszSrc As PWSTR, ByRef wcszDst As PWSTR) 188 wcszDst = wcszSrc 189 End Sub 190 191 Sub GetStrNT(wcsSrc As PWSTR, len As SIZE_T, ByRef wcszDst As PWSTR) 192 wcszDst = wcsSrc 193 End Sub 194 195 Sub GetStrNT(strSrc As String, ByRef mbszDst As PSTR) 196 GetStr(strSrc, mbszDst) 197 End Sub 198 199 Sub GetStrNT(strSrc As String, ByRef wcszDst As PWSTR) 200 GetStr(strSrc, wcszDst) 201 End Sub 202 203 Function GetWCStr(mbszSrc As PSTR, ByRef wcsDst As PWSTR) As SIZE_T 204 Return GetStr(mbszSrc, wcsDst) 205 End Function 206 207 Function GetWCStr(mbsSrc As PSTR, len As SIZE_T, ByRef wcsDst As PWSTR) As SIZE_T 208 Return GetStr(mbsSrc, len, wcsDst) 209 End Function 210 211 Function GetWCStr(wcszSrc As PWSTR, ByRef wcsDst As PWSTR) As SIZE_T 212 Return GetStr(wcszSrc, wcsDst) 213 End Function 214 215 Function GetWCStr(wcsSrc As PWSTR, len As SIZE_T, ByRef wcsDst As PWSTR) As SIZE_T 216 Return GetStr(wcsSrc, len, wcsDst) 217 End Function 218 219 Function GetWCStr(strSrc As String, ByRef wcsDst As PWSTR) As SIZE_T 220 Return GetStr(strSrc.StrPtr, strSrc.Length As SIZE_T, wcsDst) 221 End Function 222 223 Function GetMBStr(mbszSrc As PWSTR, ByRef mbsDst As PSTR) As SIZE_T 224 Return GetStr(mbszSrc, mbsDst) 225 End Function 226 227 Function GetMBStr(wcsSrc As PWSTR, len As SIZE_T, ByRef mbsDst As PSTR) As SIZE_T 228 Return GetStr(wcsSrc, len, mbsDst) 229 End Function 230 231 Function GetMBStr(mbszSrc As PSTR, ByRef mbsDst As PSTR) As SIZE_T 232 Return GetStr(mbszSrc, mbsDst) 233 End Function 234 235 Function GetMBStr(mbsSrc As PSTR, len As SIZE_T, ByRef mbsDst As PSTR) As SIZE_T 236 Return GetStr(mbsSrc, len, mbsDst) 237 End Function 238 239 Function GetMBStr(strSrc As String, ByRef mbsDst As PSTR) As SIZE_T 240 Return GetStr(strSrc.StrPtr, strSrc.Length As SIZE_T, mbsDst) 241 End Function 242 243 Function GetTCStr(mbszSrc As PSTR, ByRef tcsDst As PCTSTR) As SIZE_T 244 Return GetStr(mbszSrc, tcsDst) 245 End Function 246 247 Function GetTCStr(mbsSrc As PSTR, len As SIZE_T, ByRef tcsDst As PCTSTR) As SIZE_T 248 Return GetStr(mbsSrc, len, tcsDst) 249 End Function 250 251 Function GetTCStr(wcszSrc As PWSTR, ByRef tcsDst As PCTSTR) As SIZE_T 252 Return GetStr(wcszSrc, tcsDst) 253 End Function 254 255 Function GetTCStr(wcsSrc As PWSTR, len As SIZE_T, ByRef tcsDst As PCTSTR) As SIZE_T 256 Return GetStr(wcsSrc, len, tcsDst) 257 End Function 258 259 Function GetTCStr(strSrc As String, ByRef tcsDst As PCTSTR) As SIZE_T 260 Return GetStr(strSrc.StrPtr, strSrc.Length As SIZE_T, tcsDst) 261 End Function 262 263 Function GetSCStr(mbszSrc As PSTR, ByRef ssDst As *StrChar) As SIZE_T 264 Return GetStr(mbszSrc, ssDst) 265 End Function 266 267 Function GetSCStr(mbsSrc As PSTR, len As SIZE_T, ByRef ssDst As *StrChar) As SIZE_T 268 Return GetStr(mbsSrc, len, ssDst) 269 End Function 270 271 Function GetSCStr(wcszSrc As PWSTR, ByRef ssDst As *StrChar) As SIZE_T 272 Return GetStr(wcszSrc, ssDst) 273 End Function 274 275 Function GetSCStr(wcsSrc As PWSTR, len As SIZE_T, ByRef ssDst As *StrChar) As SIZE_T 276 Return GetStr(wcsSrc, len, ssDst) 277 End Function 278 279 Function GetSCStr(strSrc As String, ByRef ssDst As *StrChar) As SIZE_T 280 Return GetStr(strSrc.StrPtr, strSrc.Length As SIZE_T, ssDst) 281 End Function 282 283 Function ToWCStr(mbsz As PSTR) As PWSTR 284 GetStrNT(mbsz, ToWCStr) 285 End Function 286 287 Function ToWCStr(mbs As PSTR, len As SIZE_T) As PWSTR 288 GetStrNT(mbs, len, ToWCStr) 289 End Function 290 291 Function ToWCStr(wcsz As PWSTR) As PWSTR 292 ToWCStr = wcsz 293 End Function 294 295 Function ToWCStr(wcs As PWSTR, len As SIZE_T) As PWSTR 296 ToWCStr = wcs 203 297 End Function 204 298 205 299 Function ToWCStr(s As String) As PWSTR 206 GetStr (s.StrPtr, s.Length As SIZE_T, ToWCStr)207 End Function 208 209 Function ToMBStr( psz As PSTR) As PSTR210 GetStr(psz, ToMBStr)211 End Function 212 213 Function ToMBStr( pszAs PSTR, len As SIZE_T) As PSTR214 GetStr(psz, len, ToMBStr)215 End Function 216 217 Function ToMBStr( psz As PWSTR) As PSTR218 GetStr (psz, ToMBStr)219 End Function 220 221 Function ToMBStr( pszAs PWSTR, len As SIZE_T) As PSTR222 GetStr (psz, len, ToMBStr)300 GetStrNT(s, ToWCStr) 301 End Function 302 303 Function ToMBStr(mbsz As PSTR) As PSTR 304 ToMBStr = mbsz 305 End Function 306 307 Function ToMBStr(mbs As PSTR, len As SIZE_T) As PSTR 308 ToMBStr = mbs 309 End Function 310 311 Function ToMBStr(wcsz As PWSTR) As PSTR 312 GetStrNT(wcsz, ToMBStr) 313 End Function 314 315 Function ToMBStr(wcs As PWSTR, len As SIZE_T) As PSTR 316 GetStrNT(wcs, len, ToMBStr) 223 317 End Function 224 318 225 319 Function ToMBStr(s As String) As PSTR 226 GetStr (s.StrPtr, s.Length As SIZE_T, ToMBStr)227 End Function 228 229 Function ToTCStr( psz As PSTR) As PCTSTR230 GetStr (psz, ToTCStr)231 End Function 232 233 Function ToTCStr( pszAs PSTR, len As SIZE_T) As PCTSTR234 GetStr (psz, len, ToTCStr)235 End Function 236 237 Function ToTCStr( psz As PWSTR) As PCTSTR238 GetStr (psz, ToTCStr)239 End Function 240 241 Function ToTCStr( pszAs PWSTR, len As SIZE_T) As PCTSTR242 GetStr (psz, len, ToTCStr)320 GetStrNT(s, ToMBStr) 321 End Function 322 323 Function ToTCStr(mbsz As PSTR) As PCTSTR 324 GetStrNT(mbsz, ToTCStr) 325 End Function 326 327 Function ToTCStr(mbs As PSTR, len As SIZE_T) As PCTSTR 328 GetStrNT(mbs, len, ToTCStr) 329 End Function 330 331 Function ToTCStr(wcsz As PWSTR) As PCTSTR 332 GetStrNT(wcsz, ToTCStr) 333 End Function 334 335 Function ToTCStr(wcs As PWSTR, len As SIZE_T) As PCTSTR 336 GetStrNT(wcs, len, ToTCStr) 243 337 End Function 244 338 245 339 Function ToTCStr(s As String) As PCTSTR 246 GetStr (s.StrPtr, s.Length As SIZE_T, ToTCStr)247 End Function 248 249 Function ToSCStr( psz As PSTR) As *StrChar250 GetStr (psz, ToSCStr)251 End Function 252 253 Function ToSCStr( pszAs PSTR, len As SIZE_T) As *StrChar254 GetStr (psz, len, ToSCStr)255 End Function 256 257 Function ToSCStr( psz As PWSTR) As *StrChar258 GetStr (psz, ToSCStr)259 End Function 260 261 Function ToSCStr( pszAs PWSTR, len As SIZE_T) As *StrChar262 GetStr (psz, len, ToSCStr)340 GetStrNT(s, ToTCStr) 341 End Function 342 343 Function ToSCStr(mbsz As PSTR) As *StrChar 344 GetStrNT(mbsz, ToSCStr) 345 End Function 346 347 Function ToSCStr(mbs As PSTR, len As SIZE_T) As *StrChar 348 GetStrNT(mbs, len, ToSCStr) 349 End Function 350 351 Function ToSCStr(wcsz As PWSTR) As *StrChar 352 GetStrNT(wcsz, ToSCStr) 353 End Function 354 355 Function ToSCStr(wcs As PWSTR, len As SIZE_T) As *StrChar 356 GetStrNT(wcs, len, ToSCStr) 263 357 End Function 264 358 265 359 Function ToSCStr(s As String) As *StrChar 266 GetStr(s.StrPtr, s.Length As SIZE_T, ToSCStr)360 ToSCStr = StrPtr(s) 267 361 End Function 268 362
Note:
See TracChangeset
for help on using the changeset viewer.