syshelp.inc 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987
  1. {%mainunit syshelpers.pp}
  2. { ---------------------------------------------------------------------
  3. TGUIDHelper
  4. ---------------------------------------------------------------------}
  5. Procedure NotImplemented(S : String);
  6. begin
  7. Raise Exception.Create('Not yet implemented : '+S);
  8. end;
  9. Class function TGUIDHelper.Create(const Data; BigEndian: Boolean): TGUID; overload; static;
  10. Const
  11. GUIDSize = SizeOf(TGUID);
  12. Var
  13. B : Array[1..GUIDSize] of Byte;
  14. begin
  15. Move(Data,B,GUIDSize);
  16. Result:=Create(B,0,BigEndian);
  17. end;
  18. class function TGUIDHelper.Create(const Data: array of Byte; AStartIndex: Cardinal; BigEndian: Boolean): TGUID; overload; static;
  19. Var
  20. A : Cardinal;
  21. B,C : Word;
  22. begin
  23. if ((System.Length(Data)-AStartIndex)<16) then
  24. raise EArgumentException.CreateFmt('The length of a GUID array must be at least %d',[]);
  25. Move(Data[AStartIndex],A,SizeOf(Cardinal));
  26. Move(Data[AStartIndex+4],B,SizeOf(Word));
  27. Move(Data[AStartIndex+6],C,SizeOf(Word));
  28. // Writeln('BigEndian : ',BigEndian,', CPU bigendian : ',(CPUendian=TEndian.Big));
  29. if BigEndian<>(CPUendian=TEndian.Big) then
  30. begin
  31. // Writeln('Swapping');
  32. A:=SwapEndian(A);
  33. B:=SwapEndian(B);
  34. C:=SwapEndian(C);
  35. end;
  36. Result:=Create(A,B,C,Data[AStartIndex+8],Data[AStartIndex+9],Data[AStartIndex+10],Data[AStartIndex+11],Data[AStartIndex+12],Data[AStartIndex+13],Data[AStartIndex+14],Data[AStartIndex+15]);
  37. end;
  38. Class Function TGUIDHelper.Create(const Data; DataEndian: TEndian = CPUEndian): TGUID; overload; static; inline;
  39. begin
  40. Result:=Create(Data,DataEndian=TEndian.Big)
  41. end;
  42. Class Function TGUIDHelper.Create(const B: TBytes; DataEndian: TEndian = CPUEndian): TGUID; overload; static; inline;
  43. begin
  44. Result:=Create(B,0,DataEndian);
  45. end;
  46. Class Function TGUIDHelper.Create(const B: TBytes; AStartIndex: Cardinal; DataEndian: TEndian = CPUEndian): TGUID; overload; static;
  47. begin
  48. if ((System.Length(B)-AStartIndex)<16) then
  49. raise EArgumentException.CreateFmt('The length of a GUID array must be at least %d',[]);
  50. Result:=Create(B,AStartIndex,DataEndian=TEndian.Big);
  51. end;
  52. Class Function TGUIDHelper.Create(const S: string): TGUID; overload; static;
  53. begin
  54. Result:=StringToGUID(S);
  55. end;
  56. Class Function TGUIDHelper.Create(A: Integer; B: SmallInt; C: SmallInt; const D: TBytes): TGUID; overload; static;
  57. begin
  58. if (System.Length(D)<>8) then
  59. raise EArgumentException.CreateFmt('The length of a GUID array must be %d',[]);
  60. Result:=Create(Cardinal(A),Word(B),Word(C),D[0],D[1],D[2],D[3],D[4],D[5],D[6],D[7]);
  61. end;
  62. Class Function TGUIDHelper.Create(A: Integer; B: SmallInt; C: SmallInt; D, E, F, G, H, I, J, K: Byte): TGUID; overload; static;
  63. begin
  64. Result:=Create(Cardinal(A),Word(B),Word(C),D,E,F,G,H,I,J,K);
  65. end;
  66. Class Function TGUIDHelper.Create(A: Cardinal; B: Word; C: Word; D, E, F, G, H, I, J, K: Byte): TGUID; overload; static;
  67. begin
  68. Result.D1 := Cardinal(A);
  69. Result.D2 := Word(B);
  70. Result.D3 := Word(C);
  71. Result.D4[0] := D;
  72. Result.D4[1] := E;
  73. Result.D4[2] := F;
  74. Result.D4[3] := G;
  75. Result.D4[4] := H;
  76. Result.D4[5] := I;
  77. Result.D4[6] := J;
  78. Result.D4[7] := K;
  79. end;
  80. Class Function TGUIDHelper.NewGuid: TGUID; static;
  81. begin
  82. CreateGUID(Result)
  83. end;
  84. Function TGUIDHelper.ToByteArray(DataEndian: TEndian = CPUEndian): TBytes;
  85. begin
  86. SetLength(Result, 16);
  87. if DataEndian<>CPUEndian then
  88. begin
  89. PCardinal(@Result[0])^ := SwapEndian(D1);
  90. PWord(@Result[4])^ := SwapEndian(D2);
  91. PWord(@Result[6])^ := SwapEndian(D3);
  92. Move(D4, Result[8], 8);
  93. end
  94. else
  95. Move(D1, Result[0], SizeOf(Self));
  96. end;
  97. Function TGUIDHelper.ToString(SkipBrackets : Boolean = False): string;
  98. begin
  99. Result:=GuidToString(Self);
  100. If SkipBrackets then
  101. Result:=Copy(Result,2,Length(Result)-2);
  102. end;
  103. { ---------------------------------------------------------------------
  104. TStringHelper
  105. ---------------------------------------------------------------------}
  106. Function HaveChar(AChar : Char; const AList: array of Char) : Boolean;
  107. Var
  108. I : SizeInt;
  109. begin
  110. I:=0;
  111. Result:=False;
  112. While (Not Result) and (I<Length(AList)) do
  113. begin
  114. Result:=(AList[i]=AChar);
  115. Inc(I);
  116. end;
  117. end;
  118. function TStringHelper.GetChar(AIndex: SizeInt): Char;
  119. begin
  120. Result:=Self[AIndex+1];
  121. end;
  122. function TStringHelper.GetLength: SizeInt;
  123. begin
  124. Result:=System.Length(Self);
  125. end;
  126. class function TStringHelper.Compare(const A: string; const B: string): Integer;
  127. begin
  128. Result:=Compare(A,0,B,0,System.Length(B),[]);
  129. end;
  130. class function TStringHelper.Compare(const A: string; const B: string;
  131. IgnoreCase: Boolean): Integer; //deprecated 'Use same with TCompareOptions';
  132. begin
  133. if IgnoreCase then
  134. Result:=Compare(A,B,[coIgnoreCase])
  135. else
  136. Result:=Compare(A,B,[]);
  137. end;
  138. class function TStringHelper.Compare(const A: string; const B: string;
  139. Options: TCompareOptions): Integer;
  140. begin
  141. Result:=Compare(A,0,B,0,System.Length(B),Options);
  142. end;
  143. class function TStringHelper.Compare(const A: string; IndexA: SizeInt;
  144. const B: string; IndexB: SizeInt; ALen: SizeInt): Integer;
  145. begin
  146. Result:=Compare(A,IndexA,B,IndexB,ALen,[]);
  147. end;
  148. class function TStringHelper.Compare(const A: string; IndexA: SizeInt;
  149. const B: string; IndexB: SizeInt; ALen: SizeInt; IgnoreCase: Boolean
  150. ): Integer; //deprecated 'Use same with TCompareOptions';
  151. begin
  152. if IgnoreCase then
  153. Result:=Compare(A,IndexA,B,IndexB,ALen,[coIgnoreCase])
  154. else
  155. Result:=Compare(A,IndexA,B,IndexB,ALen,[])
  156. end;
  157. class function TStringHelper.Compare(const A: string; IndexA: SizeInt;
  158. const B: string; IndexB: SizeInt; ALen: SizeInt; Options: TCompareOptions
  159. ): Integer;
  160. Var
  161. L : SizeInt;
  162. begin
  163. L:=ALen;
  164. If (L>system.Length(A)-IndexA) then
  165. L:=system.Length(A)-IndexA;
  166. If (L>system.Length(B)-IndexB) then
  167. L:=system.Length(B)-IndexB;
  168. if (coIgnoreCase in Options) then
  169. begin
  170. Result:=strlicomp(PAnsiChar(@A[IndexA+1]),PAnsiChar(@B[IndexB+1]),L)
  171. end
  172. else
  173. Result:=strlcomp(PAnsiChar(@A[IndexA+1]),PAnsiChar(@B[IndexB+1]),L);
  174. end;
  175. class function TStringHelper.CompareOrdinal(const A: string; const B: string
  176. ): Integer;
  177. Var
  178. L : SizeInt;
  179. begin
  180. L:=System.Length(B);
  181. if L>System.Length(A) then
  182. L:=System.Length(A);
  183. Result:=CompareOrdinal(A,0,B,0,L);
  184. end;
  185. class function TStringHelper.CompareOrdinal(const A: string; IndexA: SizeInt;
  186. const B: string; IndexB: SizeInt; ALen: SizeInt): Integer;
  187. begin
  188. Result:=StrLComp(PAnsiChar(@A[IndexA+1]), PAnsiChar(@B[IndexB+1]), ALen);
  189. end;
  190. class function TStringHelper.CompareText(const A: string; const B: string
  191. ): Integer;
  192. begin
  193. Result:=Sysutils.CompareText(A,B);
  194. end;
  195. class function TStringHelper.Copy(const Str: string): string;
  196. begin
  197. Result:=Str;
  198. UniqueString(Result);
  199. end;
  200. class function TStringHelper.Create(AChar: Char; ACount: SizeInt): string;
  201. begin
  202. Result:=StringOfChar(AChar,ACount);
  203. end;
  204. class function TStringHelper.Create(const AValue: array of Char): string;
  205. begin
  206. Result:=Create(AValue,0,System.Length(AValue));
  207. end;
  208. class function TStringHelper.Create(const AValue: array of Char;
  209. StartIndex: SizeInt; ALen: SizeInt): string;
  210. begin
  211. SetLength(Result,ALen);
  212. if ALen>0 then
  213. Move(AValue[StartIndex],Result[1],ALen);
  214. end;
  215. class function TStringHelper.EndsText(const ASubText, AText: string): Boolean;
  216. begin
  217. Result:=(ASubText<>'') and (sysutils.CompareText(System.Copy(AText,System.Length(AText)-System.Length(ASubText)+1,System.Length(ASubText)),ASubText)=0);
  218. end;
  219. class function TStringHelper.Equals(const a: string; const b: string): Boolean;
  220. begin
  221. Result:=A=B;
  222. end;
  223. class function TStringHelper.Format(const AFormat: string;
  224. const args: array of const): string;
  225. begin
  226. Result:=Sysutils.Format(AFormat,Args);
  227. end;
  228. class function TStringHelper.IsNullOrEmpty(const AValue: string): Boolean;
  229. begin
  230. Result:=system.Length(AValue)=0;
  231. end;
  232. class function TStringHelper.IsNullOrWhiteSpace(const AValue: string): Boolean;
  233. const
  234. LWhiteSpace = [#0..' '];
  235. var
  236. I: SizeInt;
  237. begin
  238. for I:=1 to System.Length(AValue) do
  239. if not (AValue[I] in LWhiteSpace) then
  240. exit(False);
  241. Result:=True;
  242. end;
  243. class function TStringHelper.Join(const Separator: string;
  244. const Values: array of const): string;
  245. Var
  246. SValues : Array of string;
  247. I,L : SizeInt;
  248. S : String;
  249. P : ^TVarRec;
  250. begin
  251. L:=System.Length(Values);
  252. SetLength(SValues,L);
  253. Dec(L);
  254. for I:=0 to L do
  255. begin
  256. S:='';
  257. P:=@Values[I];
  258. Case P^.VType of
  259. vtInteger : S:=IntToStr(P^.VInteger);
  260. vtBoolean : S:=BoolToStr(P^.VBoolean, True);
  261. vtChar : S:=P^.VChar;
  262. vtPChar : S:= string(P^.VPChar);
  263. {$ifndef FPUNONE}
  264. vtExtended : S:=FloatToStr(P^.VExtended^);
  265. {$endif}
  266. vtObject : S:=TObject(P^.VObject).Classname;
  267. vtClass : S:=P^.VClass.Classname;
  268. vtCurrency : S:=CurrToStr(P^.VCurrency^);
  269. vtVariant : S:=(P^.VVariant^);
  270. vtInt64 : S:=IntToStr(PInt64(P^.VInt64)^);
  271. vtQword : S:=IntToStr(PQWord(P^.VQword)^);
  272. vtWideChar : S:=WideString(P^.VWideChar);
  273. vtPWideChar : S:=WideString(P^.VPWideChar);
  274. vtUnicodeString : S:=UnicodeString(P^.VUnicodeString);
  275. vtAnsiString : S:=Ansistring(P^.VAnsiString);
  276. else
  277. S:=Format('Unknown type: %d',[P^.VType]);
  278. end;
  279. SValues[I]:=S;
  280. end;
  281. Result:=Join(Separator,SValues);
  282. end;
  283. class function TStringHelper.Join(const Separator: string;
  284. const Values: array of string): string;
  285. begin
  286. Result:=Join(Separator,Values,0,System.Length(Values));
  287. end;
  288. class function TStringHelper.Join(const Separator: string;
  289. const Values: array of string; StartIndex: SizeInt; ACount: SizeInt): string;
  290. Var
  291. VLen,I,CountLim,NR,NSep,N : SizeInt;
  292. Rp: PChar;
  293. begin
  294. VLen:=System.Length(Values);
  295. If (ACount=0) then
  296. Exit('');
  297. CountLim:=VLen-StartIndex;
  298. if ACount>CountLim then
  299. ACount:=CountLim;
  300. If (ACount<0) or (StartIndex>VLen) or (StartIndex<0) then
  301. raise ERangeError.Create(SRangeError);
  302. if ACount=1 then
  303. exit(Values[StartIndex]);
  304. NSep:=System.Length(Separator);
  305. NR:=(ACount-1)*NSep;
  306. for I:=StartIndex to StartIndex+ACount-1 do
  307. NR:=NR+System.Length(Values[I]);
  308. SetLength(Result,NR);
  309. Rp:=@Result[1];
  310. for I:=StartIndex to StartIndex+ACount-1 do
  311. begin
  312. if I>StartIndex then
  313. begin
  314. Move(separator[1],Rp^,NSep*sizeof(Char));
  315. Rp:=Rp+NSep;
  316. end;
  317. N:=System.Length(Values[I]);
  318. Move(Values[I][1],Rp^,N*sizeof(Char));
  319. Rp:=Rp+N;
  320. end;
  321. end;
  322. class function TStringHelper.LowerCase(const S: string): string;
  323. begin
  324. Result:=sysutils.Lowercase(S);
  325. end;
  326. class function TStringHelper.Parse(const AValue: Boolean): string;
  327. begin
  328. Result:=BoolToStr(AValue);
  329. end;
  330. class function TStringHelper.Parse(const AValue: Extended): string;
  331. begin
  332. Result:=FloatToStr(AValue);
  333. end;
  334. class function TStringHelper.Parse(const AValue: Int64): string;
  335. begin
  336. Result:=IntToStr(AValue);
  337. end;
  338. class function TStringHelper.Parse(const AValue: Integer): string;
  339. begin
  340. Result:=IntToStr(AValue);
  341. end;
  342. class function TStringHelper.ToBoolean(const S: string): Boolean;
  343. begin
  344. Result:=StrToBool(S);
  345. end;
  346. class function TStringHelper.ToDouble(const S: string): Double;
  347. begin
  348. Result:=StrToFloat(S);
  349. end;
  350. class function TStringHelper.ToExtended(const S: string): Extended;
  351. begin
  352. Result:=StrToFloat(S);
  353. end;
  354. class function TStringHelper.ToInt64(const S: string): Int64;
  355. begin
  356. Result:=StrToInt64(S);
  357. end;
  358. class function TStringHelper.ToInteger(const S: string): Integer;
  359. begin
  360. Result:=StrToInt(S);
  361. end;
  362. class function TStringHelper.ToSingle(const S: string): Single;
  363. begin
  364. Result:=StrToFloat(S);
  365. end;
  366. class function TStringHelper.UpperCase(const S: string): string;
  367. begin
  368. Result:=sysutils.Uppercase(S);
  369. end;
  370. function TStringHelper.CompareTo(const B: string): Integer;
  371. begin
  372. // Order is important
  373. Result:=sysUtils.StrComp(PChar(Self),PChar(B));
  374. end;
  375. procedure TStringHelper.CopyTo(SourceIndex: SizeInt; var destination: array of Char; DestinationIndex: SizeInt; ACount: SizeInt);
  376. Var
  377. P1,P2 : PChar;
  378. begin
  379. // Writeln('((',DestinationIndex,'+',ACount,')<',System.Length(Destination),') : ', ((DestinationIndex+ACount)<System.Length(Destination)));
  380. if ((DestinationIndex+ACount)<=System.Length(Destination)) then
  381. begin
  382. // Writeln('AHA');
  383. P1:=@Self[SourceIndex+1];
  384. P2:=@Destination[DestinationIndex];
  385. Move(P1^,P2^,ACount*SizeOf(Char));
  386. end;
  387. end;
  388. function TStringHelper.Contains(const AValue: string; IgnoreCase: Boolean): Boolean;
  389. begin
  390. if IgnoreCase then
  391. Result:=Pos(LowerCase(AValue),LowerCase(Self))>0
  392. else
  393. Result:=Pos(AValue,Self)>0;
  394. end;
  395. function TStringHelper.CountChar(const C: Char): SizeInt;
  396. Var
  397. S : Char;
  398. begin
  399. Result:=0;
  400. For S in Self do
  401. if (S=C) then
  402. Inc(Result);
  403. end;
  404. function TStringHelper.DeQuotedString: string;
  405. begin
  406. Result:=DeQuotedString('''');
  407. end;
  408. function TStringHelper.DeQuotedString(const AQuoteChar: Char): string;
  409. var
  410. L,I : SizeInt;
  411. Res : Array of Char;
  412. PS,PD : PChar;
  413. IsQuote : Boolean;
  414. begin
  415. L:=System.Length(Self);
  416. if (L<2) or Not ((Self[1]=AQuoteChar) and (Self[L]=AQuoteChar)) then
  417. Exit(Self);
  418. SetLength(Res,L);
  419. IsQuote:=False;
  420. PS:=@Self[2];
  421. PD:=@Res[0];
  422. For I:=2 to L-1 do
  423. begin
  424. if (PS^=AQuoteChar) then
  425. begin
  426. IsQuote:=Not IsQuote;
  427. if Not IsQuote then
  428. begin
  429. PD^:=PS^;
  430. Inc(PD);
  431. end;
  432. end
  433. else
  434. begin
  435. if IsQuote then
  436. IsQuote:=false;
  437. PD^:=PS^;
  438. Inc(PD);
  439. end;
  440. Inc(PS);
  441. end;
  442. SetString(Result,@Res[0],PD-@Res[0]);
  443. end;
  444. function TStringHelper.EndsWith(const AValue: string): Boolean;
  445. begin
  446. Result:=EndsWith(AValue,False);
  447. end;
  448. function TStringHelper.EndsWith(const AValue: string; IgnoreCase: Boolean): Boolean;
  449. Var
  450. L,NS : SizeInt;
  451. begin
  452. L:=system.Length(AVAlue);
  453. NS:=System.Length(Self);
  454. Result:=L<=NS;
  455. if Result then
  456. if IgnoreCase then
  457. Result:=SameText(System.Copy(Self,NS-L+1,L),AValue)
  458. else
  459. Result:=CompareChar(PChar(Pointer(Self))[NS-L],PChar(Pointer(AValue))^,L)=0;
  460. end;
  461. function TStringHelper.Equals(const AValue: string; IgnoreCase: Boolean = False): Boolean;
  462. begin
  463. if IgnoreCase then
  464. Result:=SameText(Self,aValue)
  465. else
  466. Result:=(Self=AValue);
  467. end;
  468. function TStringHelper.Format(const args: array of const): string;
  469. begin
  470. Result:=Format(Self,Args);
  471. end;
  472. function TStringHelper.GetHashCode: Integer;
  473. // Taken from contnrs, fphash
  474. var
  475. P,pmax : PChar;
  476. begin
  477. {$push}
  478. {$Q-}
  479. Result:=0;
  480. P:=Pchar(Self);
  481. pmax:=p+length;
  482. while (p<pmax) do
  483. begin
  484. Result:=LongWord(LongInt(Result shl 5) - LongInt(Result)) xor LongWord(P^);
  485. Inc(p);
  486. end;
  487. {$pop}
  488. end;
  489. function TStringHelper.IndexOf(AValue: Char): SizeInt;
  490. begin
  491. Result:=IndexOf(AValue,0,Length);
  492. end;
  493. function TStringHelper.IndexOf(const AValue: string): SizeInt;
  494. begin
  495. Result:=IndexOf(AValue,0,Length);
  496. end;
  497. function TStringHelper.IndexOf(AValue: Char; StartIndex: SizeInt): SizeInt;
  498. begin
  499. Result:=IndexOf(AValue,StartIndex,Length);
  500. end;
  501. function TStringHelper.IndexOf(const AValue: string; StartIndex: SizeInt
  502. ): SizeInt;
  503. begin
  504. Result:=IndexOf(AValue,StartIndex,Length);
  505. end;
  506. function TStringHelper.IndexOf(AValue: Char; StartIndex: SizeInt;
  507. ACount: SizeInt): SizeInt;
  508. Var
  509. CountLim : SizeInt;
  510. begin
  511. if StartIndex<0 then
  512. StartIndex:=0;
  513. CountLim:=System.Length(Self)-StartIndex;
  514. if ACount>CountLim then
  515. ACount:=CountLim;
  516. if ACount<=0 then
  517. Exit(-1);
  518. // pointer casts are to access self as 0 based index!
  519. Result:=IndexChar(PChar(Pointer(self))[StartIndex],ACount,AValue);
  520. if Result>=0 then
  521. Result:=Result+StartIndex;
  522. end;
  523. function TStringHelper.IndexOf(const AValue: string; StartIndex: SizeInt;
  524. ACount: SizeInt): SizeInt;
  525. Var
  526. CountLim,NV,Ofs : SizeInt;
  527. SP,SE : PChar;
  528. begin
  529. if StartIndex<0 then
  530. StartIndex:=0;
  531. CountLim:=System.Length(Self)-StartIndex;
  532. if ACount>CountLim then
  533. ACount:=CountLim;
  534. NV:=System.Length(AValue);
  535. if (NV>0) and (ACount>=NV) then
  536. begin
  537. SP:=PChar(Pointer(Self))+StartIndex;
  538. SE:=SP+ACount-NV+1;
  539. repeat
  540. Ofs:=IndexChar(SP^,SE-SP,PChar(Pointer(AValue))[0]);
  541. if Ofs<0 then
  542. Break;
  543. SP:=SP+Ofs+1;
  544. if CompareChar(SP^,PChar(Pointer(AValue))[1],NV-1)=0 then
  545. Exit(SP-PChar(Pointer(Self))-1);
  546. until false;
  547. end;
  548. Result:=-1;
  549. end;
  550. function TStringHelper.IndexOfUnQuoted(const AValue: string; StartQuote,
  551. EndQuote: Char; StartIndex: SizeInt = 0): SizeInt;
  552. Var
  553. LV : SizeInt;
  554. Function MatchAt(I : SizeInt) : Boolean ; Inline;
  555. Var
  556. J : SizeInt;
  557. begin
  558. J:=1;
  559. Repeat
  560. Result:=(Self[I+J-1]=AValue[j]);
  561. Inc(J);
  562. Until (Not Result) or (J>LV);
  563. end;
  564. Var
  565. I,L,Q: SizeInt;
  566. begin
  567. Result:=-1;
  568. LV:=system.Length(AValue);
  569. L:=Length-LV+1;
  570. if L<0 then
  571. L:=0;
  572. I:=StartIndex+1;
  573. Q:=0;
  574. if StartQuote=EndQuote then
  575. begin
  576. While (Result=-1) and (I<=L) do
  577. begin
  578. if (Self[I]=StartQuote) then
  579. Q:=1-Q;
  580. if (Q=0) and MatchAt(i) then
  581. Result:=I-1;
  582. Inc(I);
  583. end;
  584. end
  585. else
  586. begin
  587. While (Result=-1) and (I<=L) do
  588. begin
  589. if Self[I]=StartQuote then
  590. Inc(Q)
  591. else if (Self[I]=EndQuote) and (Q>0) then
  592. Dec(Q);
  593. if (Q=0) and MatchAt(i) then
  594. Result:=I-1;
  595. Inc(I);
  596. end;
  597. end;
  598. end;
  599. function TStringHelper.IndexOfAny(const AnyOf: array of Char): SizeInt;
  600. begin
  601. Result:=IndexOfAny(AnyOf,0,Length);
  602. end;
  603. function TStringHelper.IndexOfAny(const AnyOf: array of Char;
  604. StartIndex: SizeInt): SizeInt;
  605. begin
  606. Result:=IndexOfAny(AnyOf,StartIndex,Length);
  607. end;
  608. function TStringHelper.IndexOfAny(const AnyOf: array of Char;
  609. StartIndex: SizeInt; ACount: SizeInt): SizeInt;
  610. Var
  611. i,L : SizeInt;
  612. begin
  613. I:=StartIndex+1;
  614. L:=I+ACount-1;
  615. If L>Length then
  616. L:=Length;
  617. Result:=-1;
  618. While (Result=-1) and (I<=L) do
  619. begin
  620. if HaveChar(Self[i],AnyOf) then
  621. Result:=I-1;
  622. Inc(I);
  623. end;
  624. end;
  625. function TStringHelper.IndexOfAny(const AnyOf: array of String): SizeInt;
  626. begin
  627. Result:=IndexOfAny(AnyOf,0,Length);
  628. end;
  629. function TStringHelper.IndexOfAny(const AnyOf: array of String;
  630. StartIndex: SizeInt): SizeInt;
  631. begin
  632. Result:=IndexOfAny(AnyOf,StartIndex,Length-StartIndex);
  633. end;
  634. function TStringHelper.IndexOfAny(const AnyOf: array of String;
  635. StartIndex: SizeInt; ACount: SizeInt): SizeInt;
  636. Var
  637. M : SizeInt;
  638. begin
  639. Result:=IndexOfAny(AnyOf,StartIndex,ACount,M);
  640. end;
  641. function TStringHelper.IndexOfAny(const AnyOf: array of String;
  642. StartIndex: SizeInt; ACount: SizeInt; out AMatch: SizeInt): SizeInt;
  643. Var
  644. L,I : SizeInt;
  645. begin
  646. Result:=-1;
  647. For I:=0 to System.Length(AnyOf)-1 do
  648. begin
  649. L:=IndexOf(AnyOf[i],StartIndex,ACount);
  650. If (L>=0) and ((Result=-1) or (L<Result)) then
  651. begin
  652. Result:=L;
  653. AMatch:=I;
  654. end;
  655. end;
  656. end;
  657. function TStringHelper.IndexOfAnyUnquoted(const AnyOf: array of Char;
  658. StartQuote, EndQuote: Char): SizeInt;
  659. begin
  660. Result:=IndexOfAnyUnquoted(AnyOf,StartQuote,EndQuote,0,Length);
  661. end;
  662. function TStringHelper.IndexOfAnyUnquoted(const AnyOf: array of Char;
  663. StartQuote, EndQuote: Char; StartIndex: SizeInt): SizeInt;
  664. begin
  665. Result:=IndexOfAnyUnquoted(AnyOf,StartQuote,EndQuote,StartIndex,Length);
  666. end;
  667. function TStringHelper.IndexOfAnyUnquoted(const AnyOf: array of Char;
  668. StartQuote, EndQuote: Char; StartIndex: SizeInt; ACount: SizeInt): SizeInt;
  669. Var
  670. I,L : SizeInt;
  671. Q : SizeInt;
  672. begin
  673. Result:=-1;
  674. L:=StartIndex+ACount-1;
  675. if L>Length then
  676. L:=Length;
  677. I:=StartIndex+1;
  678. Q:=0;
  679. if StartQuote=EndQuote then
  680. begin
  681. While (Result=-1) and (I<=L) do
  682. begin
  683. if (Self[I]=StartQuote) then
  684. Q:=1-Q;
  685. if (Q=0) and HaveChar(Self[i],AnyOf) then
  686. Result:=I-1;
  687. Inc(I);
  688. end;
  689. end
  690. else
  691. begin
  692. While (Result=-1) and (I<=L) do
  693. begin
  694. if Self[I]=StartQuote then
  695. Inc(Q)
  696. else if (Self[I]=EndQuote) and (Q>0) then
  697. Dec(Q);
  698. if (Q=0) and HaveChar(Self[i],AnyOf) then
  699. Result:=I-1;
  700. Inc(I);
  701. end;
  702. end;
  703. end;
  704. function TStringHelper.IndexOfAnyUnquoted(const AnyOf: array of string;
  705. StartQuote, EndQuote: Char; StartIndex: SizeInt; out Matched: SizeInt
  706. ): SizeInt;
  707. Var
  708. L,I : SizeInt;
  709. begin
  710. Result:=-1;
  711. For I:=0 to System.Length(AnyOf)-1 do
  712. begin
  713. L:=IndexOfUnquoted(AnyOf[i],StartQuote,EndQuote,StartIndex);
  714. If (L>=0) and ((Result=-1) or (L<Result)) then
  715. begin
  716. Result:=L;
  717. Matched:=I;
  718. end;
  719. end;
  720. end;
  721. function TStringHelper.Insert(StartIndex: SizeInt; const AValue: string
  722. ): string;
  723. begin
  724. system.Insert(AValue,Self,StartIndex+1);
  725. Result:=Self;
  726. end;
  727. function TStringHelper.IsDelimiter(const Delimiters: string; Index: SizeInt
  728. ): Boolean;
  729. begin
  730. Result:=sysutils.IsDelimiter(Delimiters,Self,Index+1);
  731. end;
  732. function TStringHelper.IsEmpty: Boolean;
  733. begin
  734. Result:=(Length=0)
  735. end;
  736. function TStringHelper.LastDelimiter(const Delims: string): SizeInt;
  737. begin
  738. Result:=sysutils.LastDelimiter(Delims,Self)-1;
  739. end;
  740. function TStringHelper.LastIndexOf(AValue: Char): SizeInt;
  741. begin
  742. Result:=LastIndexOf(AValue,Length-1,Length);
  743. end;
  744. function TStringHelper.LastIndexOf(const AValue: string): SizeInt;
  745. begin
  746. Result:=LastIndexOf(AValue,Length-1,Length);
  747. end;
  748. function TStringHelper.LastIndexOf(AValue: Char; AStartIndex: SizeInt): SizeInt;
  749. begin
  750. Result:=LastIndexOf(AValue,AStartIndex,Length);
  751. end;
  752. function TStringHelper.LastIndexOf(const AValue: string; AStartIndex: SizeInt
  753. ): SizeInt;
  754. begin
  755. Result:=LastIndexOf(AValue,AStartIndex,Length);
  756. end;
  757. function TStringHelper.LastIndexOf(AValue: Char; AStartIndex: SizeInt;
  758. ACount: SizeInt): SizeInt;
  759. Var
  760. Min : SizeInt;
  761. begin
  762. Result:=AStartIndex+1;
  763. Min:=Result-ACount+1;
  764. If Min<1 then
  765. Min:=1;
  766. While (Result>=Min) and (Self[Result]<>AValue) do
  767. Dec(Result);
  768. if Result<Min then
  769. Result:=-1
  770. else
  771. Result:=Result-1;
  772. end;
  773. function TStringHelper.LastIndexOf(const AValue: string; AStartIndex: SizeInt; ACount: SizeInt): SizeInt;
  774. var
  775. I,L,LS,M : SizeInt;
  776. S : String;
  777. P : PChar;
  778. begin
  779. Result:=-1;
  780. LS:=system.Length(Self);
  781. L:=system.Length(AValue);
  782. if (L=0) or (L>LS) then
  783. Exit;
  784. P:=PChar(AValue);
  785. S:=Self;
  786. I:=AStartIndex+1; // 1 based
  787. if (I>LS) then
  788. I:=LS;
  789. I:=I-L+1;
  790. M:=AStartIndex-ACount+2; // 1 based
  791. if M<1 then
  792. M:=1;
  793. while (Result=-1) and (I>=M) do
  794. begin
  795. if (0=StrLComp(PChar(@S[I]),P,L)) then
  796. Result:=I-1;
  797. Dec(I);
  798. end;
  799. end;
  800. function TStringHelper.LastIndexOfAny(const AnyOf: array of Char): SizeInt;
  801. begin
  802. Result:=LastIndexOfAny(AnyOf,Length-1,Length);
  803. end;
  804. function TStringHelper.LastIndexOfAny(const AnyOf: array of Char;
  805. AStartIndex: SizeInt): SizeInt;
  806. begin
  807. Result:=LastIndexOfAny(AnyOf,AStartIndex,Length);
  808. end;
  809. function TStringHelper.LastIndexOfAny(const AnyOf: array of Char;
  810. AStartIndex: SizeInt; ACount: SizeInt): SizeInt;
  811. Var
  812. Min : SizeInt;
  813. begin
  814. Result:=AStartIndex+1;
  815. Min:=Result-ACount+1;
  816. If Min<1 then
  817. Min:=1;
  818. While (Result>=Min) and Not HaveChar(Self[Result],AnyOf) do
  819. Dec(Result);
  820. if Result<Min then
  821. Result:=-1
  822. else
  823. Result:=Result-1;
  824. end;
  825. function TStringHelper.PadLeft(ATotalWidth: SizeInt): string;
  826. begin
  827. Result:=PadLeft(ATotalWidth,' ');
  828. end;
  829. function TStringHelper.PadLeft(ATotalWidth: SizeInt; PaddingChar: Char): string;
  830. Var
  831. L : SizeInt;
  832. begin
  833. Result:=Self;
  834. L:=ATotalWidth-Length;
  835. If L>0 then
  836. Result:=StringOfChar(PaddingChar,L)+Result;
  837. end;
  838. function TStringHelper.PadRight(ATotalWidth: SizeInt): string;
  839. begin
  840. Result:=PadRight(ATotalWidth,' ');
  841. end;
  842. function TStringHelper.PadRight(ATotalWidth: SizeInt; PaddingChar: Char
  843. ): string;
  844. Var
  845. L : SizeInt;
  846. begin
  847. Result:=Self;
  848. L:=ATotalWidth-Length;
  849. If L>0 then
  850. Result:=Result+StringOfChar(PaddingChar,L);
  851. end;
  852. function TStringHelper.QuotedString: string;
  853. begin
  854. Result:=QuotedStr(Self);
  855. end;
  856. function TStringHelper.QuotedString(const AQuoteChar: Char): string;
  857. begin
  858. Result:=AnsiQuotedStr(Self,AQuoteChar);
  859. end;
  860. function TStringHelper.Remove(StartIndex: SizeInt): string;
  861. begin
  862. Result:=Remove(StartIndex,Self.Length-StartIndex);
  863. end;
  864. function TStringHelper.Remove(StartIndex: SizeInt; ACount: SizeInt): string;
  865. begin
  866. Result:=Self;
  867. System.Delete(Result,StartIndex+1,ACount);
  868. end;
  869. function TStringHelper.Replace(OldChar: Char; NewChar: Char): string;
  870. begin
  871. Result:=Replace(OldChar,NewChar,[rfReplaceAll]);
  872. end;
  873. function TStringHelper.Replace(OldChar: Char; NewChar: Char;
  874. ReplaceFlags: TReplaceFlags): string;
  875. var
  876. Sp,Se,Rp : PChar;
  877. Ofs : SizeInt;
  878. begin
  879. if rfIgnoreCase in ReplaceFlags then
  880. exit(StringReplace(Self,OldChar,NewChar,ReplaceFlags));
  881. Sp:=PChar(Pointer(Self));
  882. Se:=Sp+System.Length(Self);
  883. Ofs:=IndexChar(Sp^,Se-Sp,OldChar);
  884. if Ofs<0 then
  885. exit(Self);
  886. SetLength(Result,Se-Sp);
  887. Rp:=PChar(Pointer(Result));
  888. repeat
  889. Move(Sp^,Rp^,Ofs*sizeof(Char));
  890. Sp:=Sp+Ofs+1;
  891. Rp[Ofs]:=NewChar;
  892. Rp:=Rp+Ofs+1;
  893. if not (rfReplaceAll in ReplaceFlags) then
  894. break;
  895. { This loop can be removed entirely, but greatly speeds up replacing streaks of characters. }
  896. while (Sp<Se) and (Sp^=OldChar) do
  897. begin
  898. Rp^:=NewChar;
  899. Sp:=Sp+1;
  900. Rp:=Rp+1;
  901. end;
  902. Ofs:=IndexChar(Sp^,Se-Sp,OldChar);
  903. until Ofs<0;
  904. Move(Sp^,Rp^,(Se-Sp)*sizeof(Char));
  905. end;
  906. function TStringHelper.Replace(const OldValue: string; const NewValue: string
  907. ): string;
  908. begin
  909. Result:=Replace(OldValue,NewValue,[rfReplaceAll]);
  910. end;
  911. function TStringHelper.Replace(const OldValue: string; const NewValue: string;
  912. ReplaceFlags: TReplaceFlags): string;
  913. begin
  914. Result:=StringReplace(Self,OldValue,NewValue,ReplaceFlags);
  915. end;
  916. function TStringHelper.Split(const Separators: array of Char): TStringArray;
  917. begin
  918. Result:=Split(Separators,#0,#0,Length+1,TStringSplitOptions.None);
  919. end;
  920. function TStringHelper.Split(const Separators: array of Char; ACount: SizeInt
  921. ): TStringArray;
  922. begin
  923. Result:=Split(Separators,#0,#0,ACount,TStringSplitOptions.None);
  924. end;
  925. function TStringHelper.Split(const Separators: array of Char;
  926. Options: TStringSplitOptions): TStringArray;
  927. begin
  928. Result:=Split(Separators,Length+1,Options);
  929. end;
  930. function TStringHelper.Split(const Separators: array of Char; ACount: SizeInt;
  931. Options: TStringSplitOptions): TStringArray;
  932. begin
  933. Result:=Split(Separators,#0,#0,ACount,Options);
  934. end;
  935. function TStringHelper.Split(const Separators: array of string): TStringArray;
  936. begin
  937. Result:=Split(Separators,Length+1);
  938. end;
  939. function TStringHelper.Split(const Separators: array of string; ACount: SizeInt
  940. ): TStringArray;
  941. begin
  942. Result:=Split(Separators,ACount,TStringSplitOptions.None);
  943. end;
  944. function TStringHelper.Split(const Separators: array of string;
  945. Options: TStringSplitOptions): TStringArray;
  946. begin
  947. Result:=Split(Separators,Length+1,Options);
  948. end;
  949. function TStringHelper.Split(const Separators: array of string;
  950. ACount: SizeInt; Options: TStringSplitOptions): TStringArray;
  951. begin
  952. Result:=Split(Separators,#0,#0,ACount,Options);
  953. end;
  954. function TStringHelper.Split(const Separators: array of Char; AQuote: Char
  955. ): TStringArray;
  956. begin
  957. Result:=Split(Separators,AQuote,AQuote);
  958. end;
  959. function TStringHelper.Split(const Separators: array of Char; AQuoteStart,
  960. AQuoteEnd: Char): TStringArray;
  961. begin
  962. Result:=Split(Separators,AQuoteStart,AQuoteEnd,TStringSplitOptions.None);
  963. end;
  964. function TStringHelper.Split(const Separators: array of Char; AQuoteStart,
  965. AQuoteEnd: Char; Options: TStringSplitOptions): TStringArray;
  966. begin
  967. Result:=Split(Separators,AQuoteStart,AQuoteEnd,Length+1,Options);
  968. end;
  969. function TStringHelper.Split(const Separators: array of Char; AQuoteStart,
  970. AQuoteEnd: Char; ACount: SizeInt): TStringArray;
  971. begin
  972. Result:=Split(Separators,AQuoteStart,AQuoteEnd,ACount,TStringSplitOptions.None);
  973. end;
  974. function TStringHelper.Split(const Separators: array of Char; AQuoteStart,
  975. AQuoteEnd: Char; ACount: SizeInt; Options: TStringSplitOptions): TStringArray;
  976. Function NextSep(StartIndex : SizeInt) : SizeInt;
  977. begin
  978. if (AQuoteStart<>#0) then
  979. Result:=Self.IndexOfAnyUnQuoted(Separators,AQuoteStart,AQuoteEnd,StartIndex)
  980. else
  981. Result:=Self.IndexOfAny(Separators,StartIndex);
  982. end;
  983. Procedure MaybeGrow(Curlen : SizeInt);
  984. begin
  985. if System.Length(Result)<=CurLen then
  986. SetLength(Result,System.Length(Result)+4+SizeInt(SizeUint(System.Length(Result)) div 4));
  987. end;
  988. Var
  989. Sep,LastSep,Len : SizeInt;
  990. begin
  991. Result:=nil;
  992. Len:=0;
  993. LastSep:=0;
  994. While ((ACount=0) or (Len<ACount)) and (LastSep<=System.Length(Self)) do
  995. begin
  996. Sep:=NextSep(LastSep);
  997. if Sep<0 then
  998. Sep:=System.Length(Self);
  999. // Writeln('Examining >',T,'< at pos ',LastSep,', till pos ',Sep);
  1000. If (Sep>LastSep) or (not (TStringSplitOptions.ExcludeEmpty=Options)) then
  1001. begin
  1002. MaybeGrow(Len);
  1003. Result[Len]:=SubString(LastSep,Sep-LastSep);
  1004. Inc(Len);
  1005. end;
  1006. LastSep:=Sep+1;
  1007. end;
  1008. if (TStringSplitOptions.ExcludeLastEmpty=Options) then
  1009. if (Len > 0) and (Result[Len-1] = '') then
  1010. dec(Len);
  1011. SetLength(Result,Len);
  1012. end;
  1013. function TStringHelper.Split(const Separators: array of string; AQuote: Char
  1014. ): TStringArray;
  1015. begin
  1016. Result:=SPlit(Separators,AQuote,AQuote);
  1017. end;
  1018. function TStringHelper.Split(const Separators: array of string; AQuoteStart,
  1019. AQuoteEnd: Char): TStringArray;
  1020. begin
  1021. Result:=SPlit(Separators,AQuoteStart,AQuoteEnd,Length+1,TStringSplitOptions.None);
  1022. end;
  1023. function TStringHelper.Split(const Separators: array of string; AQuoteStart,
  1024. AQuoteEnd: Char; Options: TStringSplitOptions): TStringArray;
  1025. begin
  1026. Result:=SPlit(Separators,AQuoteStart,AQuoteEnd,Length+1,Options);
  1027. end;
  1028. function TStringHelper.Split(const Separators: array of string; AQuoteStart,
  1029. AQuoteEnd: Char; ACount: SizeInt): TStringArray;
  1030. begin
  1031. Result:=SPlit(Separators,AQuoteStart,AQuoteEnd,ACount,TStringSplitOptions.None);
  1032. end;
  1033. function TStringHelper.Split(const Separators: array of string; AQuoteStart,
  1034. AQuoteEnd: Char; ACount: SizeInt; Options: TStringSplitOptions): TStringArray;
  1035. Const
  1036. BlockSize = 10;
  1037. Function NextSep(StartIndex : SizeInt; out Match : SizeInt) : SizeInt;
  1038. begin
  1039. if (AQuoteStart<>#0) then
  1040. Result:=Self.IndexOfAnyUnQuoted(Separators,AQuoteStart,AQuoteEnd,StartIndex,Match)
  1041. else
  1042. Result:=Self.IndexOfAny(Separators,StartIndex,Length,Match);
  1043. if Result<>-1 then
  1044. end;
  1045. Procedure MaybeGrow(Curlen : SizeInt);
  1046. begin
  1047. if System.Length(Result)<=CurLen then
  1048. SetLength(Result,System.Length(Result)+BlockSize);
  1049. end;
  1050. Var
  1051. Sep,LastSep,Len,Match : SizeInt;
  1052. T : String;
  1053. begin
  1054. SetLength(Result,BlockSize);
  1055. Len:=0;
  1056. LastSep:=0;
  1057. Sep:=NextSep(0,Match);
  1058. While (Sep<>-1) and ((ACount=0) or (Len<ACount)) do
  1059. begin
  1060. T:=SubString(LastSep,Sep-LastSep);
  1061. If (T<>'') or (not (TStringSplitOptions.ExcludeEmpty=Options)) then
  1062. begin
  1063. MaybeGrow(Len);
  1064. Result[Len]:=T;
  1065. Inc(Len);
  1066. end;
  1067. LastSep:=Sep+System.Length(Separators[Match]);
  1068. Sep:=NextSep(LastSep,Match);
  1069. end;
  1070. if (LastSep<=Length) and ((ACount=0) or (Len<ACount)) then
  1071. begin
  1072. T:=SubString(LastSep);
  1073. // Writeln('Examining >',T,'< at pos,',LastSep,' till pos ',Sep);
  1074. If (T<>'') or (not (TStringSplitOptions.ExcludeEmpty=Options)) then
  1075. begin
  1076. MaybeGrow(Len);
  1077. Result[Len]:=T;
  1078. Inc(Len);
  1079. end;
  1080. end;
  1081. If (TStringSplitOptions.ExcludeLastEmpty=Options) then
  1082. if (Len > 0) and (Result[Len-1] = '') then
  1083. dec(Len);
  1084. SetLength(Result,Len);
  1085. end;
  1086. function TStringHelper.StartsWith(const AValue: string): Boolean;
  1087. begin
  1088. Result:=StartsWith(AValue,False);
  1089. end;
  1090. function TStringHelper.StartsWith(const AValue: string; IgnoreCase: Boolean
  1091. ): Boolean;
  1092. Var
  1093. L : SizeInt;
  1094. begin
  1095. L:=System.Length(AValue);
  1096. Result:=L<=System.Length(Self);
  1097. if Result then
  1098. if IgnoreCase then
  1099. Result:=SameText(System.Copy(Self,1,L),AValue)
  1100. else
  1101. Result:=CompareChar(PChar(Pointer(Self))^,PChar(Pointer(AValue))^,L)=0;
  1102. end;
  1103. function TStringHelper.Substring(AStartIndex: SizeInt): string;
  1104. begin
  1105. Result:=Self.SubString(AStartIndex,Self.Length-AStartIndex);
  1106. end;
  1107. function TStringHelper.Substring(AStartIndex: SizeInt; ALen: SizeInt): string;
  1108. begin
  1109. Result:=system.Copy(Self,AStartIndex+1,ALen);
  1110. end;
  1111. function TStringHelper.ToBoolean: Boolean;
  1112. begin
  1113. Result:=StrToBool(Self);
  1114. end;
  1115. function TStringHelper.ToInteger: Integer;
  1116. begin
  1117. Result:=StrToInt(Self);
  1118. end;
  1119. function TStringHelper.ToInt64: Int64;
  1120. begin
  1121. Result:=StrToInt64(Self);
  1122. end;
  1123. function TStringHelper.ToSingle: Single;
  1124. begin
  1125. Result:=StrToFLoat(Self);
  1126. end;
  1127. function TStringHelper.ToDouble: Double;
  1128. begin
  1129. Result:=StrToFLoat(Self);
  1130. end;
  1131. function TStringHelper.ToExtended: Extended;
  1132. begin
  1133. Result:=StrToFLoat(Self);
  1134. end;
  1135. function TStringHelper.ToCharArray: TCharArray;
  1136. begin
  1137. Result:=ToCharArray(0,Self.Length);
  1138. end;
  1139. function TStringHelper.ToCharArray(AStartIndex: SizeInt; ALen: SizeInt
  1140. ): TCharArray;
  1141. Var
  1142. I : SizeInt;
  1143. begin
  1144. SetLength(Result,ALen);
  1145. For I:=0 to ALen-1 do
  1146. Result[I]:=Self[AStartIndex+I+1];
  1147. end;
  1148. function TStringHelper.ToLower: string;
  1149. begin
  1150. Result:=LowerCase(Self);
  1151. end;
  1152. function TStringHelper.ToLowerInvariant: string;
  1153. begin
  1154. Result:=LowerCase(Self);
  1155. end;
  1156. function TStringHelper.ToUpper: string;
  1157. begin
  1158. Result:=UpperCase(Self);
  1159. end;
  1160. function TStringHelper.ToUpperInvariant: string;
  1161. begin
  1162. Result:=UpperCase(Self);
  1163. end;
  1164. function TStringHelper.Trim: string;
  1165. begin
  1166. Result:=SysUtils.Trim(Self);
  1167. end;
  1168. function TStringHelper.TrimLeft: string;
  1169. begin
  1170. Result:=SysUtils.TrimLeft(Self);
  1171. end;
  1172. function TStringHelper.TrimRight: string;
  1173. begin
  1174. Result:=SysUtils.TrimRight(Self);
  1175. end;
  1176. function TStringHelper.Trim(const ATrimChars: array of Char): string;
  1177. begin
  1178. Result:=Self.TrimLeft(ATrimChars).TrimRight(ATrimChars);
  1179. end;
  1180. function TStringHelper.TrimLeft(const ATrimChars: array of Char): string;
  1181. Var
  1182. I,Len : SizeInt;
  1183. begin
  1184. I:=1;
  1185. Len:=Self.Length;
  1186. While (I<=Len) and HaveChar(Self[i],ATrimChars) do Inc(I);
  1187. if I=1 then
  1188. Result:=Self
  1189. else if I>Len then
  1190. Result:=''
  1191. else
  1192. Result:=system.Copy(Self,I,Len-I+1);
  1193. end;
  1194. function TStringHelper.TrimRight(const ATrimChars: array of Char): string;
  1195. Var
  1196. I,Len : SizeInt;
  1197. begin
  1198. Len:=Self.Length;
  1199. I:=Len;
  1200. While (I>=1) and HaveChar(Self[i],ATrimChars) do Dec(I);
  1201. if I<1 then
  1202. Result:=''
  1203. else if I=Len then
  1204. Result:=Self
  1205. else
  1206. Result:=system.Copy(Self,1,I);
  1207. end;
  1208. function TStringHelper.TrimEnd(const ATrimChars: array of Char): string;
  1209. begin
  1210. Result:=TrimRight(ATrimChars);
  1211. end;
  1212. function TStringHelper.TrimStart(const ATrimChars: array of Char): string;
  1213. begin
  1214. Result:=TrimLeft(ATrimChars);
  1215. end;
  1216. { ---------------------------------------------------------------------
  1217. TCurrencyHelper
  1218. ---------------------------------------------------------------------}
  1219. function TCurrencyHelper.GetMaxValue: Currency;
  1220. begin
  1221. Result:=MaxCurrency;
  1222. end;
  1223. function TCurrencyHelper.GetMinValue: Currency;
  1224. begin
  1225. Result:=MinCurrency;
  1226. end;
  1227. function TCurrencyHelper.Ceil: Int64;
  1228. begin
  1229. Result:=System.Trunc(Self);
  1230. if Currency(Result)<Self then
  1231. Result:=Result+1;
  1232. end;
  1233. function TCurrencyHelper.Floor: Int64;
  1234. begin
  1235. Result:=System.Trunc(Self);
  1236. if Currency(Result)>Self then
  1237. Result:=Result-1;
  1238. end;
  1239. function TCurrencyHelper.Frac: Currency;
  1240. begin
  1241. Result:=System.Frac(Self);
  1242. end;
  1243. class function TCurrencyHelper.Parse(const S: string; const AFormatSettings: TFormatSettings): Currency;
  1244. begin
  1245. Result:=StrToCurr(S, AFormatSettings);
  1246. end;
  1247. class function TCurrencyHelper.Parse(const S: string): Currency;
  1248. begin
  1249. Result:=StrToCurr(S);
  1250. end;
  1251. class function TCurrencyHelper.Size: Integer;
  1252. begin
  1253. Result:=SizeOf(Currency);
  1254. end;
  1255. function TCurrencyHelper.ToString(const AFormatSettings: TFormatSettings): string;
  1256. begin
  1257. Result:=CurrToStr(Self, AFormatSettings);
  1258. end;
  1259. function TCurrencyHelper.ToString: string;
  1260. begin
  1261. Result:=CurrToStr(Self);
  1262. end;
  1263. class function TCurrencyHelper.ToString(const Value: Currency; const AFormatSettings: TFormatSettings): string;
  1264. begin
  1265. Result:=CurrToStr(Value, AFormatSettings);
  1266. end;
  1267. class function TCurrencyHelper.ToString(const Value: Currency): string;
  1268. begin
  1269. Result:=CurrToStr(Value);
  1270. end;
  1271. function TCurrencyHelper.Trunc: Int64;
  1272. begin
  1273. Result:=System.Trunc(Self);
  1274. end;
  1275. class function TCurrencyHelper.TryParse(const S: string; out Value: Currency; const AFormatSettings: TFormatSettings): Boolean;
  1276. begin
  1277. Result:=True;
  1278. try
  1279. Value:=StrToCurr(S, AFormatSettings);
  1280. except
  1281. on E: Exception do
  1282. Result:=False;
  1283. end;
  1284. end;
  1285. class function TCurrencyHelper.TryParse(const S: string; out Value: Currency): Boolean;
  1286. begin
  1287. Result:=True;
  1288. try
  1289. Value:=StrToCurr(S);
  1290. except
  1291. on E: Exception do
  1292. Result:=False;
  1293. end;
  1294. end;
  1295. { ---------------------------------------------------------------------
  1296. TSingleHelper
  1297. ---------------------------------------------------------------------}
  1298. {$MACRO ON}
  1299. {$IFDEF FPC_HAS_TYPE_SINGLE}
  1300. {$define TFLOATHELPER:=TSingleHelper}
  1301. {$define FLOATTYPE:=Single}
  1302. {$define TFloatRec:=TSingleRec}
  1303. {$i syshelpf.inc}
  1304. {$UNDEF TFloatRec}
  1305. {$ENDIF FPC_HAS_TYPE_SINGLE}
  1306. { ---------------------------------------------------------------------
  1307. TDoubleHelper
  1308. ---------------------------------------------------------------------}
  1309. {$IFDEF FPC_HAS_TYPE_DOUBLE}
  1310. {$define TFLOATHELPER:=TDoubleHelper}
  1311. {$define FLOATTYPE:=Double}
  1312. {$define TFloatRec:=TDoubleRec}
  1313. {$i syshelpf.inc}
  1314. {$UNDEF TFloatRec}
  1315. {$ENDIF FPC_HAS_TYPE_DOUBLE}
  1316. { ---------------------------------------------------------------------
  1317. TExtendedHelper
  1318. ---------------------------------------------------------------------}
  1319. {$ifdef FPC_HAS_TYPE_EXTENDED}
  1320. {$define TFLOATHELPER:=TExtendedHelper}
  1321. {$define FLOATTYPE:=Extended}
  1322. {$define TFloatRec:=TExtended80Rec}
  1323. {$i syshelpf.inc}
  1324. {$UNDEF TFloatRec}
  1325. {$ENDIF FPC_HAS_TYPE_EXTENDED}
  1326. { ---------------------------------------------------------------------
  1327. TByteHelper
  1328. ---------------------------------------------------------------------}
  1329. {$define TORDINALHELPER:=TByteHelper}
  1330. {$define TORDINALTYPE:=Byte}
  1331. {$define TORDINALBITINDEX:=TByteBitIndex}
  1332. {$define TORDINALNIBBLEINDEX:=TByteNibbleIndex}
  1333. {$define TORDINALOVERLAY:=TByteOverlay}
  1334. {$define TORDINALTYPESIZE1}
  1335. {$i syshelpo.inc}
  1336. {$undef TORDINALTYPESIZE1}
  1337. { ---------------------------------------------------------------------
  1338. TShortintHelper
  1339. ---------------------------------------------------------------------}
  1340. {$define TORDINALHELPER:=TShortIntHelper}
  1341. {$define TORDINALTYPE:=ShortInt}
  1342. {$define TORDINALBITINDEX:=TShortIntBitIndex}
  1343. {$define TORDINALNIBBLEINDEX:=TShortIntNibbleIndex}
  1344. {$define TORDINALOVERLAY:=TShortIntOverlay}
  1345. {$define TORDINALTYPESIZE1}
  1346. {$i syshelpo.inc}
  1347. {$undef TORDINALTYPESIZE1}
  1348. { ---------------------------------------------------------------------
  1349. TSmallintHelper
  1350. ---------------------------------------------------------------------}
  1351. {$define TORDINALHELPER:=TSmallIntHelper}
  1352. {$define TORDINALTYPE:=SmallInt}
  1353. {$define TORDINALBITINDEX:=TSmallIntBitIndex}
  1354. {$define TORDINALNIBBLEINDEX:=TSmallIntNibbleIndex}
  1355. {$define TORDINALBYTEINDEX:=TWordByteIndex}
  1356. {$define TORDINALOVERLAY:=TWordOverlay}
  1357. {$define TORDINALTYPESIZE2}
  1358. {$i syshelpo.inc}
  1359. {$undef TORDINALTYPESIZE2}
  1360. { ---------------------------------------------------------------------
  1361. TWordHelper
  1362. ---------------------------------------------------------------------}
  1363. {$define TORDINALHELPER:=TWordHelper}
  1364. {$define TORDINALTYPE:=Word}
  1365. {$define TORDINALBITINDEX:=TWordBitIndex}
  1366. {$define TORDINALNIBBLEINDEX:=TWordNibbleIndex}
  1367. {$define TORDINALBYTEINDEX:=TWordByteIndex}
  1368. {$define TORDINALOVERLAY:=TWordOverlay}
  1369. {$define TORDINALTYPESIZE2}
  1370. {$i syshelpo.inc}
  1371. {$undef TORDINALTYPESIZE2}
  1372. { ---------------------------------------------------------------------
  1373. TCardinalHelper
  1374. ---------------------------------------------------------------------}
  1375. {$define TORDINALHELPER:=TCardinalHelper}
  1376. {$define TORDINALTYPE:=Cardinal}
  1377. {$define TORDINALBITINDEX:=TCardinalBitIndex}
  1378. {$define TORDINALNIBBLEINDEX:=TCardinalNibbleIndex}
  1379. {$define TORDINALBYTEINDEX:=TCardinalByteIndex}
  1380. {$define TORDINALWORDINDEX:=TCardinalWordIndex}
  1381. {$define TORDINALOVERLAY:=TDwordOverlay}
  1382. {$define TORDINALTYPESIZE4}
  1383. {$i syshelpo.inc}
  1384. {$undef TORDINALTYPESIZE4}
  1385. { ---------------------------------------------------------------------
  1386. TIntegerHelper
  1387. ---------------------------------------------------------------------}
  1388. {$define TORDINALHELPER:=TIntegerHelper}
  1389. {$define TORDINALTYPE:=Integer}
  1390. {$define TORDINALBITINDEX:=TIntegerBitIndex}
  1391. {$define TORDINALNIBBLEINDEX:=TIntegerNibbleIndex}
  1392. {$define TORDINALBYTEINDEX:=TIntegerByteIndex}
  1393. {$define TORDINALWORDINDEX:=TIntegerWordIndex}
  1394. {$if sizeof(Integer)=2}
  1395. {$define TORDINALOVERLAY:=TWordOverlay}
  1396. {$define TORDINALTYPESIZE2}
  1397. {$elseif sizeof(Integer)=4}
  1398. {$define TORDINALOVERLAY:=TDwordOverlay}
  1399. {$define TORDINALTYPESIZE4}
  1400. {$else}
  1401. {$fatal Unsupported Integer type size}
  1402. {$endif}
  1403. {$i syshelpo.inc}
  1404. {$undef TORDINALTYPESIZE2}
  1405. {$undef TORDINALTYPESIZE4}
  1406. { ---------------------------------------------------------------------
  1407. TLongIntHelper
  1408. ---------------------------------------------------------------------}
  1409. {$define TORDINALHELPER:=TLongIntHelper}
  1410. {$define TORDINALTYPE:=LongInt}
  1411. {$define TORDINALBITINDEX:=TLongIntBitIndex}
  1412. {$define TORDINALNIBBLEINDEX:=TLongIntNibbleIndex}
  1413. {$define TORDINALBYTEINDEX:=TLongIntByteIndex}
  1414. {$define TORDINALWORDINDEX:=TLongIntWordIndex}
  1415. {$define TORDINALOVERLAY:=TDwordOverlay}
  1416. {$define TORDINALTYPESIZE4}
  1417. {$i syshelpo.inc}
  1418. {$undef TORDINALTYPESIZE4}
  1419. { ---------------------------------------------------------------------
  1420. TInt64Helper
  1421. ---------------------------------------------------------------------}
  1422. {$define TORDINALHELPER:=TInt64Helper}
  1423. {$define TORDINALTYPE:=Int64}
  1424. {$define TORDINALBITINDEX:=TInt64BitIndex}
  1425. {$define TORDINALNIBBLEINDEX:=TInt64NibbleIndex}
  1426. {$define TORDINALBYTEINDEX:=TInt64ByteIndex}
  1427. {$define TORDINALWORDINDEX:=TInt64WordIndex}
  1428. {$define TORDINALDWORDINDEX:=TInt64DWordIndex}
  1429. {$define TORDINALOVERLAY:=TQwordOverlay}
  1430. {$define TORDINALTYPESIZE8}
  1431. {$i syshelpo.inc}
  1432. {$undef TORDINALTYPESIZE8}
  1433. { ---------------------------------------------------------------------
  1434. TQWordHelper
  1435. ---------------------------------------------------------------------}
  1436. {$define TORDINALHELPER:=TQWordHelper}
  1437. {$define TORDINALTYPE:=QWord}
  1438. {$define TORDINALBITINDEX:=TQwordBitIndex}
  1439. {$define TORDINALNIBBLEINDEX:=TQwordNibbleIndex}
  1440. {$define TORDINALBYTEINDEX:=TQwordByteIndex}
  1441. {$define TORDINALWORDINDEX:=TQWordWordIndex}
  1442. {$define TORDINALDWORDINDEX:=TQWordDWordIndex}
  1443. {$define TORDINALOVERLAY:=TQwordOverlay}
  1444. {$define TORDINALTYPESIZE8}
  1445. {$i syshelpo.inc}
  1446. {$undef TORDINALTYPESIZE8}
  1447. { ---------------------------------------------------------------------
  1448. TNativeIntHelper
  1449. ---------------------------------------------------------------------}
  1450. {$define TORDINALHELPER:=TNativeIntHelper}
  1451. {$define TORDINALTYPE:=NativeInt}
  1452. {$define TORDINALBITINDEX:=TNativeIntBitIndex}
  1453. {$if sizeof(NativeInt)=2}
  1454. {$define TORDINALNIBBLEINDEX:=TSmallIntNibbleIndex}
  1455. {$define TORDINALBYTEINDEX:=TSmallIntByteIndex}
  1456. {$define TORDINALOVERLAY:=TSmallIntOverlay}
  1457. {$define TORDINALTYPESIZE2}
  1458. {$elseif sizeof(NativeInt)=4}
  1459. {$define TORDINALNIBBLEINDEX:=TLongIntNibbleIndex}
  1460. {$define TORDINALBYTEINDEX:=TLongIntByteIndex}
  1461. {$define TORDINALWORDINDEX:=TLongIntWordIndex}
  1462. {$define TORDINALOVERLAY:=TLongIntOverlay}
  1463. {$define TORDINALTYPESIZE4}
  1464. {$elseif sizeof(NativeInt)=8}
  1465. {$define TORDINALNIBBLEINDEX:=TInt64NibbleIndex}
  1466. {$define TORDINALBYTEINDEX:=TInt64ByteIndex}
  1467. {$define TORDINALWORDINDEX:=TInt64WordIndex}
  1468. {$define TORDINALDWORDINDEX:=TInt64DWordIndex}
  1469. {$define TORDINALOVERLAY:=TInt64Overlay}
  1470. {$define TORDINALTYPESIZE8}
  1471. {$else}
  1472. {$fatal Unsupported NativeInt type size}
  1473. {$endif}
  1474. {$i syshelpo.inc}
  1475. {$undef TORDINALTYPESIZE2}
  1476. {$undef TORDINALTYPESIZE4}
  1477. {$undef TORDINALTYPESIZE8}
  1478. { ---------------------------------------------------------------------
  1479. TNativeUIntHelper
  1480. ---------------------------------------------------------------------}
  1481. {$define TORDINALHELPER:=TNativeUIntHelper}
  1482. {$define TORDINALTYPE:=NativeUInt}
  1483. {$define TORDINALBITINDEX:=TNativeUIntBitIndex}
  1484. {$if sizeof(NativeUInt)=2}
  1485. {$define TORDINALNIBBLEINDEX:=TWordNibbleIndex}
  1486. {$define TORDINALBYTEINDEX:=TWordByteIndex}
  1487. {$define TORDINALOVERLAY:=TWordOverlay}
  1488. {$define TORDINALTYPESIZE2}
  1489. {$elseif sizeof(NativeUInt)=4}
  1490. {$define TORDINALNIBBLEINDEX:=TDwordNibbleIndex}
  1491. {$define TORDINALBYTEINDEX:=TDwordByteIndex}
  1492. {$define TORDINALWORDINDEX:=TDwordWordIndex}
  1493. {$define TORDINALOVERLAY:=TDwordOverlay}
  1494. {$define TORDINALTYPESIZE4}
  1495. {$elseif sizeof(NativeUInt)=8}
  1496. {$define TORDINALNIBBLEINDEX:=TQwordNibbleIndex}
  1497. {$define TORDINALBYTEINDEX:=TQwordByteIndex}
  1498. {$define TORDINALWORDINDEX:=TQwordWordIndex}
  1499. {$define TORDINALDWORDINDEX:=TQwordDWordIndex}
  1500. {$define TORDINALOVERLAY:=TQwordOverlay}
  1501. {$define TORDINALTYPESIZE8}
  1502. {$else}
  1503. {$fatal Unsupported NativeUInt type size}
  1504. {$endif}
  1505. {$i syshelpo.inc}
  1506. {$undef TORDINALTYPESIZE2}
  1507. {$undef TORDINALTYPESIZE4}
  1508. {$undef TORDINALTYPESIZE8}
  1509. { ---------------------------------------------------------------------
  1510. TBooleanHelper
  1511. ---------------------------------------------------------------------}
  1512. {$define TBOOLHELPER:=TBooleanHelper}
  1513. {$define TBOOLTYPE:=Boolean}
  1514. {$i syshelpb.inc}
  1515. { ---------------------------------------------------------------------
  1516. TBoolean8Helper
  1517. ---------------------------------------------------------------------}
  1518. {$define TBOOLHELPER:=TBoolean8Helper}
  1519. {$define TBOOLTYPE:=Boolean8}
  1520. {$i syshelpb.inc}
  1521. { ---------------------------------------------------------------------
  1522. TBoolean16Helper
  1523. ---------------------------------------------------------------------}
  1524. {$define TBOOLHELPER:=TBoolean16Helper}
  1525. {$define TBOOLTYPE:=Boolean16}
  1526. {$i syshelpb.inc}
  1527. { ---------------------------------------------------------------------
  1528. TBoolean32Helper
  1529. ---------------------------------------------------------------------}
  1530. {$define TBOOLHELPER:=TBoolean32Helper}
  1531. {$define TBOOLTYPE:=Boolean32}
  1532. {$i syshelpb.inc}
  1533. { ---------------------------------------------------------------------
  1534. TBoolean64Helper
  1535. ---------------------------------------------------------------------}
  1536. {$define TBOOLHELPER:=TBoolean64Helper}
  1537. {$define TBOOLTYPE:=Boolean64}
  1538. {$i syshelpb.inc}
  1539. { ---------------------------------------------------------------------
  1540. TByteBoolHelper
  1541. ---------------------------------------------------------------------}
  1542. {$define TBOOLHELPER:=TByteBoolHelper}
  1543. {$define TBOOLTYPE:=ByteBool}
  1544. {$i syshelpb.inc}
  1545. { ---------------------------------------------------------------------
  1546. TWordBoolHelper
  1547. ---------------------------------------------------------------------}
  1548. {$define TBOOLHELPER:=TWordBoolHelper}
  1549. {$define TBOOLTYPE:=WordBool}
  1550. {$i syshelpb.inc}
  1551. { ---------------------------------------------------------------------
  1552. TLongBoolHelper
  1553. ---------------------------------------------------------------------}
  1554. {$define TBOOLHELPER:=TLongBoolHelper}
  1555. {$define TBOOLTYPE:=LongBool}
  1556. {$i syshelpb.inc}
  1557. { ---------------------------------------------------------------------
  1558. TQWordBoolHelper
  1559. ---------------------------------------------------------------------}
  1560. {$define TBOOLHELPER:=TQWordBoolHelper}
  1561. {$define TBOOLTYPE:=QWordBool}
  1562. {$i syshelpb.inc}