source: Include/system/string.sbp@ 177

Last change on this file since 177 was 177, checked in by 森崎 孝明, 17 years ago

些細なバグの修正

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