source: trunk/Include/system/string.sbp@ 343

Last change on this file since 343 was 303, checked in by イグトランス (egtra), 17 years ago

フルコンパイルでのミスあぶり出し。註:修正は全て@300や@301以前に行われた。

File size: 6.9 KB
RevLine 
[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]10Function StrPtr(s As String) As *StrChar
11 StrPtr = s.StrPtr
[1]12End Function
[303]13'StringBuilder版はClasses/System/Text/StringBuilder.abに定義されている
[1]14
[303]15Function ZeroString(length As Long) As System.Text.StringBuilder
16 ZeroString = New System.Text.StringBuilder
17 ZeroString.Length = length
[1]18End Function
19
[167]20Function MakeStr(psz As PSTR) As String
21 Return New String(psz)
[1]22End Function
23
[167]24Function MakeStr(psz As PWSTR) As String
25 Return New String(psz)
[142]26End Function
27
28Dim _System_AllocForConvertedString As *Function(size As SIZE_T) As VoidPtr
29_System_AllocForConvertedString = AddressOf (GC_malloc_atomic)
30
31Function 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
37End Function
38
39Function 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]45End Function
46
47Function 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
54End Function
55
56Function 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
63End Function
64
65Function 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
71End Function
72
73Function 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
79End Function
80
81Function 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
88End Function
89
90Function 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]97End Function
98
[237]99Function GetStr(s As String, ByRef mbs As PSTR) As SIZE_T
[272]100 Return GetStr(s.StrPtr, s.Length As SIZE_T, mbs)
[142]101End Function
102
[237]103Function GetStr(s As String, ByRef wcs As PWSTR) As SIZE_T
[272]104 Return GetStr(s.StrPtr, s.Length As SIZE_T, wcs)
[142]105End Function
106
107Function GetWCStr(psz As PSTR, ByRef wcs As PWSTR) As SIZE_T
108 Return GetStr(psz, wcs)
109End Function
110
111Function GetWCStr(psz As PSTR, len As SIZE_T, ByRef wcs As PWSTR) As SIZE_T
112 Return GetStr(psz, len, wcs)
113End Function
114
115Function GetWCStr(psz As PWSTR, ByRef wcs As PWSTR) As SIZE_T
116 Return GetStr(psz, wcs)
117End Function
118
119Function GetWCStr(psz As PWSTR, len As SIZE_T, ByRef wcs As PWSTR) As SIZE_T
120 Return GetStr(psz, len, wcs)
121End Function
122
[237]123Function GetWCStr(s As String, ByRef wcs As PWSTR) As SIZE_T
[272]124 Return GetStr(s.StrPtr, s.Length As SIZE_T, wcs)
[142]125End Function
126
127Function GetMBStr(psz As PWSTR, ByRef mbs As PSTR) As SIZE_T
128 Return GetStr(psz, mbs)
129End Function
130
131Function GetMBStr(psz As PWSTR, len As SIZE_T, ByRef mbs As PSTR) As SIZE_T
132 Return GetStr(psz, len, mbs)
133End Function
134
135Function GetMBStr(psz As PSTR, ByRef mbs As PSTR) As SIZE_T
136 Return GetStr(psz, mbs)
137End Function
138
139Function GetMBStr(psz As PSTR, len As SIZE_T, ByRef mbs As PSTR) As SIZE_T
140 Return GetStr(psz, len, mbs)
141End Function
142
[237]143Function GetMBStr(s As String, ByRef mbs As PSTR) As SIZE_T
[272]144 Return GetStr(s.StrPtr, s.Length As SIZE_T, mbs)
[142]145End Function
146
147Function GetTCStr(psz As PSTR, ByRef tcs As PCTSTR) As SIZE_T
148 Return GetStr(psz, tcs)
149End Function
150
151Function GetTCStr(psz As PSTR, len As SIZE_T, ByRef tcs As PCTSTR) As SIZE_T
152 Return GetStr(psz, len, tcs)
153End Function
154
155Function GetTCStr(psz As PWSTR, ByRef tcs As PCTSTR) As SIZE_T
156 Return GetStr(psz, tcs)
157End Function
158
159Function GetTCStr(psz As PWSTR, len As SIZE_T, ByRef tcs As PCTSTR) As SIZE_T
160 Return GetStr(psz, len, tcs)
161End Function
162
[237]163Function GetTCStr(s As String, ByRef tcs As PCTSTR) As SIZE_T
[272]164 Return GetStr(s.StrPtr, s.Length As SIZE_T, tcs)
[142]165End Function
166
167Function GetSCStr(psz As PSTR, ByRef ss As *StrChar) As SIZE_T
168 Return GetStr(psz, ss)
169End Function
170
171Function GetSCStr(psz As PSTR, len As SIZE_T, ByRef ss As *StrChar) As SIZE_T
172 Return GetStr(psz, len, ss)
173End Function
174
175Function GetSCStr(psz As PWSTR, ByRef ss As *StrChar) As SIZE_T
176 Return GetStr(psz, ss)
177End Function
178
179Function GetSCStr(psz As PWSTR, len As SIZE_T, ByRef ss As *StrChar) As SIZE_T
180 Return GetStr(psz, len, ss)
181End Function
182
[237]183Function GetSCStr(s As String, ByRef ss As *StrChar) As SIZE_T
[272]184 Return GetStr(s.StrPtr, s.Length As SIZE_T, ss)
[142]185End Function
186
187Function ToWCStr(psz As PSTR) As PWSTR
[149]188 GetStr(psz, ToWCStr)
[142]189End Function
190
191Function ToWCStr(psz As PSTR, len As SIZE_T) As PWSTR
[149]192 GetStr(psz, len, ToWCStr)
[142]193End Function
194
195Function ToWCStr(psz As PWSTR) As PWSTR
[149]196 GetStr(psz, ToWCStr)
[142]197End Function
198
199Function ToWCStr(psz As PWSTR, len As SIZE_T) As PWSTR
[149]200 GetStr(psz, len, ToWCStr)
[142]201End Function
202
[237]203Function ToWCStr(s As String) As PWSTR
[272]204 GetStr(s.StrPtr, s.Length As SIZE_T, ToWCStr)
[142]205End Function
206
207Function ToMBStr(psz As PSTR) As PSTR
[149]208 GetStr(psz, ToMBStr)
[142]209End Function
210
211Function ToMBStr(psz As PSTR, len As SIZE_T) As PSTR
[149]212 GetStr(psz, len, ToMBStr)
[142]213End Function
214
215Function ToMBStr(psz As PWSTR) As PSTR
[149]216 GetStr(psz, ToMBStr)
[142]217End Function
218
219Function ToMBStr(psz As PWSTR, len As SIZE_T) As PSTR
[149]220 GetStr(psz, len, ToMBStr)
[142]221End Function
222
[237]223Function ToMBStr(s As String) As PSTR
[272]224 GetStr(s.StrPtr, s.Length As SIZE_T, ToMBStr)
[142]225End Function
226
227Function ToTCStr(psz As PSTR) As PCTSTR
[149]228 GetStr(psz, ToTCStr)
[142]229End Function
230
231Function ToTCStr(psz As PSTR, len As SIZE_T) As PCTSTR
[149]232 GetStr(psz, len, ToTCStr)
[142]233End Function
234
235Function ToTCStr(psz As PWSTR) As PCTSTR
[149]236 GetStr(psz, ToTCStr)
[142]237End Function
238
239Function ToTCStr(psz As PWSTR, len As SIZE_T) As PCTSTR
[149]240 GetStr(psz, len, ToTCStr)
[142]241End Function
242
[237]243Function ToTCStr(s As String) As PCTSTR
[272]244 GetStr(s.StrPtr, s.Length As SIZE_T, ToTCStr)
[142]245End Function
246
247Function ToSCStr(psz As PSTR) As *StrChar
[149]248 GetStr(psz, ToSCStr)
[142]249End Function
250
251Function ToSCStr(psz As PSTR, len As SIZE_T) As *StrChar
[149]252 GetStr(psz, len, ToSCStr)
[142]253End Function
254
255Function ToSCStr(psz As PWSTR) As *StrChar
[149]256 GetStr(psz, ToSCStr)
[142]257End Function
258
259Function ToSCStr(psz As PWSTR, len As SIZE_T) As *StrChar
[149]260 GetStr(psz, len, ToSCStr)
[142]261End Function
262
[237]263Function ToSCStr(s As String) As *StrChar
[272]264 GetStr(s.StrPtr, s.Length As SIZE_T, ToSCStr)
[142]265End Function
266
[1]267#endif '_INC_BASIC_STRING
Note: See TracBrowser for help on using the repository browser.