source: Include/system/string.sbp@ 170

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

String関連の変更とHex$の修正

File size: 6.7 KB
RevLine 
[1]1'string.sbp
2'文字列変数の操作用
3
4#ifndef _INC_BASIC_STRING
5#define _INC_BASIC_STRING
6
[167]7Function StrPtr(buf As *StrChar) As *StrChar
[1]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
[167]17Function MakeStr(psz As PSTR) As String
18 Return New String(psz)
[1]19End Function
20
[167]21Function MakeStr(psz As PWSTR) As String
22 Return New String(psz)
[142]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), 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)
39 wcs = _System_AllocForConvertedString(SizeOf (WCHAR) * sizeWCS) As PWSTR
[149]40 GetStr = MultiByteToWideChar(CP_THREAD_ACP, 0, psz, len, wcs, sizeWCS)
41 wcs[GetStr] = 0
[142]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)
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
[149]56 Return len
[142]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), 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)
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
[149]89 If psz <> 0 Then
90 Return len
91 Else
92 Return 0
93 End If
[142]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
[149]161 Return GetStr(s.Chars, s.Length As SIZE_T, tcs)
[142]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
[149]181 Return GetStr(s.Chars, s.Length As SIZE_T, ss)
[142]182End Function
183
184Function ToWCStr(psz As PSTR) As PWSTR
[149]185 GetStr(psz, ToWCStr)
[142]186End Function
187
188Function ToWCStr(psz As PSTR, len As SIZE_T) As PWSTR
[149]189 GetStr(psz, len, ToWCStr)
[142]190End Function
191
192Function ToWCStr(psz As PWSTR) As PWSTR
[149]193 GetStr(psz, ToWCStr)
[142]194End Function
195
196Function ToWCStr(psz As PWSTR, len As SIZE_T) As PWSTR
[149]197 GetStr(psz, len, ToWCStr)
[142]198End Function
199
200Function ToWCStr(ByRef s As String) As PWSTR
[149]201 GetStr(s.Chars As PWSTR, s.Length As SIZE_T, ToWCStr)
[142]202End Function
203
204Function ToMBStr(psz As PSTR) As PSTR
[149]205 GetStr(psz, ToMBStr)
[142]206End Function
207
208Function ToMBStr(psz As PSTR, len As SIZE_T) As PSTR
[149]209 GetStr(psz, len, ToMBStr)
[142]210End Function
211
212Function ToMBStr(psz As PWSTR) As PSTR
[149]213 GetStr(psz, ToMBStr)
[142]214End Function
215
216Function ToMBStr(psz As PWSTR, len As SIZE_T) As PSTR
[149]217 GetStr(psz, len, ToMBStr)
[142]218End Function
219
220Function ToMBStr(ByRef s As String) As PSTR
[149]221 GetStr(s.Chars, s.Length As SIZE_T, ToMBStr)
[142]222End Function
223
224Function ToTCStr(psz As PSTR) As PCTSTR
[149]225 GetStr(psz, ToTCStr)
[142]226End Function
227
228Function ToTCStr(psz As PSTR, len As SIZE_T) As PCTSTR
[149]229 GetStr(psz, len, ToTCStr)
[142]230End Function
231
232Function ToTCStr(psz As PWSTR) As PCTSTR
[149]233 GetStr(psz, ToTCStr)
[142]234End Function
235
236Function ToTCStr(psz As PWSTR, len As SIZE_T) As PCTSTR
[149]237 GetStr(psz, len, ToTCStr)
[142]238End Function
239
240Function ToTCStr(ByRef s As String) As PCTSTR
[149]241 GetStr(s.Chars, s.Length As SIZE_T, ToTCStr)
[142]242End Function
243
244Function ToSCStr(psz As PSTR) As *StrChar
[149]245 GetStr(psz, ToSCStr)
[142]246End Function
247
248Function ToSCStr(psz As PSTR, len As SIZE_T) As *StrChar
[149]249 GetStr(psz, len, ToSCStr)
[142]250End Function
251
252Function ToSCStr(psz As PWSTR) As *StrChar
[149]253 GetStr(psz, ToSCStr)
[142]254End Function
255
256Function ToSCStr(psz As PWSTR, len As SIZE_T) As *StrChar
[149]257 GetStr(psz, len, ToSCStr)
[142]258End Function
259
260Function ToSCStr(ByRef s As String) As *StrChar
[149]261 GetStr(s.Chars, s.Length As SIZE_T, ToSCStr)
[142]262End Function
263
[1]264#endif '_INC_BASIC_STRING
Note: See TracBrowser for help on using the repository browser.