1 |
(* ***** BEGIN LICENSE BLOCK *****
|
2 |
* Version: MPL 1.1
|
3 |
*
|
4 |
* The contents of this file are subject to the Mozilla Public License Version
|
5 |
* 1.1 (the "License"); you may not use this file except in compliance with
|
6 |
* the License. You may obtain a copy of the License at
|
7 |
* http://www.mozilla.org/MPL/
|
8 |
*
|
9 |
* Software distributed under the License is distributed on an "AS IS" basis,
|
10 |
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
11 |
* for the specific language governing rights and limitations under the
|
12 |
* License.
|
13 |
*
|
14 |
* The Original Code is TurboPower SysTools
|
15 |
*
|
16 |
* The Initial Developer of the Original Code is
|
17 |
* TurboPower Software
|
18 |
*
|
19 |
* Portions created by the Initial Developer are Copyright (C) 1996-2002
|
20 |
* the Initial Developer. All Rights Reserved.
|
21 |
*
|
22 |
* Contributor(s):
|
23 |
*
|
24 |
* ***** END LICENSE BLOCK ***** *)
|
25 |
|
26 |
{*********************************************************}
|
27 |
{* _STSTRING.PAS 3.00 *}
|
28 |
{*********************************************************}
|
29 |
|
30 |
{$I STDEFINE.INC}
|
31 |
{$I STCOMDEF.INC}
|
32 |
unit _StString;
|
33 |
|
34 |
interface
|
35 |
|
36 |
uses
|
37 |
ComObj, Classes, SysTools_TLB, StdVcl;
|
38 |
|
39 |
type
|
40 |
TStString = class(TAutoObject, IStString)
|
41 |
private {Private declarations }
|
42 |
FTokens : IStStringList;
|
43 |
FTokensList : TStringList;
|
44 |
FIsLicensed : Boolean;
|
45 |
public {Public declarations }
|
46 |
procedure Initialize; override;
|
47 |
destructor Destroy; override;
|
48 |
protected {Protected declarations }
|
49 |
{ IStString - Methods }
|
50 |
function AddBackSlash(const DirName: WideString): WideString; safecall;
|
51 |
function AsciiCount(const S, WordDelims, Quote: WideString): Integer; safecall;
|
52 |
function AsciiPosition(N: Integer; const S, WordDelims, Quote: WideString; var Pos: Integer): WordBool; safecall;
|
53 |
function BinaryB(B: Byte): WideString; safecall;
|
54 |
function BinaryW(W: Integer): WideString; safecall;
|
55 |
function BinaryL(L: Integer): WideString; safecall;
|
56 |
function Center(const S: WideString; Len: Integer): WideString; safecall;
|
57 |
function CenterCh(const S, C: WideString; Len: Integer): WideString; safecall;
|
58 |
function CharCount(const S, C: WideString): Integer; safecall;
|
59 |
function CharExists(const S, C: WideString): WordBool; safecall;
|
60 |
function CharStr(const C: WideString; Len: Integer): WideString; safecall;
|
61 |
function CleanPathName(const PathName: WideString): WideString; safecall;
|
62 |
function Commaize(L: Integer): WideString; safecall;
|
63 |
function CommaizeCh(L: Integer; const Ch: WideString): WideString; safecall;
|
64 |
function CompString(const S1, S2: WideString): Integer; safecall;
|
65 |
function CompUCString(const S1, S2: WideString): Integer; safecall;
|
66 |
function ContainsOnly(const S, Chars: WideString; var BadPos: Integer): WordBool; safecall;
|
67 |
function ContainsOtherThan(const S, Chars: WideString; var BadPos: Integer): WordBool; safecall;
|
68 |
function CopyFromNthWord(const S, WordDelims, AWord: WideString; N: Integer; var SubString: WideString): WordBool; safecall;
|
69 |
function CopyFromToWord(const S, WordDelims, Word1, Word2: WideString; N1, N2: Integer; var SubString: WideString): WordBool; safecall;
|
70 |
function CopyLeft(const S: WideString; Len: Integer): WideString; safecall;
|
71 |
function CopyMid(const S: WideString; First, Len: Integer): WideString; safecall;
|
72 |
function CopyRight(const S: WideString; First: Integer): WideString; safecall;
|
73 |
function CopyWithin(const S, Delimiter: WideString; Strip: WordBool): WideString; safecall;
|
74 |
function DefaultExtension(const Name, Ext: WideString): WideString; safecall;
|
75 |
function DeleteFromNthWord(const S, WordDelims, AWord: WideString; N: Integer; var SubString: WideString): WordBool; safecall;
|
76 |
function DeleteFromToWord(const S, WordDelims, Word1, Word2: WideString; N1, N2: Integer; var SubString: WideString): WordBool; safecall;
|
77 |
function DeleteWithin(const S, Delimeter: WideString): WideString; safecall;
|
78 |
function Detab(const S: WideString; TabSize: Byte): WideString; safecall;
|
79 |
function Entab(const S: WideString; TabSize: Byte): WideString; safecall;
|
80 |
function Ext2Str(R: OleVariant; Width, Places: Byte): WideString; safecall;
|
81 |
function ExtractAscii(N: Integer; const S, WordDelims, Quote: WideString): WideString; safecall;
|
82 |
function ExtractTokens(const S, Delims, QuoteChar: WideString; AllowNulls: WordBool; out Tokens: IStStringList): Integer; safecall;
|
83 |
function ExtractWord(N: Integer; const S, WordDelims: WideString): WideString; safecall;
|
84 |
function Filter(const S, Filters: WideString): WideString; safecall;
|
85 |
function FloatForm(const Mask: WideString; R: Double; L: Integer; const LtCurr, RtCurr, Sep, DecPt: WideString): WideString; safecall;
|
86 |
function ForceExtension(const Name, Ext: WideString): WideString; safecall;
|
87 |
function HasExtension(const Name: WideString; var DotPos: Integer): WordBool; safecall;
|
88 |
function HexB(B: Byte): WideString; safecall;
|
89 |
function HexW(W: Integer): WideString; safecall;
|
90 |
function HexL(L: Integer): WideString; safecall;
|
91 |
function IsChAlpha(const C: WideString): WordBool; safecall;
|
92 |
function IsChAlphaNumeric(const C, Numbers: WideString): WordBool; safecall;
|
93 |
function IsChNumeric(const C, Numbers: WideString): WordBool; safecall;
|
94 |
function IsStrAlpha(const S: WideString): WordBool; safecall;
|
95 |
function IsStrAlphaNumeric(const S, Numbers: WideString): WordBool; safecall;
|
96 |
function IsStrNumeric(const S, Numbers: WideString): WordBool; safecall;
|
97 |
function JustExtension(const Name: WideString): WideString; safecall;
|
98 |
function JustFilename(const PathName: WideString): WideString; safecall;
|
99 |
function JustName(const PathName: WideString): WideString; safecall;
|
100 |
function JustPathname(const PathName: WideString): WideString; safecall;
|
101 |
function KeepChars(const S, Chars: WideString): WideString; safecall;
|
102 |
function LastString(const S, AString: WideString; var Position: Integer): WordBool; safecall;
|
103 |
function LastWord(const S, WordDelims, AWord: WideString; var Position: Integer): WordBool; safecall;
|
104 |
function LastWordAbs(const S, WordDelims: WideString; var Position: Integer): WordBool; safecall;
|
105 |
function LeftPad(const S: WideString; Len: Integer): WideString; safecall;
|
106 |
function LeftPadCh(const S, C: WideString; Len: Integer): WideString; safecall;
|
107 |
function LeftTrimChars(const S, Chars: WideString): WideString; safecall;
|
108 |
function Long2Str(L: Integer): WideString; safecall;
|
109 |
function LongIntForm(const Mask: WideString; L: Integer; const LtCurr, RtCurr, Sep: WideString): WideString; safecall;
|
110 |
function OctalB(B: Byte): WideString; safecall;
|
111 |
function OctalW(W: Integer): WideString; safecall;
|
112 |
function OctalL(L: Integer): WideString; safecall;
|
113 |
function Pad(const S: WideString; Len: Integer): WideString; safecall;
|
114 |
function PadCh(const S, C: WideString; Len: Integer): WideString; safecall;
|
115 |
function Real2Str(R: Double; Width, Places: Byte): WideString; safecall;
|
116 |
function RepeatString(const S: WideString; var Repetitions: Integer; MaxLen: Integer): WideString; safecall;
|
117 |
function ReplaceWord(const S, WordDelims, OldWord, NewWord: WideString; N: Integer; var Replacements: Integer): WideString; safecall;
|
118 |
function ReplaceWordAll(const S, WordDelims, OldWord, NewWord: WideString; var Replacements: Integer): WideString; safecall;
|
119 |
function ReplaceString(const S, OldString, NewString: WideString; N: Integer; var Replacements: Integer): WideString; safecall;
|
120 |
function ReplaceStringAll(const S, OldString, NewString: WideString; var Replacements: Integer): WideString; safecall;
|
121 |
function RightTrimChars(const S, Chars: WideString): WideString; safecall;
|
122 |
function Scramble(const S, Key: WideString): WideString; safecall;
|
123 |
function Str2Ext(const S: WideString; var R: OleVariant): WordBool; safecall;
|
124 |
function Str2Int16(const S: WideString; var I: Smallint): WordBool; safecall;
|
125 |
function Str2Long(const S: WideString; var I: Integer): WordBool; safecall;
|
126 |
function Str2Real(const S: WideString; var R: Double): WordBool; safecall;
|
127 |
function Str2Word(const S: WideString; var W: Integer): WordBool; safecall;
|
128 |
function StrChDelete(const S: WideString; Pos: Integer): WideString; safecall;
|
129 |
function StrChInsert(const S, C: WideString; Pos: Integer): WideString; safecall;
|
130 |
function StrChPos(const P, C: WideString; var Pos: Integer): WordBool; safecall;
|
131 |
function StrStCopy(const S: WideString; Pos, Count: Integer): WideString; safecall;
|
132 |
function StrStDelete(const S: WideString; Pos, Count: Integer): WideString; safecall;
|
133 |
function StrStInsert(const S1, S2: WideString; Pos: Integer): WideString; safecall;
|
134 |
function StrStPos(const P, S: WideString; var Pos: Integer): WordBool; safecall;
|
135 |
function StrWithin(const S, SearchStr: WideString; Start: Integer; var Position: Integer): WordBool; safecall;
|
136 |
function Substitute(const S, FromStr, ToStr: WideString): WideString; safecall;
|
137 |
function Trim(const S: WideString): WideString; safecall;
|
138 |
function TrimChars(const S, Chars: WideString): WideString; safecall;
|
139 |
function TrimLead(const S: WideString): WideString; safecall;
|
140 |
function TrimSpaces(const S: WideString): WideString; safecall;
|
141 |
function TrimTrail(const S: WideString): WideString; safecall;
|
142 |
function ValPrep(const S: WideString): WideString; safecall;
|
143 |
function WordCount(const S, WordDelims: WideString): Integer; safecall;
|
144 |
function WordPos(const S, WordDelims, AWord: WideString; N: Integer; var Position: Integer): WordBool; safecall;
|
145 |
function WordPosition(N: Integer; const S, WordDelims: WideString; var Position: Integer): WordBool; safecall;
|
146 |
procedure WordWrap(const InSt: WideString; var OutSt, Overlap: WideString; Margin: Integer; PadToMArgin: WordBool); safecall;
|
147 |
function License(const Key: WideString): WordBool; safecall;
|
148 |
function Soundex(const S: WideString): WideString; safecall;
|
149 |
end;
|
150 |
|
151 |
implementation
|
152 |
|
153 |
uses ComServ, StStrL, StStrW, _StUtil {$IFDEF LICENSE}, ActiveX, StComLic {$ENDIF};
|
154 |
|
155 |
{ ********** TStString Interface ********************************************************* }
|
156 |
procedure TStString.Initialize;
|
157 |
begin
|
158 |
inherited Initialize;
|
159 |
FTokensList := TStringList.Create;
|
160 |
FTokens := TStStringList.Create(FTokensList);
|
161 |
{$IFDEF LICENSE}
|
162 |
FIsLicensed := False;
|
163 |
{$ELSE}
|
164 |
FIsLicensed := True;
|
165 |
{$ENDIF}
|
166 |
end;
|
167 |
|
168 |
destructor TStString.Destroy;
|
169 |
begin
|
170 |
if Assigned (FTokensList) then
|
171 |
FTokensList.Free;
|
172 |
|
173 |
FTokens := nil;
|
174 |
inherited Destroy;
|
175 |
end;
|
176 |
|
177 |
{ ********** TStString Methods *********************************************************** }
|
178 |
function TStString.AddBackSlash(const DirName: WideString): WideString;
|
179 |
begin
|
180 |
{$IFDEF LICENSE}
|
181 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
182 |
OleError(CLASS_E_NOTLICENSED);
|
183 |
{$ENDIF}
|
184 |
Result := StStrW.AddBackSlashW(DirName);
|
185 |
end;
|
186 |
|
187 |
function TStString.AsciiCount(const S, WordDelims,
|
188 |
Quote: WideString): Integer;
|
189 |
begin
|
190 |
{$IFDEF LICENSE}
|
191 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
192 |
OleError(CLASS_E_NOTLICENSED);
|
193 |
{$ENDIF}
|
194 |
Result := StStrW.AsciiCountW(S, WordDelims, Quote[1])
|
195 |
end;
|
196 |
|
197 |
function TStString.AsciiPosition(N: Integer; const S, WordDelims,
|
198 |
Quote: WideString; var Pos: Integer): WordBool;
|
199 |
begin
|
200 |
{$IFDEF LICENSE}
|
201 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
202 |
OleError(CLASS_E_NOTLICENSED);
|
203 |
{$ENDIF}
|
204 |
Result := StStrW.AsciiPositionW(Cardinal(N), S, WordDelims, Quote[1], Cardinal(Pos));
|
205 |
end;
|
206 |
|
207 |
function TStString.BinaryB(B: Byte): WideString;
|
208 |
begin
|
209 |
{$IFDEF LICENSE}
|
210 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
211 |
OleError(CLASS_E_NOTLICENSED);
|
212 |
{$ENDIF}
|
213 |
Result := StStrW.BinaryBW(B);
|
214 |
end;
|
215 |
|
216 |
function TStString.BinaryW(W: Integer): WideString;
|
217 |
begin
|
218 |
{$IFDEF LICENSE}
|
219 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
220 |
OleError(CLASS_E_NOTLICENSED);
|
221 |
{$ENDIF}
|
222 |
Result := StStrW.BinaryWW(W);
|
223 |
end;
|
224 |
|
225 |
function TStString.BinaryL(L: Integer): WideString;
|
226 |
begin
|
227 |
{$IFDEF LICENSE}
|
228 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
229 |
OleError(CLASS_E_NOTLICENSED);
|
230 |
{$ENDIF}
|
231 |
Result := StStrW.BinaryLW(Cardinal(L));
|
232 |
end;
|
233 |
|
234 |
function TStString.Center(const S: WideString; Len: Integer): WideString;
|
235 |
begin
|
236 |
{$IFDEF LICENSE}
|
237 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
238 |
OleError(CLASS_E_NOTLICENSED);
|
239 |
{$ENDIF}
|
240 |
Result := StStrW.CenterW(S, Cardinal(Len));
|
241 |
end;
|
242 |
|
243 |
function TStString.CenterCh(const S, C: WideString;
|
244 |
Len: Integer): WideString;
|
245 |
begin
|
246 |
{$IFDEF LICENSE}
|
247 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
248 |
OleError(CLASS_E_NOTLICENSED);
|
249 |
{$ENDIF}
|
250 |
Result := StStrW.CenterChW(S, C[1], Cardinal(Len));
|
251 |
end;
|
252 |
|
253 |
function TStString.CharCount(const S, C: WideString): Integer;
|
254 |
begin
|
255 |
{$IFDEF LICENSE}
|
256 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
257 |
OleError(CLASS_E_NOTLICENSED);
|
258 |
{$ENDIF}
|
259 |
Result := StStrW.CharCountW(S, C[1]);
|
260 |
end;
|
261 |
|
262 |
function TStString.CharExists(const S, C: WideString): WordBool;
|
263 |
begin
|
264 |
{$IFDEF LICENSE}
|
265 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
266 |
OleError(CLASS_E_NOTLICENSED);
|
267 |
{$ENDIF}
|
268 |
Result := StStrW.CharExistsW(S, C[1]);
|
269 |
end;
|
270 |
|
271 |
function TStString.CharStr(const C: WideString; Len: Integer): WideString;
|
272 |
begin
|
273 |
{$IFDEF LICENSE}
|
274 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
275 |
OleError(CLASS_E_NOTLICENSED);
|
276 |
{$ENDIF}
|
277 |
Result := StStrW.CharStrW(C[1], Cardinal(Len));
|
278 |
end;
|
279 |
|
280 |
function TStString.CleanPathName(const PathName: WideString): WideString;
|
281 |
begin
|
282 |
{$IFDEF LICENSE}
|
283 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
284 |
OleError(CLASS_E_NOTLICENSED);
|
285 |
{$ENDIF}
|
286 |
Result := StStrW.CleanPathNameW(PathName);
|
287 |
end;
|
288 |
|
289 |
function TStString.Commaize(L: Integer): WideString;
|
290 |
begin
|
291 |
{$IFDEF LICENSE}
|
292 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
293 |
OleError(CLASS_E_NOTLICENSED);
|
294 |
{$ENDIF}
|
295 |
Result := StStrW.CommaizeW(LongInt(L));
|
296 |
end;
|
297 |
|
298 |
function TStString.CommaizeCh(L: Integer;
|
299 |
const Ch: WideString): WideString;
|
300 |
begin
|
301 |
{$IFDEF LICENSE}
|
302 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
303 |
OleError(CLASS_E_NOTLICENSED);
|
304 |
{$ENDIF}
|
305 |
Result := StStrW.CommaizeChW(LongInt(L), Ch[1]);
|
306 |
end;
|
307 |
|
308 |
function TStString.CompString(const S1, S2: WideString): Integer;
|
309 |
begin
|
310 |
{$IFDEF LICENSE}
|
311 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
312 |
OleError(CLASS_E_NOTLICENSED);
|
313 |
{$ENDIF}
|
314 |
Result := StStrW.CompStringW(S1, S2);
|
315 |
end;
|
316 |
|
317 |
function TStString.CompUCString(const S1, S2: WideString): Integer;
|
318 |
begin
|
319 |
{$IFDEF LICENSE}
|
320 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
321 |
OleError(CLASS_E_NOTLICENSED);
|
322 |
{$ENDIF}
|
323 |
Result := StStrW.CompUCStringW(S1, S2);
|
324 |
end;
|
325 |
|
326 |
function TStString.ContainsOnly(const S, Chars: WideString;
|
327 |
var BadPos: Integer): WordBool;
|
328 |
begin
|
329 |
{$IFDEF LICENSE}
|
330 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
331 |
OleError(CLASS_E_NOTLICENSED);
|
332 |
{$ENDIF}
|
333 |
Result := StStrW.ContainsOnlyW(S, Chars, Cardinal(BadPos));
|
334 |
end;
|
335 |
|
336 |
function TStString.ContainsOtherThan(const S, Chars: WideString;
|
337 |
var BadPos: Integer): WordBool;
|
338 |
begin
|
339 |
{$IFDEF LICENSE}
|
340 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
341 |
OleError(CLASS_E_NOTLICENSED);
|
342 |
{$ENDIF}
|
343 |
Result := StStrW.ContainsOtherThanW(S, Chars, Cardinal(BadPos));
|
344 |
end;
|
345 |
|
346 |
function TStString.CopyFromNthWord(const S, WordDelims, AWord: WideString;
|
347 |
N: Integer; var SubString: WideString): WordBool;
|
348 |
begin
|
349 |
{$IFDEF LICENSE}
|
350 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
351 |
OleError(CLASS_E_NOTLICENSED);
|
352 |
{$ENDIF}
|
353 |
Result := StStrW.CopyFromNthWordW(S, WordDelims, AWord, Cardinal(N), SubString);
|
354 |
end;
|
355 |
|
356 |
function TStString.CopyFromToWord(const S, WordDelims, Word1,
|
357 |
Word2: WideString; N1, N2: Integer; var SubString: WideString): WordBool;
|
358 |
begin
|
359 |
{$IFDEF LICENSE}
|
360 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
361 |
OleError(CLASS_E_NOTLICENSED);
|
362 |
{$ENDIF}
|
363 |
Result := StStrW.CopyFromToWordW(S, WordDelims, Word1, Word2, Cardinal(N1), Cardinal(N2), SubString);
|
364 |
end;
|
365 |
|
366 |
function TStString.CopyLeft(const S: WideString; Len: Integer): WideString;
|
367 |
begin
|
368 |
{$IFDEF LICENSE}
|
369 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
370 |
OleError(CLASS_E_NOTLICENSED);
|
371 |
{$ENDIF}
|
372 |
Result := StStrW.CopyLeftW(S, Cardinal(Len));
|
373 |
end;
|
374 |
|
375 |
function TStString.CopyMid(const S: WideString; First,
|
376 |
Len: Integer): WideString;
|
377 |
begin
|
378 |
{$IFDEF LICENSE}
|
379 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
380 |
OleError(CLASS_E_NOTLICENSED);
|
381 |
{$ENDIF}
|
382 |
Result := StStrW.CopyMidW(S, Cardinal(First), Cardinal(Len));
|
383 |
end;
|
384 |
|
385 |
function TStString.CopyRight(const S: WideString;
|
386 |
First: Integer): WideString;
|
387 |
begin
|
388 |
{$IFDEF LICENSE}
|
389 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
390 |
OleError(CLASS_E_NOTLICENSED);
|
391 |
{$ENDIF}
|
392 |
Result := StStrW.CopyRightW(S, Cardinal(First));
|
393 |
end;
|
394 |
|
395 |
function TStString.CopyWithin(const S, Delimiter: WideString;
|
396 |
Strip: WordBool): WideString;
|
397 |
begin
|
398 |
{$IFDEF LICENSE}
|
399 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
400 |
OleError(CLASS_E_NOTLICENSED);
|
401 |
{$ENDIF}
|
402 |
Result := StStrW.CopyWithinW(S, Delimiter, Strip);
|
403 |
end;
|
404 |
|
405 |
function TStString.DefaultExtension(const Name,
|
406 |
Ext: WideString): WideString;
|
407 |
begin
|
408 |
{$IFDEF LICENSE}
|
409 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
410 |
OleError(CLASS_E_NOTLICENSED);
|
411 |
{$ENDIF}
|
412 |
Result := StStrW.DefaultExtensionW(Name, Ext);
|
413 |
end;
|
414 |
|
415 |
function TStString.DeleteFromNthWord(const S, WordDelims,
|
416 |
AWord: WideString; N: Integer; var SubString: WideString): WordBool;
|
417 |
begin
|
418 |
{$IFDEF LICENSE}
|
419 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
420 |
OleError(CLASS_E_NOTLICENSED);
|
421 |
{$ENDIF}
|
422 |
Result := StStrW.DeleteFromNthWordW(S, WordDelims, AWord, Cardinal(N), SubString);
|
423 |
end;
|
424 |
|
425 |
function TStString.DeleteFromToWord(const S, WordDelims, Word1,
|
426 |
Word2: WideString; N1, N2: Integer; var SubString: WideString): WordBool;
|
427 |
begin
|
428 |
{$IFDEF LICENSE}
|
429 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
430 |
OleError(CLASS_E_NOTLICENSED);
|
431 |
{$ENDIF}
|
432 |
Result := StStrW.DeleteFromToWordW(S, WordDelims, Word1, Word2, Cardinal(N1), Cardinal(N2), SubString);
|
433 |
end;
|
434 |
|
435 |
function TStString.DeleteWithin(const S,
|
436 |
Delimeter: WideString): WideString;
|
437 |
begin
|
438 |
{$IFDEF LICENSE}
|
439 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
440 |
OleError(CLASS_E_NOTLICENSED);
|
441 |
{$ENDIF}
|
442 |
Result := StStrW.DeleteWithinW(S, Delimeter);
|
443 |
end;
|
444 |
|
445 |
function TStString.Detab(const S: WideString; TabSize: Byte): WideString;
|
446 |
begin
|
447 |
{$IFDEF LICENSE}
|
448 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
449 |
OleError(CLASS_E_NOTLICENSED);
|
450 |
{$ENDIF}
|
451 |
Result := StStrW.DetabW(S, TabSize);
|
452 |
end;
|
453 |
|
454 |
function TStString.Entab(const S: WideString; TabSize: Byte): WideString;
|
455 |
begin
|
456 |
{$IFDEF LICENSE}
|
457 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
458 |
OleError(CLASS_E_NOTLICENSED);
|
459 |
{$ENDIF}
|
460 |
Result := StStrW.EntabW(S, TabSize);
|
461 |
end;
|
462 |
|
463 |
function TStString.Ext2Str(R: OleVariant; Width, Places: Byte): WideString;
|
464 |
var
|
465 |
X : Extended;
|
466 |
begin
|
467 |
{$IFDEF LICENSE}
|
468 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
469 |
OleError(CLASS_E_NOTLICENSED);
|
470 |
{$ENDIF}
|
471 |
{!! Will this work with an OleVariant instead of Extended? !!}
|
472 |
X := R;
|
473 |
Result := StStrW.Ext2StrW(X, Width, ShortInt(Places));
|
474 |
end;
|
475 |
|
476 |
function TStString.ExtractAscii(N: Integer; const S, WordDelims,
|
477 |
Quote: WideString): WideString;
|
478 |
begin
|
479 |
{$IFDEF LICENSE}
|
480 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
481 |
OleError(CLASS_E_NOTLICENSED);
|
482 |
{$ENDIF}
|
483 |
Result := StStrW.ExtractAsciiW(Cardinal(N), S, WordDelims, Quote[1]);
|
484 |
end;
|
485 |
|
486 |
function TStString.ExtractTokens(const S, Delims, QuoteChar: WideString;
|
487 |
AllowNulls: WordBool; out Tokens: IStStringList): Integer;
|
488 |
begin
|
489 |
{$IFDEF LICENSE}
|
490 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
491 |
OleError(CLASS_E_NOTLICENSED);
|
492 |
{$ENDIF}
|
493 |
FTokensList.Clear;
|
494 |
Result := StStrW.ExtractTokensW(S, Delims, QuoteChar[1], AllowNulls, FTokensList);
|
495 |
Tokens := FTokens;
|
496 |
end;
|
497 |
|
498 |
function TStString.ExtractWord(N: Integer; const S,
|
499 |
WordDelims: WideString): WideString;
|
500 |
begin
|
501 |
{$IFDEF LICENSE}
|
502 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
503 |
OleError(CLASS_E_NOTLICENSED);
|
504 |
{$ENDIF}
|
505 |
Result := StStrW.ExtractWordW(Cardinal(N), S, WordDelims);
|
506 |
end;
|
507 |
|
508 |
function TStString.Filter(const S, Filters: WideString): WideString;
|
509 |
begin
|
510 |
{$IFDEF LICENSE}
|
511 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
512 |
OleError(CLASS_E_NOTLICENSED);
|
513 |
{$ENDIF}
|
514 |
Result := StStrW.FilterW(S, Filters);
|
515 |
end;
|
516 |
|
517 |
function TStString.FloatForm(const Mask: WideString; R: Double; L: Integer;
|
518 |
const LtCurr, RtCurr, Sep, DecPt: WideString): WideString;
|
519 |
begin
|
520 |
{$IFDEF LICENSE}
|
521 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
522 |
OleError(CLASS_E_NOTLICENSED);
|
523 |
{$ENDIF}
|
524 |
Result := StStrW.FloatFormW(Mask, R, LtCurr, RtCurr, Sep[1], DecPt[1])
|
525 |
end;
|
526 |
|
527 |
function TStString.ForceExtension(const Name, Ext: WideString): WideString;
|
528 |
begin
|
529 |
{$IFDEF LICENSE}
|
530 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
531 |
OleError(CLASS_E_NOTLICENSED);
|
532 |
{$ENDIF}
|
533 |
Result := StStrW.ForceExtensionW(Name, Ext);
|
534 |
end;
|
535 |
|
536 |
function TStString.HasExtension(const Name: WideString;
|
537 |
var DotPos: Integer): WordBool;
|
538 |
begin
|
539 |
{$IFDEF LICENSE}
|
540 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
541 |
OleError(CLASS_E_NOTLICENSED);
|
542 |
{$ENDIF}
|
543 |
Result := StStrW.HasExtensionW(Name, Cardinal(DotPos));
|
544 |
end;
|
545 |
|
546 |
function TStString.HexB(B: Byte): WideString;
|
547 |
begin
|
548 |
{$IFDEF LICENSE}
|
549 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
550 |
OleError(CLASS_E_NOTLICENSED);
|
551 |
{$ENDIF}
|
552 |
Result := StStrW.HexBW(B);
|
553 |
end;
|
554 |
|
555 |
function TStString.HexW(W: Integer): WideString;
|
556 |
begin
|
557 |
{$IFDEF LICENSE}
|
558 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
559 |
OleError(CLASS_E_NOTLICENSED);
|
560 |
{$ENDIF}
|
561 |
Result := StStrW.HexWW(W);
|
562 |
end;
|
563 |
|
564 |
function TStString.HexL(L: Integer): WideString;
|
565 |
begin
|
566 |
{$IFDEF LICENSE}
|
567 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
568 |
OleError(CLASS_E_NOTLICENSED);
|
569 |
{$ENDIF}
|
570 |
Result := StStrW.HexLW(LongInt(L));
|
571 |
end;
|
572 |
|
573 |
function TStString.IsChAlpha(const C: WideString): WordBool;
|
574 |
begin
|
575 |
{$IFDEF LICENSE}
|
576 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
577 |
OleError(CLASS_E_NOTLICENSED);
|
578 |
{$ENDIF}
|
579 |
Result := StStrW.IsChAlphaW(C[1]);
|
580 |
end;
|
581 |
|
582 |
function TStString.IsChAlphaNumeric(const C,
|
583 |
Numbers: WideString): WordBool;
|
584 |
begin
|
585 |
{$IFDEF LICENSE}
|
586 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
587 |
OleError(CLASS_E_NOTLICENSED);
|
588 |
{$ENDIF}
|
589 |
Result := StStrW.IsChAlphaNumericW(C[1], Numbers);
|
590 |
end;
|
591 |
|
592 |
function TStString.IsChNumeric(const C, Numbers: WideString): WordBool;
|
593 |
begin
|
594 |
{$IFDEF LICENSE}
|
595 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
596 |
OleError(CLASS_E_NOTLICENSED);
|
597 |
{$ENDIF}
|
598 |
Result := StStrW.IsChNumericW(C[1], Numbers);
|
599 |
end;
|
600 |
|
601 |
function TStString.IsStrAlpha(const S: WideString): WordBool;
|
602 |
begin
|
603 |
{$IFDEF LICENSE}
|
604 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
605 |
OleError(CLASS_E_NOTLICENSED);
|
606 |
{$ENDIF}
|
607 |
Result := StStrW.IsStrAlphaW(S);
|
608 |
end;
|
609 |
|
610 |
function TStString.IsStrAlphaNumeric(const S,
|
611 |
Numbers: WideString): WordBool;
|
612 |
begin
|
613 |
{$IFDEF LICENSE}
|
614 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
615 |
OleError(CLASS_E_NOTLICENSED);
|
616 |
{$ENDIF}
|
617 |
Result := StStrW.IsStrAlphaNumericW(S, Numbers);
|
618 |
end;
|
619 |
|
620 |
function TStString.IsStrNumeric(const S, Numbers: WideString): WordBool;
|
621 |
begin
|
622 |
{$IFDEF LICENSE}
|
623 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
624 |
OleError(CLASS_E_NOTLICENSED);
|
625 |
{$ENDIF}
|
626 |
Result := StStrW.IsStrNumericW(S, Numbers);
|
627 |
end;
|
628 |
|
629 |
function TStString.JustExtension(const Name: WideString): WideString;
|
630 |
begin
|
631 |
{$IFDEF LICENSE}
|
632 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
633 |
OleError(CLASS_E_NOTLICENSED);
|
634 |
{$ENDIF}
|
635 |
Result := StStrW.JustExtensionW(Name);
|
636 |
end;
|
637 |
|
638 |
function TStString.JustFilename(const PathName: WideString): WideString;
|
639 |
begin
|
640 |
{$IFDEF LICENSE}
|
641 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
642 |
OleError(CLASS_E_NOTLICENSED);
|
643 |
{$ENDIF}
|
644 |
Result := StStrW.JustFilenameW(PathName);
|
645 |
end;
|
646 |
|
647 |
function TStString.JustName(const PathName: WideString): WideString;
|
648 |
begin
|
649 |
{$IFDEF LICENSE}
|
650 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
651 |
OleError(CLASS_E_NOTLICENSED);
|
652 |
{$ENDIF}
|
653 |
Result := StStrW.JustNameW(PathName);
|
654 |
end;
|
655 |
|
656 |
function TStString.JustPathname(const PathName: WideString): WideString;
|
657 |
begin
|
658 |
{$IFDEF LICENSE}
|
659 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
660 |
OleError(CLASS_E_NOTLICENSED);
|
661 |
{$ENDIF}
|
662 |
Result := StStrW.JustPathnameW(PathName);
|
663 |
end;
|
664 |
|
665 |
function TStString.KeepChars(const S, Chars: WideString): WideString;
|
666 |
begin
|
667 |
{$IFDEF LICENSE}
|
668 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
669 |
OleError(CLASS_E_NOTLICENSED);
|
670 |
{$ENDIF}
|
671 |
Result := StStrW.KeepCharsW(S, Chars);
|
672 |
end;
|
673 |
|
674 |
function TStString.LastString(const S, AString: WideString;
|
675 |
var Position: Integer): WordBool;
|
676 |
begin
|
677 |
{$IFDEF LICENSE}
|
678 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
679 |
OleError(CLASS_E_NOTLICENSED);
|
680 |
{$ENDIF}
|
681 |
Result := StStrW.LastStringW(S, AString, Cardinal(Position));
|
682 |
end;
|
683 |
|
684 |
function TStString.LastWord(const S, WordDelims, AWord: WideString;
|
685 |
var Position: Integer): WordBool;
|
686 |
begin
|
687 |
{$IFDEF LICENSE}
|
688 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
689 |
OleError(CLASS_E_NOTLICENSED);
|
690 |
{$ENDIF}
|
691 |
Result := StStrW.LastWordW(S, WordDelims, AWord, Cardinal(Position));
|
692 |
end;
|
693 |
|
694 |
function TStString.LastWordAbs(const S, WordDelims: WideString;
|
695 |
var Position: Integer): WordBool;
|
696 |
begin
|
697 |
{$IFDEF LICENSE}
|
698 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
699 |
OleError(CLASS_E_NOTLICENSED);
|
700 |
{$ENDIF}
|
701 |
Result := StStrW.LastWordAbsW(S, WordDelims, Cardinal(Position));
|
702 |
end;
|
703 |
|
704 |
function TStString.LeftPad(const S: WideString; Len: Integer): WideString;
|
705 |
begin
|
706 |
{$IFDEF LICENSE}
|
707 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
708 |
OleError(CLASS_E_NOTLICENSED);
|
709 |
{$ENDIF}
|
710 |
Result := StStrW.LeftPadW(S, Cardinal(Len));
|
711 |
end;
|
712 |
|
713 |
function TStString.LeftPadCh(const S, C: WideString;
|
714 |
Len: Integer): WideString;
|
715 |
begin
|
716 |
{$IFDEF LICENSE}
|
717 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
718 |
OleError(CLASS_E_NOTLICENSED);
|
719 |
{$ENDIF}
|
720 |
Result := StStrW.LeftPadChW(S, C[1], Cardinal(Len));
|
721 |
end;
|
722 |
|
723 |
function TStString.LeftTrimChars(const S, Chars: WideString): WideString;
|
724 |
begin
|
725 |
{$IFDEF LICENSE}
|
726 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
727 |
OleError(CLASS_E_NOTLICENSED);
|
728 |
{$ENDIF}
|
729 |
Result := StStrW.LeftTrimCharsW(S, Chars);
|
730 |
end;
|
731 |
|
732 |
function TStString.Long2Str(L: Integer): WideString;
|
733 |
begin
|
734 |
{$IFDEF LICENSE}
|
735 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
736 |
OleError(CLASS_E_NOTLICENSED);
|
737 |
{$ENDIF}
|
738 |
Result := StStrW.Long2StrW(LongInt(L));
|
739 |
end;
|
740 |
|
741 |
function TStString.LongIntForm(const Mask: WideString; L: Integer;
|
742 |
const LtCurr, RtCurr, Sep: WideString): WideString;
|
743 |
begin
|
744 |
{$IFDEF LICENSE}
|
745 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
746 |
OleError(CLASS_E_NOTLICENSED);
|
747 |
{$ENDIF}
|
748 |
Result := StStrW.LongIntFormW(Mask, LongInt(L), LtCurr, RtCurr, Sep[1]);
|
749 |
end;
|
750 |
|
751 |
function TStString.OctalB(B: Byte): WideString;
|
752 |
begin
|
753 |
{$IFDEF LICENSE}
|
754 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
755 |
OleError(CLASS_E_NOTLICENSED);
|
756 |
{$ENDIF}
|
757 |
Result := StStrW.OctalBW(B);
|
758 |
end;
|
759 |
|
760 |
function TStString.OctalW(W: Integer): WideString;
|
761 |
begin
|
762 |
{$IFDEF LICENSE}
|
763 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
764 |
OleError(CLASS_E_NOTLICENSED);
|
765 |
{$ENDIF}
|
766 |
Result := StStrW.OctalWW(W);
|
767 |
end;
|
768 |
|
769 |
function TStString.OctalL(L: Integer): WideString;
|
770 |
begin
|
771 |
{$IFDEF LICENSE}
|
772 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
773 |
OleError(CLASS_E_NOTLICENSED);
|
774 |
{$ENDIF}
|
775 |
Result := StStrW.OctalLW(LongInt(L));
|
776 |
end;
|
777 |
|
778 |
function TStString.Pad(const S: WideString; Len: Integer): WideString;
|
779 |
begin
|
780 |
{$IFDEF LICENSE}
|
781 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
782 |
OleError(CLASS_E_NOTLICENSED);
|
783 |
{$ENDIF}
|
784 |
Result := StStrW.PadW(S, Cardinal(Len));
|
785 |
end;
|
786 |
|
787 |
function TStString.PadCh(const S, C: WideString; Len: Integer): WideString;
|
788 |
begin
|
789 |
{$IFDEF LICENSE}
|
790 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
791 |
OleError(CLASS_E_NOTLICENSED);
|
792 |
{$ENDIF}
|
793 |
Result := StStrW.PadChW(S, C[1], Cardinal(Len));
|
794 |
end;
|
795 |
|
796 |
function TStString.Real2Str(R: Double; Width, Places: Byte): WideString;
|
797 |
begin
|
798 |
{$IFDEF LICENSE}
|
799 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
800 |
OleError(CLASS_E_NOTLICENSED);
|
801 |
{$ENDIF}
|
802 |
Result := StStrW.Real2StrW(R, Width, ShortInt(Places));
|
803 |
end;
|
804 |
|
805 |
function TStString.RepeatString(const S: WideString;
|
806 |
var Repetitions: Integer; MaxLen: Integer): WideString;
|
807 |
begin
|
808 |
{$IFDEF LICENSE}
|
809 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
810 |
OleError(CLASS_E_NOTLICENSED);
|
811 |
{$ENDIF}
|
812 |
Result := StStrW.RepeatStringW(S, Cardinal(Repetitions), Cardinal(MaxLen));
|
813 |
end;
|
814 |
|
815 |
function TStString.ReplaceWord(const S, WordDelims, OldWord,
|
816 |
NewWord: WideString; N: Integer; var Replacements: Integer): WideString;
|
817 |
begin
|
818 |
{$IFDEF LICENSE}
|
819 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
820 |
OleError(CLASS_E_NOTLICENSED);
|
821 |
{$ENDIF}
|
822 |
Result := StStrW.ReplaceWordW(S, WordDelims, OldWord, NewWord, Cardinal(N), Cardinal(Replacements));
|
823 |
end;
|
824 |
|
825 |
function TStString.ReplaceWordAll(const S, WordDelims, OldWord,
|
826 |
NewWord: WideString; var Replacements: Integer): WideString;
|
827 |
begin
|
828 |
{$IFDEF LICENSE}
|
829 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
830 |
OleError(CLASS_E_NOTLICENSED);
|
831 |
{$ENDIF}
|
832 |
Result := StStrW.ReplaceWordAllW(S, WordDelims, OldWord, NewWord, Cardinal(Replacements));
|
833 |
end;
|
834 |
|
835 |
function TStString.ReplaceString(const S, OldString, NewString: WideString;
|
836 |
N: Integer; var Replacements: Integer): WideString;
|
837 |
begin
|
838 |
{$IFDEF LICENSE}
|
839 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
840 |
OleError(CLASS_E_NOTLICENSED);
|
841 |
{$ENDIF}
|
842 |
Result := StStrW.ReplaceStringW(S, OldString, NewString, Cardinal(N), Cardinal(Replacements));
|
843 |
end;
|
844 |
|
845 |
function TStString.ReplaceStringAll(const S, OldString,
|
846 |
NewString: WideString; var Replacements: Integer): WideString;
|
847 |
begin
|
848 |
{$IFDEF LICENSE}
|
849 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
850 |
OleError(CLASS_E_NOTLICENSED);
|
851 |
{$ENDIF}
|
852 |
Result := StStrW.ReplaceStringAllW(S, OldString, NewString, Cardinal(Replacements));
|
853 |
end;
|
854 |
|
855 |
function TStString.RightTrimChars(const S, Chars: WideString): WideString;
|
856 |
begin
|
857 |
{$IFDEF LICENSE}
|
858 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
859 |
OleError(CLASS_E_NOTLICENSED);
|
860 |
{$ENDIF}
|
861 |
Result := StStrW.RightTrimCharsW(S, Chars);
|
862 |
end;
|
863 |
|
864 |
function TStString.Scramble(const S, Key: WideString): WideString;
|
865 |
begin
|
866 |
{$IFDEF LICENSE}
|
867 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
868 |
OleError(CLASS_E_NOTLICENSED);
|
869 |
{$ENDIF}
|
870 |
Result := StStrW.ScrambleW(S, Key);
|
871 |
end;
|
872 |
|
873 |
function TStString.Str2Ext(const S: WideString;
|
874 |
var R: OleVariant): WordBool;
|
875 |
var
|
876 |
R1 : Extended;
|
877 |
begin
|
878 |
{$IFDEF LICENSE}
|
879 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
880 |
OleError(CLASS_E_NOTLICENSED);
|
881 |
{$ENDIF}
|
882 |
R1 := R;
|
883 |
Result := StStrW.Str2ExtW(S, R1);
|
884 |
R := R1;
|
885 |
end;
|
886 |
|
887 |
function TStString.Str2Int16(const S: WideString;
|
888 |
var I: Smallint): WordBool;
|
889 |
begin
|
890 |
{$IFDEF LICENSE}
|
891 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
892 |
OleError(CLASS_E_NOTLICENSED);
|
893 |
{$ENDIF}
|
894 |
Result := StStrW.Str2Int16W(S, I);
|
895 |
end;
|
896 |
|
897 |
function TStString.Str2Long(const S: WideString; var I: Integer): WordBool;
|
898 |
begin
|
899 |
{$IFDEF LICENSE}
|
900 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
901 |
OleError(CLASS_E_NOTLICENSED);
|
902 |
{$ENDIF}
|
903 |
Result := StStrW.Str2LongW(S, LongInt(I));
|
904 |
end;
|
905 |
|
906 |
function TStString.Str2Real(const S: WideString; var R: Double): WordBool;
|
907 |
begin
|
908 |
{$IFDEF LICENSE}
|
909 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
910 |
OleError(CLASS_E_NOTLICENSED);
|
911 |
{$ENDIF}
|
912 |
Result := StStrW.Str2RealW(S, R);
|
913 |
end;
|
914 |
|
915 |
function TStString.Str2Word(const S: WideString; var W: Integer): WordBool;
|
916 |
var
|
917 |
W1 : Word;
|
918 |
begin
|
919 |
{$IFDEF LICENSE}
|
920 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
921 |
OleError(CLASS_E_NOTLICENSED);
|
922 |
{$ENDIF}
|
923 |
Result := StStrW.Str2WordW(S, W1);
|
924 |
W := W1;
|
925 |
end;
|
926 |
|
927 |
function TStString.StrChDelete(const S: WideString;
|
928 |
Pos: Integer): WideString;
|
929 |
begin
|
930 |
{$IFDEF LICENSE}
|
931 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
932 |
OleError(CLASS_E_NOTLICENSED);
|
933 |
{$ENDIF}
|
934 |
Result := StStrW.StrChDeleteW(S, Cardinal(Pos));
|
935 |
end;
|
936 |
|
937 |
function TStString.StrChInsert(const S, C: WideString;
|
938 |
Pos: Integer): WideString;
|
939 |
begin
|
940 |
{$IFDEF LICENSE}
|
941 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
942 |
OleError(CLASS_E_NOTLICENSED);
|
943 |
{$ENDIF}
|
944 |
Result := StStrW.StrChInsertW(S, C[1], Cardinal(Pos));
|
945 |
end;
|
946 |
|
947 |
function TStString.StrChPos(const P, C: WideString;
|
948 |
var Pos: Integer): WordBool;
|
949 |
begin
|
950 |
{$IFDEF LICENSE}
|
951 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
952 |
OleError(CLASS_E_NOTLICENSED);
|
953 |
{$ENDIF}
|
954 |
Result := StStrW.StrChPosW(P, C[1], Cardinal(Pos));
|
955 |
end;
|
956 |
|
957 |
function TStString.StrStCopy(const S: WideString; Pos,
|
958 |
Count: Integer): WideString;
|
959 |
begin
|
960 |
{$IFDEF LICENSE}
|
961 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
962 |
OleError(CLASS_E_NOTLICENSED);
|
963 |
{$ENDIF}
|
964 |
Result := StStrW.StrStCopyW(S, Cardinal(Pos), Cardinal(Count));
|
965 |
end;
|
966 |
|
967 |
function TStString.StrStDelete(const S: WideString; Pos,
|
968 |
Count: Integer): WideString;
|
969 |
begin
|
970 |
{$IFDEF LICENSE}
|
971 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
972 |
OleError(CLASS_E_NOTLICENSED);
|
973 |
{$ENDIF}
|
974 |
Result := StStrW.StrStDeleteW(S, Cardinal(Pos), Cardinal(Count));
|
975 |
end;
|
976 |
|
977 |
function TStString.StrStInsert(const S1, S2: WideString;
|
978 |
Pos: Integer): WideString;
|
979 |
begin
|
980 |
{$IFDEF LICENSE}
|
981 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
982 |
OleError(CLASS_E_NOTLICENSED);
|
983 |
{$ENDIF}
|
984 |
Result := StStrW.StrStInsertW(S1, S2, Cardinal(Pos));
|
985 |
end;
|
986 |
|
987 |
function TStString.StrStPos(const P, S: WideString;
|
988 |
var Pos: Integer): WordBool;
|
989 |
begin
|
990 |
{$IFDEF LICENSE}
|
991 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
992 |
OleError(CLASS_E_NOTLICENSED);
|
993 |
{$ENDIF}
|
994 |
Result := StStrW.StrStPosW(P, S, Cardinal(Pos));
|
995 |
end;
|
996 |
|
997 |
function TStString.StrWithin(const S, SearchStr: WideString;
|
998 |
Start: Integer; var Position: Integer): WordBool;
|
999 |
begin
|
1000 |
{$IFDEF LICENSE}
|
1001 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
1002 |
OleError(CLASS_E_NOTLICENSED);
|
1003 |
{$ENDIF}
|
1004 |
Result := StStrW.StrWithinW(S, SearchStr, Cardinal(Start), Cardinal(Position));
|
1005 |
end;
|
1006 |
|
1007 |
function TStString.Substitute(const S, FromStr,
|
1008 |
ToStr: WideString): WideString;
|
1009 |
begin
|
1010 |
{$IFDEF LICENSE}
|
1011 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
1012 |
OleError(CLASS_E_NOTLICENSED);
|
1013 |
{$ENDIF}
|
1014 |
Result := StStrW.SubstituteW(S, FromStr, ToStr);
|
1015 |
end;
|
1016 |
|
1017 |
function TStString.Trim(const S: WideString): WideString;
|
1018 |
begin
|
1019 |
{$IFDEF LICENSE}
|
1020 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
1021 |
OleError(CLASS_E_NOTLICENSED);
|
1022 |
{$ENDIF}
|
1023 |
Result := StStrW.TrimW(S);
|
1024 |
end;
|
1025 |
|
1026 |
function TStString.TrimChars(const S, Chars: WideString): WideString;
|
1027 |
begin
|
1028 |
{$IFDEF LICENSE}
|
1029 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
1030 |
OleError(CLASS_E_NOTLICENSED);
|
1031 |
{$ENDIF}
|
1032 |
Result := StStrW.TrimCharsW(S, Chars);
|
1033 |
end;
|
1034 |
|
1035 |
function TStString.TrimLead(const S: WideString): WideString;
|
1036 |
begin
|
1037 |
{$IFDEF LICENSE}
|
1038 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
1039 |
OleError(CLASS_E_NOTLICENSED);
|
1040 |
{$ENDIF}
|
1041 |
Result := StStrW.TrimLeadW(S);
|
1042 |
end;
|
1043 |
|
1044 |
function TStString.TrimSpaces(const S: WideString): WideString;
|
1045 |
begin
|
1046 |
{$IFDEF LICENSE}
|
1047 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
1048 |
OleError(CLASS_E_NOTLICENSED);
|
1049 |
{$ENDIF}
|
1050 |
Result := StStrW.TrimSpacesW(S);
|
1051 |
end;
|
1052 |
|
1053 |
function TStString.TrimTrail(const S: WideString): WideString;
|
1054 |
begin
|
1055 |
{$IFDEF LICENSE}
|
1056 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
1057 |
OleError(CLASS_E_NOTLICENSED);
|
1058 |
{$ENDIF}
|
1059 |
Result := StStrW.TrimTrailW(S);
|
1060 |
end;
|
1061 |
|
1062 |
function TStString.ValPrep(const S: WideString): WideString;
|
1063 |
begin
|
1064 |
{$IFDEF LICENSE}
|
1065 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
1066 |
OleError(CLASS_E_NOTLICENSED);
|
1067 |
{$ENDIF}
|
1068 |
Result := StStrW.ValPrepW(S);
|
1069 |
end;
|
1070 |
|
1071 |
function TStString.WordCount(const S, WordDelims: WideString): Integer;
|
1072 |
begin
|
1073 |
{$IFDEF LICENSE}
|
1074 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
1075 |
OleError(CLASS_E_NOTLICENSED);
|
1076 |
{$ENDIF}
|
1077 |
Result := StStrW.WordCountW(S, WordDelims);
|
1078 |
end;
|
1079 |
|
1080 |
function TStString.WordPos(const S, WordDelims, AWord: WideString;
|
1081 |
N: Integer; var Position: Integer): WordBool;
|
1082 |
begin
|
1083 |
{$IFDEF LICENSE}
|
1084 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
1085 |
OleError(CLASS_E_NOTLICENSED);
|
1086 |
{$ENDIF}
|
1087 |
Result := StStrW.WordPosW(S, WordDelims, AWord, Cardinal(N), Cardinal(Position));
|
1088 |
end;
|
1089 |
|
1090 |
function TStString.WordPosition(N: Integer; const S,
|
1091 |
WordDelims: WideString; var Position: Integer): WordBool;
|
1092 |
begin
|
1093 |
{$IFDEF LICENSE}
|
1094 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
1095 |
OleError(CLASS_E_NOTLICENSED);
|
1096 |
{$ENDIF}
|
1097 |
Result := StStrW.WordPositionW(Cardinal(N), S, WordDelims, Cardinal(Position));
|
1098 |
end;
|
1099 |
|
1100 |
procedure TStString.WordWrap(const InSt: WideString; var OutSt,
|
1101 |
Overlap: WideString; Margin: Integer; PadToMArgin: WordBool);
|
1102 |
begin
|
1103 |
{$IFDEF LICENSE}
|
1104 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
1105 |
OleError(CLASS_E_NOTLICENSED);
|
1106 |
{$ENDIF}
|
1107 |
StStrW.WordWrapW(InSt, OutSt, Overlap, Cardinal(Margin), PadToMargin);
|
1108 |
end;
|
1109 |
|
1110 |
function TStString.License(const Key: WideString): WordBool;
|
1111 |
begin
|
1112 |
{$IFDEF LICENSE}
|
1113 |
Result := COMIsValidKey(Key);
|
1114 |
|
1115 |
{ License the objects used in this class }
|
1116 |
FTokens.License(Key);
|
1117 |
|
1118 |
{$ELSE}
|
1119 |
Result := True;
|
1120 |
{$ENDIF}
|
1121 |
FIsLicensed := Result;
|
1122 |
end;
|
1123 |
|
1124 |
function TStString.Soundex(const S: WideString): WideString;
|
1125 |
begin
|
1126 |
{$IFDEF LICENSE}
|
1127 |
if (not FIsLicensed) or (not COMHasBeenLicensed) then
|
1128 |
OleError(CLASS_E_NOTLICENSED);
|
1129 |
{$ENDIF}
|
1130 |
Result := StStrL.SoundexL(S);
|
1131 |
end;
|
1132 |
|
1133 |
initialization
|
1134 |
TAutoObjectFactory.Create(ComServer, TStString, Class_StString, ciMultiInstance, tmBoth);
|
1135 |
end.
|