source: Include/system/string.sbp@ 209

Last change on this file since 209 was 208, checked in by イグトランス (egtra), 18 years ago

[207]参照型変数のNothing初期化に対応する修正

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