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