source: Include/system/string.sbp@ 149

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

To系の戻り値指定の間違いを直す

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