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

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

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

File size: 6.9 KB
Line 
1'string.sbp
2'文字列変数の操作用
3
4#ifndef _INC_BASIC_STRING
5#define _INC_BASIC_STRING
6
7#require <Classes/System/String.ab>
8#require <Classes/System/Text/StringBuilder.ab>
9
10Function StrPtr(s As String) As *StrChar
11 StrPtr = s.StrPtr
12End Function
13'StringBuilder版はClasses/System/Text/StringBuilder.abに定義されている
14
15Function ZeroString(length As Long) As System.Text.StringBuilder
16 ZeroString = New System.Text.StringBuilder
17 ZeroString.Length = length
18End Function
19
20Function MakeStr(psz As PSTR) As String
21 Return New String(psz)
22End Function
23
24Function MakeStr(psz As PWSTR) As String
25 Return New String(psz)
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
33 Return GetStr(psz, lstrlenA(psz) As SIZE_T, wcs)
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
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)
44 wcs[GetStr] = 0
45End Function
46
47Function GetStr(psz As PWSTR, ByRef wcs As PWSTR) As SIZE_T
48 wcs = psz
49 If psz <> 0 Then
50 Return lstrlenW(psz) As SIZE_T
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
59 Return len
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
69 Return GetStr(psz, lstrlenW(psz) As SIZE_T, mbs)
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
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
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
84 Return lstrlenA(psz) As SIZE_T
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
92 If psz <> 0 Then
93 Return len
94 Else
95 Return 0
96 End If
97End Function
98
99Function GetStr(s As String, ByRef mbs As PSTR) As SIZE_T
100 Return GetStr(s.StrPtr, s.Length As SIZE_T, mbs)
101End Function
102
103Function GetStr(s As String, ByRef wcs As PWSTR) As SIZE_T
104 Return GetStr(s.StrPtr, s.Length As SIZE_T, wcs)
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
123Function GetWCStr(s As String, ByRef wcs As PWSTR) As SIZE_T
124 Return GetStr(s.StrPtr, s.Length As SIZE_T, wcs)
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
143Function GetMBStr(s As String, ByRef mbs As PSTR) As SIZE_T
144 Return GetStr(s.StrPtr, s.Length As SIZE_T, mbs)
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
163Function GetTCStr(s As String, ByRef tcs As PCTSTR) As SIZE_T
164 Return GetStr(s.StrPtr, s.Length As SIZE_T, tcs)
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
183Function GetSCStr(s As String, ByRef ss As *StrChar) As SIZE_T
184 Return GetStr(s.StrPtr, s.Length As SIZE_T, ss)
185End Function
186
187Function ToWCStr(psz As PSTR) As PWSTR
188 GetStr(psz, ToWCStr)
189End Function
190
191Function ToWCStr(psz As PSTR, len As SIZE_T) As PWSTR
192 GetStr(psz, len, ToWCStr)
193End Function
194
195Function ToWCStr(psz As PWSTR) As PWSTR
196 GetStr(psz, ToWCStr)
197End Function
198
199Function ToWCStr(psz As PWSTR, len As SIZE_T) As PWSTR
200 GetStr(psz, len, ToWCStr)
201End Function
202
203Function ToWCStr(s As String) As PWSTR
204 GetStr(s.StrPtr, s.Length As SIZE_T, ToWCStr)
205End Function
206
207Function ToMBStr(psz As PSTR) As PSTR
208 GetStr(psz, ToMBStr)
209End Function
210
211Function ToMBStr(psz As PSTR, len As SIZE_T) As PSTR
212 GetStr(psz, len, ToMBStr)
213End Function
214
215Function ToMBStr(psz As PWSTR) As PSTR
216 GetStr(psz, ToMBStr)
217End Function
218
219Function ToMBStr(psz As PWSTR, len As SIZE_T) As PSTR
220 GetStr(psz, len, ToMBStr)
221End Function
222
223Function ToMBStr(s As String) As PSTR
224 GetStr(s.StrPtr, s.Length As SIZE_T, ToMBStr)
225End Function
226
227Function ToTCStr(psz As PSTR) As PCTSTR
228 GetStr(psz, ToTCStr)
229End Function
230
231Function ToTCStr(psz As PSTR, len As SIZE_T) As PCTSTR
232 GetStr(psz, len, ToTCStr)
233End Function
234
235Function ToTCStr(psz As PWSTR) As PCTSTR
236 GetStr(psz, ToTCStr)
237End Function
238
239Function ToTCStr(psz As PWSTR, len As SIZE_T) As PCTSTR
240 GetStr(psz, len, ToTCStr)
241End Function
242
243Function ToTCStr(s As String) As PCTSTR
244 GetStr(s.StrPtr, s.Length As SIZE_T, ToTCStr)
245End Function
246
247Function ToSCStr(psz As PSTR) As *StrChar
248 GetStr(psz, ToSCStr)
249End Function
250
251Function ToSCStr(psz As PSTR, len As SIZE_T) As *StrChar
252 GetStr(psz, len, ToSCStr)
253End Function
254
255Function ToSCStr(psz As PWSTR) As *StrChar
256 GetStr(psz, ToSCStr)
257End Function
258
259Function ToSCStr(psz As PWSTR, len As SIZE_T) As *StrChar
260 GetStr(psz, len, ToSCStr)
261End Function
262
263Function ToSCStr(s As String) As *StrChar
264 GetStr(s.StrPtr, s.Length As SIZE_T, ToSCStr)
265End Function
266
267#endif '_INC_BASIC_STRING
Note: See TracBrowser for help on using the repository browser.