syshelph.inc 102 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660
  1. {%MainUnit sysutils.pp}
  2. Type
  3. TStringArray = Array of string;
  4. TAnsiStringArray = Array of Ansistring;
  5. TUnicodeStringArray = Array of UnicodeString;
  6. TWideStringArray = Array of WideString;
  7. TShortStringArray = Array of ShortString;
  8. TCharArray = Array of AnsiChar;
  9. TEndian = ObjPas.TEndian;
  10. TByteBitIndex = 0..7;
  11. TShortIntBitIndex = 0..7;
  12. TWordBitIndex = 0..15;
  13. TSmallIntBitIndex = 0..15;
  14. TCardinalBitIndex = 0..31;
  15. {$if sizeof(Integer)=2}
  16. TIntegerBitIndex = 0..15;
  17. {$elseif sizeof(Integer)=4}
  18. TIntegerBitIndex = 0..31;
  19. {$else}
  20. {$fatal Unsupported Integer type size}
  21. {$endif}
  22. TLongIntBitIndex = 0..31;
  23. TQwordBitIndex = 0..63;
  24. TInt64BitIndex = 0..63;
  25. {$IFDEF cpu16}
  26. TNativeUIntBitIndex = TWordBitIndex;
  27. TNativeIntBitIndex = TSmallIntBitIndex;
  28. {$ENDIF}
  29. {$IFDEF cpu32}
  30. TNativeUIntBitIndex = TCardinalBitIndex;
  31. TNativeIntBitIndex = TIntegerBitIndex;
  32. {$ENDIF}
  33. {$IFDEF cpu64}
  34. TNativeUIntBitIndex = TQWordBitIndex;
  35. TNativeIntBitIndex = TInt64BitIndex;
  36. {$ENDIF}
  37. Const
  38. CPUEndian = {$IFDEF FPC_LITTLE_ENDIAN}TEndian.Little{$ELSE}TEndian.Big{$ENDIF};
  39. Type
  40. TGuidHelper = record helper for TGUID
  41. Class function Create(const Data; BigEndian: Boolean): TGUID; overload; static;
  42. class function Create(const Data: array of Byte; AStartIndex: Cardinal; BigEndian: Boolean): TGUID; overload; static;
  43. Class Function Create(const Data; DataEndian: TEndian = CPUEndian): TGUID; overload; static; inline;
  44. Class Function Create(const B: TBytes; DataEndian: TEndian = CPUEndian): TGUID; overload; static; inline;
  45. Class Function Create(const B: TBytes; AStartIndex: Cardinal; DataEndian: TEndian = CPUEndian): TGUID; overload; static;
  46. Class Function Create(const S: string): TGUID; overload; static;
  47. Class Function Create(A: Integer; B: SmallInt; C: SmallInt; const D: TBytes): TGUID; overload; static;
  48. Class Function Create(A: Integer; B: SmallInt; C: SmallInt; D, E, F, G, H, I, J, K: Byte): TGUID; overload; static;
  49. Class Function Create(A: Cardinal; B: Word; C: Word; D, E, F, G, H, I, J, K: Byte): TGUID; overload; static;
  50. Class Function NewGuid: TGUID; static;
  51. Function ToByteArray(DataEndian: TEndian = CPUEndian): TBytes;
  52. Function ToString(SkipBrackets: Boolean = False): string;
  53. end;
  54. TCompareOption = system.TCompareOption;
  55. TCompareOptions = system.TCompareOptions;
  56. {$SCOPEDENUMS ON}
  57. TStringSplitOptions = (None, ExcludeEmpty, ExcludeLastEmpty);
  58. {$SCOPEDENUMS OFF}
  59. { TAnsiStringHelper }
  60. TAnsiStringHelper = Type Helper for AnsiString
  61. Private
  62. Function GetChar(AIndex : SizeInt) : AnsiChar;
  63. Function GetLength : SizeInt;
  64. public
  65. const Empty = '';
  66. // Methods
  67. Class Function Compare(const A: AnsiString; const B: AnsiString): Integer; overload; static; //inline;
  68. Class Function Compare(const A: AnsiString; const B: AnsiString; IgnoreCase: Boolean): Integer; overload; static; //inline; //deprecated 'Use same with TCompareOptions';
  69. Class Function Compare(const A: AnsiString; const B: AnsiString; Options: TCompareOptions): Integer; overload; static; // inline;
  70. Class Function Compare(const A: AnsiString; IndexA: SizeInt; const B: AnsiString; IndexB: SizeInt; ALen: SizeInt): Integer; overload; static; // inline;
  71. Class Function Compare(const A: AnsiString; IndexA: SizeInt; const B: AnsiString; IndexB: SizeInt; ALen: SizeInt; IgnoreCase: Boolean): Integer; overload; static; // inline; //deprecated 'Use same with TCompareOptions';
  72. Class Function Compare(const A: AnsiString; IndexA: SizeInt; const B: AnsiString; IndexB: SizeInt; ALen: SizeInt; Options: TCompareOptions): Integer; overload; static;// inline;
  73. Class Function CompareOrdinal(const A: AnsiString; const B: AnsiString): Integer; overload; static;
  74. Class Function CompareOrdinal(const A: AnsiString; IndexA: SizeInt; const B: AnsiString; IndexB: SizeInt; ALen: SizeInt): Integer; overload; static;
  75. Class Function CompareText(const A: AnsiString; const B: AnsiString): Integer; static; inline;
  76. Class Function Copy(const Str: AnsiString): AnsiString; inline; static;
  77. Class Function Create(AChar: AnsiChar; ACount: SizeInt): AnsiString; overload; inline; static;
  78. Class Function Create(const AValue: array of AnsiChar): AnsiString; overload; static;
  79. Class Function Create(const AValue: array of AnsiChar; StartIndex: SizeInt; ALen: SizeInt): AnsiString; overload; static;
  80. Class Function EndsText(const ASubText, AText: AnsiString): Boolean; static;
  81. Class Function Equals(const a: AnsiString; const b: AnsiString): Boolean; overload; static;
  82. Class Function Format(const AFormat: AnsiString; const args: array of const): AnsiString; overload; static;
  83. Class Function IsNullOrEmpty(const AValue: AnsiString): Boolean; static;
  84. Class Function IsNullOrWhiteSpace(const AValue: AnsiString): Boolean; static;
  85. Class Function Join(const Separator: AnsiString; const Values: array of const): AnsiString; overload; static;
  86. Class Function Join(const Separator: AnsiString; const Values: array of AnsiString): AnsiString; overload; static;
  87. Class Function Join(const Separator: AnsiString; const Values: array of AnsiString; StartIndex: SizeInt; ACount: SizeInt): AnsiString; overload; static;
  88. Class Function LowerCase(const S: AnsiString): AnsiString; overload; static; inline;
  89. Class Function Parse(const AValue: Boolean): AnsiString; overload; static; inline;
  90. Class Function Parse(const AValue: Extended): AnsiString; overload; static;inline;
  91. Class Function Parse(const AValue: Int64): AnsiString; overload; static; inline;
  92. Class Function Parse(const AValue: Integer): AnsiString; overload; static; inline;
  93. Class Function ToBoolean(const S: AnsiString): Boolean; overload; static; inline;
  94. Class Function ToDouble(const S: AnsiString): Double; overload; static; inline;
  95. Class Function ToExtended(const S: AnsiString): Extended; overload; static; inline;
  96. Class Function ToInt64(const S: AnsiString): Int64; overload; static; inline;
  97. Class Function ToInteger(const S: AnsiString): Integer; overload; static; inline;
  98. Class Function ToSingle(const S: AnsiString): Single; overload; static; inline;
  99. Class Function UpperCase(const S: AnsiString): AnsiString; overload; static; inline;
  100. Function CompareTo(const B: AnsiString): Integer;
  101. Function Contains(const AValue: AnsiString; IgnoreCase: Boolean = False): Boolean;
  102. procedure CopyTo(SourceIndex: SizeInt; var destination: array of AnsiChar; DestinationIndex: SizeInt; ACount: SizeInt);
  103. Function CountChar(const C: AnsiChar): SizeInt;
  104. Function DeQuotedString: AnsiString; overload;
  105. Function DeQuotedString(const AQuoteChar: AnsiChar): AnsiString; overload;
  106. Function EndsWith(const AValue: AnsiString): Boolean; overload; inline;
  107. Function EndsWith(const AValue: AnsiString; IgnoreCase: Boolean): Boolean; overload;
  108. Function Equals(const AValue: AnsiString; IgnoreCase: Boolean = False): Boolean; overload;
  109. Function Format(const args: array of const): AnsiString; overload;
  110. Function GetHashCode: Integer;
  111. Function IndexOf(AValue: AnsiChar): SizeInt; overload; inline;
  112. Function IndexOf(const AValue: AnsiString): SizeInt; overload; inline;
  113. Function IndexOf(AValue: AnsiChar; StartIndex: SizeInt): SizeInt; overload;
  114. Function IndexOf(const AValue: AnsiString; StartIndex: SizeInt): SizeInt; overload;
  115. Function IndexOf(AValue: AnsiChar; StartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  116. Function IndexOf(const AValue: AnsiString; StartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  117. Function IndexOfUnQuoted(const AValue: AnsiString; StartQuote, EndQuote: AnsiChar; StartIndex: SizeInt = 0): SizeInt; overload;
  118. Function IndexOfAny(const AnyOf: array of AnsiChar): SizeInt; overload;
  119. Function IndexOfAny(const AnyOf: array of AnsiChar; StartIndex: SizeInt): SizeInt; overload;
  120. Function IndexOfAny(const AnyOf: array of AnsiChar; StartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  121. Function IndexOfAny(const AnyOf: array of AnsiString): SizeInt; overload;
  122. Function IndexOfAny(const AnyOf: array of AnsiString; StartIndex: SizeInt): SizeInt; overload;
  123. Function IndexOfAny(const AnyOf: array of AnsiString; StartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  124. Function IndexOfAny(const AnyOf: array of AnsiString; StartIndex: SizeInt; ACount: SizeInt; Out AMatch : SizeInt): SizeInt; overload;
  125. Function IndexOfAnyUnquoted(const AnyOf: array of AnsiChar; StartQuote, EndQuote: AnsiChar): SizeInt; overload;
  126. Function IndexOfAnyUnquoted(const AnyOf: array of AnsiChar; StartQuote, EndQuote: AnsiChar; StartIndex: SizeInt): SizeInt; overload;
  127. Function IndexOfAnyUnquoted(const AnyOf: array of AnsiChar; StartQuote, EndQuote: AnsiChar; StartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  128. function IndexOfAnyUnquoted(const AnyOf: array of AnsiString; StartQuote, EndQuote: AnsiChar; StartIndex: SizeInt; Out Matched: SizeInt): SizeInt; overload;
  129. Function Insert(StartIndex: SizeInt; const AValue: AnsiString): AnsiString;
  130. Function IsDelimiter(const Delimiters: AnsiString; Index: SizeInt): Boolean;
  131. Function IsEmpty: Boolean;
  132. Function LastDelimiter(const Delims: AnsiString): SizeInt;
  133. Function LastIndexOf(AValue: AnsiChar): SizeInt; overload;
  134. Function LastIndexOf(const AValue: AnsiString): SizeInt; overload;
  135. Function LastIndexOf(AValue: AnsiChar; AStartIndex: SizeInt): SizeInt; overload;
  136. Function LastIndexOf(const AValue: AnsiString; AStartIndex: SizeInt): SizeInt; overload;
  137. Function LastIndexOf(AValue: AnsiChar; AStartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  138. Function LastIndexOf(const AValue: AnsiString; AStartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  139. Function LastIndexOfAny(const AnyOf: array of AnsiChar): SizeInt; overload;
  140. Function LastIndexOfAny(const AnyOf: array of AnsiChar; AStartIndex: SizeInt): SizeInt; overload;
  141. Function LastIndexOfAny(const AnyOf: array of AnsiChar; AStartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  142. Function PadLeft(ATotalWidth: SizeInt): AnsiString; overload; inline;
  143. Function PadLeft(ATotalWidth: SizeInt; PaddingChar: AnsiChar): AnsiString; overload; inline;
  144. Function PadRight(ATotalWidth: SizeInt): AnsiString; overload; inline;
  145. Function PadRight(ATotalWidth: SizeInt; PaddingChar: AnsiChar): AnsiString; overload; inline;
  146. Function QuotedString: AnsiString; overload;
  147. Function QuotedString(const AQuoteChar: AnsiChar): AnsiString; overload;
  148. Function Remove(StartIndex: SizeInt): AnsiString; overload; inline;
  149. Function Remove(StartIndex: SizeInt; ACount: SizeInt): AnsiString; overload; inline;
  150. Function Replace(OldChar: AnsiChar; NewChar: AnsiChar): AnsiString; overload;
  151. Function Replace(OldChar: AnsiChar; NewChar: AnsiChar; ReplaceFlags: TReplaceFlags): AnsiString; overload;
  152. Function Replace(const OldValue: AnsiString; const NewValue: AnsiString): AnsiString; overload;
  153. Function Replace(const OldValue: AnsiString; const NewValue: AnsiString; ReplaceFlags: TReplaceFlags): AnsiString; overload;
  154. Function Split(const Separators: array of AnsiChar): TAnsiStringArray; overload;
  155. Function Split(const Separators: array of AnsiChar; ACount: SizeInt): TAnsiStringArray; overload;
  156. Function Split(const Separators: array of AnsiChar; Options: TStringSplitOptions): TAnsiStringArray; overload;
  157. Function Split(const Separators: array of AnsiChar; ACount: SizeInt; Options: TStringSplitOptions): TAnsiStringArray; overload;
  158. Function Split(const Separators: array of AnsiString): TAnsiStringArray; overload;
  159. Function Split(const Separators: array of AnsiString; ACount: SizeInt): TAnsiStringArray; overload;
  160. Function Split(const Separators: array of AnsiString; Options: TStringSplitOptions): TAnsiStringArray; overload;
  161. Function Split(const Separators: array of AnsiString; ACount: SizeInt; Options: TStringSplitOptions): TAnsiStringArray; overload;
  162. Function Split(const Separators: array of AnsiChar; AQuote: AnsiChar): TAnsiStringArray; overload;
  163. Function Split(const Separators: array of AnsiChar; AQuoteStart, AQuoteEnd: AnsiChar): TAnsiStringArray; overload;
  164. Function Split(const Separators: array of AnsiChar; AQuoteStart, AQuoteEnd: AnsiChar; Options: TStringSplitOptions): TAnsiStringArray; overload;
  165. Function Split(const Separators: array of AnsiChar; AQuoteStart, AQuoteEnd: AnsiChar; ACount: SizeInt): TAnsiStringArray; overload;
  166. Function Split(const Separators: array of AnsiChar; AQuoteStart, AQuoteEnd: AnsiChar; ACount: SizeInt; Options: TStringSplitOptions): TAnsiStringArray; overload;
  167. Function Split(const Separators: array of AnsiString; AQuote: AnsiChar): TAnsiStringArray; overload;
  168. Function Split(const Separators: array of AnsiString; AQuoteStart, AQuoteEnd: AnsiChar): TAnsiStringArray; overload;
  169. Function Split(const Separators: array of AnsiString; AQuoteStart, AQuoteEnd: AnsiChar; Options: TStringSplitOptions): TAnsiStringArray; overload;
  170. Function Split(const Separators: array of AnsiString; AQuoteStart, AQuoteEnd: AnsiChar; ACount: SizeInt): TAnsiStringArray; overload;
  171. Function Split(const Separators: array of AnsiString; AQuoteStart, AQuoteEnd: AnsiChar; ACount: SizeInt; Options: TStringSplitOptions): TAnsiStringArray; overload;
  172. Function StartsWith(const AValue: AnsiString): Boolean; overload; inline;
  173. Function StartsWith(const AValue: AnsiString; IgnoreCase: Boolean): Boolean; overload;
  174. Function Substring(AStartIndex: SizeInt): AnsiString; overload;
  175. Function Substring(AStartIndex: SizeInt; ALen: SizeInt): AnsiString; overload;
  176. Function ToBoolean: Boolean; overload; inline;
  177. Function ToInteger: Integer; overload; inline;
  178. Function ToInt64: Int64; overload; inline;
  179. Function ToSingle: Single; overload; inline;
  180. Function ToDouble: Double; overload; inline;
  181. Function ToExtended: Extended; overload; inline;
  182. Function ToCharArray: TCharArray; overload;
  183. Function ToCharArray(AStartIndex: SizeInt; ALen: SizeInt): TCharArray; overload;
  184. Function ToLower: AnsiString; overload; inline;
  185. Function ToLowerInvariant: AnsiString;
  186. Function ToUpper: AnsiString; overload; inline;
  187. Function ToUpperInvariant: AnsiString; inline;
  188. Function Trim: AnsiString; overload;
  189. Function TrimLeft: AnsiString; overload;
  190. Function TrimRight: AnsiString; overload;
  191. Function Trim(const ATrimChars: array of AnsiChar): AnsiString; overload;
  192. Function TrimLeft(const ATrimChars: array of AnsiChar): AnsiString; overload;
  193. Function TrimRight(const ATrimChars: array of AnsiChar): AnsiString; overload;
  194. Function TrimEnd(const ATrimChars: array of AnsiChar): AnsiString; deprecated 'Use TrimRight';
  195. Function TrimStart(const ATrimChars: array of AnsiChar): AnsiString; deprecated 'Use TrimLeft';
  196. property Chars[AIndex: SizeInt]: AnsiChar read GetChar;
  197. property Length: SizeInt read GetLength;
  198. end;
  199. TCurrencyHelper = type helper for Currency
  200. private
  201. function GetMaxValue: Currency; inline;
  202. function GetMinValue: Currency; inline;
  203. public
  204. function Ceil: Int64; inline;
  205. function Floor: Int64; inline;
  206. function Frac: Currency; inline;
  207. class function Parse(const S: string; const AFormatSettings: TFormatSettings): Currency; overload; static;
  208. class function Parse(const S: string): Currency; overload; inline; static;
  209. class function Size: Integer; inline; static;
  210. function ToString(const AFormatSettings: TFormatSettings): string; overload; inline;
  211. function ToString: string; overload; inline;
  212. class function ToString(const Value: Currency; const AFormatSettings: TFormatSettings): string; overload; inline; static;
  213. class function ToString(const Value: Currency): string; overload; inline; static;
  214. function Trunc: Int64; inline;
  215. class function TryParse(const S: string; out Value: Currency; const AFormatSettings: TFormatSettings): Boolean; overload; inline; static;
  216. class function TryParse(const S: string; out Value: Currency): Boolean; overload; inline; static;
  217. property MaxValue: Currency read GetMaxValue;
  218. property MinValue: Currency read GetMinValue;
  219. end;
  220. { TWideStringHelper }
  221. TWideStringHelper = Type Helper for WideString
  222. Private
  223. Function GetChar(AIndex : SizeInt) : WideChar;
  224. Function GetLength : SizeInt;
  225. public
  226. const Empty = '';
  227. // Methods
  228. Class Function Compare(const A: WideString; const B: WideString): Integer; overload; static; //inline;
  229. Class Function Compare(const A: WideString; const B: WideString; IgnoreCase: Boolean): Integer; overload; static; //inline; //deprecated 'Use same with TCompareOptions';
  230. Class Function Compare(const A: WideString; const B: WideString; Options: TCompareOptions): Integer; overload; static; // inline;
  231. Class Function Compare(const A: WideString; IndexA: SizeInt; const B: WideString; IndexB: SizeInt; ALen: SizeInt): Integer; overload; static; // inline;
  232. Class Function Compare(const A: WideString; IndexA: SizeInt; const B: WideString; IndexB: SizeInt; ALen: SizeInt; IgnoreCase: Boolean): Integer; overload; static; // inline; //deprecated 'Use same with TCompareOptions';
  233. Class Function Compare(const A: WideString; IndexA: SizeInt; const B: WideString; IndexB: SizeInt; ALen: SizeInt; Options: TCompareOptions): Integer; overload; static;// inline;
  234. Class Function CompareOrdinal(const A: WideString; const B: WideString): Integer; overload; static;
  235. Class Function CompareOrdinal(const A: WideString; IndexA: SizeInt; const B: WideString; IndexB: SizeInt; ALen: SizeInt): Integer; overload; static;
  236. Class Function CompareText(const A: WideString; const B: WideString): Integer; static; inline;
  237. Class Function Copy(const Str: WideString): WideString; inline; static;
  238. Class Function Create(AChar: WideChar; ACount: SizeInt): WideString; overload; inline; static;
  239. Class Function Create(const AValue: array of WideChar): WideString; overload; static;
  240. Class Function Create(const AValue: array of WideChar; StartIndex: SizeInt; ALen: SizeInt): WideString; overload; static;
  241. Class Function EndsText(const ASubText, AText: WideString): Boolean; static;
  242. Class Function Equals(const a: WideString; const b: WideString): Boolean; overload; static;
  243. Class Function Format(const AFormat: WideString; const args: array of const): WideString; overload; static;
  244. Class Function IsNullOrEmpty(const AValue: WideString): Boolean; static;
  245. Class Function IsNullOrWhiteSpace(const AValue: WideString): Boolean; static;
  246. Class Function Join(const Separator: WideString; const Values: array of const): WideString; overload; static;
  247. Class Function Join(const Separator: WideString; const Values: array of WideString): WideString; overload; static;
  248. Class Function Join(const Separator: WideString; const Values: array of WideString; StartIndex: SizeInt; ACount: SizeInt): WideString; overload; static;
  249. Class Function LowerCase(const S: WideString): WideString; overload; static; inline;
  250. Class Function Parse(const AValue: Boolean): WideString; overload; static; inline;
  251. Class Function Parse(const AValue: Extended): WideString; overload; static;inline;
  252. Class Function Parse(const AValue: Int64): WideString; overload; static; inline;
  253. Class Function Parse(const AValue: Integer): WideString; overload; static; inline;
  254. Class Function ToBoolean(const S: WideString): Boolean; overload; static; inline;
  255. Class Function ToDouble(const S: WideString): Double; overload; static; inline;
  256. Class Function ToExtended(const S: WideString): Extended; overload; static; inline;
  257. Class Function ToInt64(const S: WideString): Int64; overload; static; inline;
  258. Class Function ToInteger(const S: WideString): Integer; overload; static; inline;
  259. Class Function ToSingle(const S: WideString): Single; overload; static; inline;
  260. Class Function UpperCase(const S: WideString): WideString; overload; static; inline;
  261. Function CompareTo(const B: WideString): Integer;
  262. Function Contains(const AValue: WideString; IgnoreCase: Boolean = False): Boolean;
  263. procedure CopyTo(SourceIndex: SizeInt; var destination: array of WideChar; DestinationIndex: SizeInt; ACount: SizeInt);
  264. Function CountChar(const C: WideChar): SizeInt;
  265. Function DeQuotedString: WideString; overload;
  266. Function DeQuotedString(const AQuoteChar: WideChar): WideString; overload;
  267. Function EndsWith(const AValue: WideString): Boolean; overload; inline;
  268. Function EndsWith(const AValue: WideString; IgnoreCase: Boolean): Boolean; overload;
  269. Function Equals(const AValue: WideString; IgnoreCase: Boolean = False): Boolean; overload;
  270. Function Format(const args: array of const): WideString; overload;
  271. Function GetHashCode: Integer;
  272. Function IndexOf(AValue: WideChar): SizeInt; overload; inline;
  273. Function IndexOf(const AValue: WideString): SizeInt; overload; inline;
  274. Function IndexOf(AValue: WideChar; StartIndex: SizeInt): SizeInt; overload;
  275. Function IndexOf(const AValue: WideString; StartIndex: SizeInt): SizeInt; overload;
  276. Function IndexOf(AValue: WideChar; StartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  277. Function IndexOf(const AValue: WideString; StartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  278. Function IndexOfUnQuoted(const AValue: WideString; StartQuote, EndQuote: WideChar; StartIndex: SizeInt = 0): SizeInt; overload;
  279. Function IndexOfAny(const AnyOf: array of WideChar): SizeInt; overload;
  280. Function IndexOfAny(const AnyOf: array of WideChar; StartIndex: SizeInt): SizeInt; overload;
  281. Function IndexOfAny(const AnyOf: array of WideChar; StartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  282. Function IndexOfAny(const AnyOf: array of WideString): SizeInt; overload;
  283. Function IndexOfAny(const AnyOf: array of WideString; StartIndex: SizeInt): SizeInt; overload;
  284. Function IndexOfAny(const AnyOf: array of WideString; StartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  285. Function IndexOfAny(const AnyOf: array of WideString; StartIndex: SizeInt; ACount: SizeInt; Out AMatch : SizeInt): SizeInt; overload;
  286. Function IndexOfAnyUnquoted(const AnyOf: array of WideChar; StartQuote, EndQuote: WideChar): SizeInt; overload;
  287. Function IndexOfAnyUnquoted(const AnyOf: array of WideChar; StartQuote, EndQuote: WideChar; StartIndex: SizeInt): SizeInt; overload;
  288. Function IndexOfAnyUnquoted(const AnyOf: array of WideChar; StartQuote, EndQuote: WideChar; StartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  289. function IndexOfAnyUnquoted(const AnyOf: array of WideString; StartQuote, EndQuote: WideChar; StartIndex: SizeInt; Out Matched: SizeInt): SizeInt; overload;
  290. Function Insert(StartIndex: SizeInt; const AValue: WideString): WideString;
  291. Function IsDelimiter(const Delimiters: WideString; Index: SizeInt): Boolean;
  292. Function IsEmpty: Boolean;
  293. Function LastDelimiter(const Delims: WideString): SizeInt;
  294. Function LastIndexOf(AValue: WideChar): SizeInt; overload;
  295. Function LastIndexOf(const AValue: WideString): SizeInt; overload;
  296. Function LastIndexOf(AValue: WideChar; AStartIndex: SizeInt): SizeInt; overload;
  297. Function LastIndexOf(const AValue: WideString; AStartIndex: SizeInt): SizeInt; overload;
  298. Function LastIndexOf(AValue: WideChar; AStartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  299. Function LastIndexOf(const AValue: WideString; AStartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  300. Function LastIndexOfAny(const AnyOf: array of WideChar): SizeInt; overload;
  301. Function LastIndexOfAny(const AnyOf: array of WideChar; AStartIndex: SizeInt): SizeInt; overload;
  302. Function LastIndexOfAny(const AnyOf: array of WideChar; AStartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  303. Function PadLeft(ATotalWidth: SizeInt): WideString; overload; inline;
  304. Function PadLeft(ATotalWidth: SizeInt; PaddingChar: WideChar): WideString; overload; inline;
  305. Function PadRight(ATotalWidth: SizeInt): WideString; overload; inline;
  306. Function PadRight(ATotalWidth: SizeInt; PaddingChar: WideChar): WideString; overload; inline;
  307. Function QuotedString: WideString; overload;
  308. Function QuotedString(const AQuoteChar: WideChar): WideString; overload;
  309. Function Remove(StartIndex: SizeInt): WideString; overload; inline;
  310. Function Remove(StartIndex: SizeInt; ACount: SizeInt): WideString; overload; inline;
  311. Function Replace(OldChar: WideChar; NewChar: WideChar): WideString; overload;
  312. Function Replace(OldChar: WideChar; NewChar: WideChar; ReplaceFlags: TReplaceFlags): WideString; overload;
  313. Function Replace(const OldValue: WideString; const NewValue: WideString): WideString; overload;
  314. Function Replace(const OldValue: WideString; const NewValue: WideString; ReplaceFlags: TReplaceFlags): WideString; overload;
  315. Function Split(const Separators: array of WideChar): TWideStringArray; overload;
  316. Function Split(const Separators: array of WideChar; ACount: SizeInt): TWideStringArray; overload;
  317. Function Split(const Separators: array of WideChar; Options: TStringSplitOptions): TWideStringArray; overload;
  318. Function Split(const Separators: array of WideChar; ACount: SizeInt; Options: TStringSplitOptions): TWideStringArray; overload;
  319. Function Split(const Separators: array of WideString): TWideStringArray; overload;
  320. Function Split(const Separators: array of WideString; ACount: SizeInt): TWideStringArray; overload;
  321. Function Split(const Separators: array of WideString; Options: TStringSplitOptions): TWideStringArray; overload;
  322. Function Split(const Separators: array of WideString; ACount: SizeInt; Options: TStringSplitOptions): TWideStringArray; overload;
  323. Function Split(const Separators: array of WideChar; AQuote: WideChar): TWideStringArray; overload;
  324. Function Split(const Separators: array of WideChar; AQuoteStart, AQuoteEnd: WideChar): TWideStringArray; overload;
  325. Function Split(const Separators: array of WideChar; AQuoteStart, AQuoteEnd: WideChar; Options: TStringSplitOptions): TWideStringArray; overload;
  326. Function Split(const Separators: array of WideChar; AQuoteStart, AQuoteEnd: WideChar; ACount: SizeInt): TWideStringArray; overload;
  327. Function Split(const Separators: array of WideChar; AQuoteStart, AQuoteEnd: WideChar; ACount: SizeInt; Options: TStringSplitOptions): TWideStringArray; overload;
  328. Function Split(const Separators: array of WideString; AQuote: WideChar): TWideStringArray; overload;
  329. Function Split(const Separators: array of WideString; AQuoteStart, AQuoteEnd: WideChar): TWideStringArray; overload;
  330. Function Split(const Separators: array of WideString; AQuoteStart, AQuoteEnd: WideChar; Options: TStringSplitOptions): TWideStringArray; overload;
  331. Function Split(const Separators: array of WideString; AQuoteStart, AQuoteEnd: WideChar; ACount: SizeInt): TWideStringArray; overload;
  332. Function Split(const Separators: array of WideString; AQuoteStart, AQuoteEnd: WideChar; ACount: SizeInt; Options: TStringSplitOptions): TWideStringArray; overload;
  333. Function StartsWith(const AValue: WideString): Boolean; overload; inline;
  334. Function StartsWith(const AValue: WideString; IgnoreCase: Boolean): Boolean; overload;
  335. Function Substring(AStartIndex: SizeInt): WideString; overload;
  336. Function Substring(AStartIndex: SizeInt; ALen: SizeInt): WideString; overload;
  337. Function ToBoolean: Boolean; overload; inline;
  338. Function ToInteger: Integer; overload; inline;
  339. Function ToInt64: Int64; overload; inline;
  340. Function ToSingle: Single; overload; inline;
  341. Function ToDouble: Double; overload; inline;
  342. Function ToExtended: Extended; overload; inline;
  343. Function ToCharArray: TCharArray; overload;
  344. Function ToCharArray(AStartIndex: SizeInt; ALen: SizeInt): TCharArray; overload;
  345. Function ToLower: WideString; overload; inline;
  346. Function ToLowerInvariant: WideString;
  347. Function ToUpper: WideString; overload; inline;
  348. Function ToUpperInvariant: WideString; inline;
  349. Function Trim: WideString; overload;
  350. Function TrimLeft: WideString; overload;
  351. Function TrimRight: WideString; overload;
  352. Function Trim(const ATrimChars: array of WideChar): WideString; overload;
  353. Function TrimLeft(const ATrimChars: array of WideChar): WideString; overload;
  354. Function TrimRight(const ATrimChars: array of WideChar): WideString; overload;
  355. Function TrimEnd(const ATrimChars: array of WideChar): WideString; deprecated 'Use TrimRight';
  356. Function TrimStart(const ATrimChars: array of WideChar): WideString; deprecated 'Use TrimLeft';
  357. property Chars[AIndex: SizeInt]: WideChar read GetChar;
  358. property Length: SizeInt read GetLength;
  359. end;
  360. { TUnicodeStringHelper }
  361. TUnicodeStringHelper = Type Helper for UnicodeString
  362. Private
  363. Function GetChar(AIndex : SizeInt) : UnicodeChar;
  364. Function GetLength : SizeInt;
  365. public
  366. const Empty = '';
  367. // Methods
  368. Class Function Compare(const A: UnicodeString; const B: UnicodeString): Integer; overload; static; //inline;
  369. Class Function Compare(const A: UnicodeString; const B: UnicodeString; IgnoreCase: Boolean): Integer; overload; static; //inline; //deprecated 'Use same with TCompareOptions';
  370. Class Function Compare(const A: UnicodeString; const B: UnicodeString; Options: TCompareOptions): Integer; overload; static; // inline;
  371. Class Function Compare(const A: UnicodeString; IndexA: SizeInt; const B: UnicodeString; IndexB: SizeInt; ALen: SizeInt): Integer; overload; static; // inline;
  372. Class Function Compare(const A: UnicodeString; IndexA: SizeInt; const B: UnicodeString; IndexB: SizeInt; ALen: SizeInt; IgnoreCase: Boolean): Integer; overload; static; // inline; //deprecated 'Use same with TCompareOptions';
  373. Class Function Compare(const A: UnicodeString; IndexA: SizeInt; const B: UnicodeString; IndexB: SizeInt; ALen: SizeInt; Options: TCompareOptions): Integer; overload; static;// inline;
  374. Class Function CompareOrdinal(const A: UnicodeString; const B: UnicodeString): Integer; overload; static;
  375. Class Function CompareOrdinal(const A: UnicodeString; IndexA: SizeInt; const B: UnicodeString; IndexB: SizeInt; ALen: SizeInt): Integer; overload; static;
  376. Class Function CompareText(const A: UnicodeString; const B: UnicodeString): Integer; static; inline;
  377. Class Function Copy(const Str: UnicodeString): UnicodeString; inline; static;
  378. Class Function Create(AChar: UnicodeChar; ACount: SizeInt): UnicodeString; overload; inline; static;
  379. Class Function Create(const AValue: array of UnicodeChar): UnicodeString; overload; static;
  380. Class Function Create(const AValue: array of UnicodeChar; StartIndex: SizeInt; ALen: SizeInt): UnicodeString; overload; static;
  381. Class Function EndsText(const ASubText, AText: UnicodeString): Boolean; static;
  382. Class Function Equals(const a: UnicodeString; const b: UnicodeString): Boolean; overload; static;
  383. Class Function Format(const AFormat: UnicodeString; const args: array of const): UnicodeString; overload; static;
  384. Class Function IsNullOrEmpty(const AValue: UnicodeString): Boolean; static;
  385. Class Function IsNullOrWhiteSpace(const AValue: UnicodeString): Boolean; static;
  386. Class Function Join(const Separator: UnicodeString; const Values: array of const): UnicodeString; overload; static;
  387. Class Function Join(const Separator: UnicodeString; const Values: array of UnicodeString): UnicodeString; overload; static;
  388. Class Function Join(const Separator: UnicodeString; const Values: array of UnicodeString; StartIndex: SizeInt; ACount: SizeInt): UnicodeString; overload; static;
  389. Class Function LowerCase(const S: UnicodeString): UnicodeString; overload; static; inline;
  390. Class Function Parse(const AValue: Boolean): UnicodeString; overload; static; inline;
  391. Class Function Parse(const AValue: Extended): UnicodeString; overload; static;inline;
  392. Class Function Parse(const AValue: Int64): UnicodeString; overload; static; inline;
  393. Class Function Parse(const AValue: Integer): UnicodeString; overload; static; inline;
  394. Class Function ToBoolean(const S: UnicodeString): Boolean; overload; static; inline;
  395. Class Function ToDouble(const S: UnicodeString): Double; overload; static; inline;
  396. Class Function ToExtended(const S: UnicodeString): Extended; overload; static; inline;
  397. Class Function ToInt64(const S: UnicodeString): Int64; overload; static; inline;
  398. Class Function ToInteger(const S: UnicodeString): Integer; overload; static; inline;
  399. Class Function ToSingle(const S: UnicodeString): Single; overload; static; inline;
  400. Class Function UpperCase(const S: UnicodeString): UnicodeString; overload; static; inline;
  401. Function CompareTo(const B: UnicodeString): Integer;
  402. Function Contains(const AValue: UnicodeString; IgnoreCase: Boolean = False): Boolean;
  403. procedure CopyTo(SourceIndex: SizeInt; var destination: array of UnicodeChar; DestinationIndex: SizeInt; ACount: SizeInt);
  404. Function CountChar(const C: UnicodeChar): SizeInt;
  405. Function DeQuotedString: UnicodeString; overload;
  406. Function DeQuotedString(const AQuoteChar: UnicodeChar): UnicodeString; overload;
  407. Function EndsWith(const AValue: UnicodeString): Boolean; overload; inline;
  408. Function EndsWith(const AValue: UnicodeString; IgnoreCase: Boolean): Boolean; overload;
  409. Function Equals(const AValue: UnicodeString; IgnoreCase: Boolean = False): Boolean; overload;
  410. Function Format(const args: array of const): UnicodeString; overload;
  411. Function GetHashCode: Integer;
  412. Function IndexOf(AValue: UnicodeChar): SizeInt; overload; inline;
  413. Function IndexOf(const AValue: UnicodeString): SizeInt; overload; inline;
  414. Function IndexOf(AValue: UnicodeChar; StartIndex: SizeInt): SizeInt; overload;
  415. Function IndexOf(const AValue: UnicodeString; StartIndex: SizeInt): SizeInt; overload;
  416. Function IndexOf(AValue: UnicodeChar; StartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  417. Function IndexOf(const AValue: UnicodeString; StartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  418. Function IndexOfUnQuoted(const AValue: UnicodeString; StartQuote, EndQuote: UnicodeChar; StartIndex: SizeInt = 0): SizeInt; overload;
  419. Function IndexOfAny(const AnyOf: array of UnicodeChar): SizeInt; overload;
  420. Function IndexOfAny(const AnyOf: array of UnicodeChar; StartIndex: SizeInt): SizeInt; overload;
  421. Function IndexOfAny(const AnyOf: array of UnicodeChar; StartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  422. Function IndexOfAny(const AnyOf: array of UnicodeString): SizeInt; overload;
  423. Function IndexOfAny(const AnyOf: array of UnicodeString; StartIndex: SizeInt): SizeInt; overload;
  424. Function IndexOfAny(const AnyOf: array of UnicodeString; StartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  425. Function IndexOfAny(const AnyOf: array of UnicodeString; StartIndex: SizeInt; ACount: SizeInt; Out AMatch : SizeInt): SizeInt; overload;
  426. Function IndexOfAnyUnquoted(const AnyOf: array of UnicodeChar; StartQuote, EndQuote: UnicodeChar): SizeInt; overload;
  427. Function IndexOfAnyUnquoted(const AnyOf: array of UnicodeChar; StartQuote, EndQuote: UnicodeChar; StartIndex: SizeInt): SizeInt; overload;
  428. Function IndexOfAnyUnquoted(const AnyOf: array of UnicodeChar; StartQuote, EndQuote: UnicodeChar; StartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  429. function IndexOfAnyUnquoted(const AnyOf: array of UnicodeString; StartQuote, EndQuote: UnicodeChar; StartIndex: SizeInt; Out Matched: SizeInt): SizeInt; overload;
  430. Function Insert(StartIndex: SizeInt; const AValue: UnicodeString): UnicodeString;
  431. Function IsDelimiter(const Delimiters: UnicodeString; Index: SizeInt): Boolean;
  432. Function IsEmpty: Boolean;
  433. Function LastDelimiter(const Delims: UnicodeString): SizeInt;
  434. Function LastIndexOf(AValue: UnicodeChar): SizeInt; overload;
  435. Function LastIndexOf(const AValue: UnicodeString): SizeInt; overload;
  436. Function LastIndexOf(AValue: UnicodeChar; AStartIndex: SizeInt): SizeInt; overload;
  437. Function LastIndexOf(const AValue: UnicodeString; AStartIndex: SizeInt): SizeInt; overload;
  438. Function LastIndexOf(AValue: UnicodeChar; AStartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  439. Function LastIndexOf(const AValue: UnicodeString; AStartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  440. Function LastIndexOfAny(const AnyOf: array of UnicodeChar): SizeInt; overload;
  441. Function LastIndexOfAny(const AnyOf: array of UnicodeChar; AStartIndex: SizeInt): SizeInt; overload;
  442. Function LastIndexOfAny(const AnyOf: array of UnicodeChar; AStartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  443. Function PadLeft(ATotalWidth: SizeInt): UnicodeString; overload; inline;
  444. Function PadLeft(ATotalWidth: SizeInt; PaddingChar: UnicodeChar): UnicodeString; overload; inline;
  445. Function PadRight(ATotalWidth: SizeInt): UnicodeString; overload; inline;
  446. Function PadRight(ATotalWidth: SizeInt; PaddingChar: UnicodeChar): UnicodeString; overload; inline;
  447. Function QuotedString: UnicodeString; overload;
  448. Function QuotedString(const AQuoteChar: UnicodeChar): UnicodeString; overload;
  449. Function Remove(StartIndex: SizeInt): UnicodeString; overload; inline;
  450. Function Remove(StartIndex: SizeInt; ACount: SizeInt): UnicodeString; overload; inline;
  451. Function Replace(OldChar: UnicodeChar; NewChar: UnicodeChar): UnicodeString; overload;
  452. Function Replace(OldChar: UnicodeChar; NewChar: UnicodeChar; ReplaceFlags: TReplaceFlags): UnicodeString; overload;
  453. Function Replace(const OldValue: UnicodeString; const NewValue: UnicodeString): UnicodeString; overload;
  454. Function Replace(const OldValue: UnicodeString; const NewValue: UnicodeString; ReplaceFlags: TReplaceFlags): UnicodeString; overload;
  455. Function Split(const Separators: array of UnicodeChar): TUnicodeStringArray; overload;
  456. Function Split(const Separators: array of UnicodeChar; ACount: SizeInt): TUnicodeStringArray; overload;
  457. Function Split(const Separators: array of UnicodeChar; Options: TStringSplitOptions): TUnicodeStringArray; overload;
  458. Function Split(const Separators: array of UnicodeChar; ACount: SizeInt; Options: TStringSplitOptions): TUnicodeStringArray; overload;
  459. Function Split(const Separators: array of UnicodeString): TUnicodeStringArray; overload;
  460. Function Split(const Separators: array of UnicodeString; ACount: SizeInt): TUnicodeStringArray; overload;
  461. Function Split(const Separators: array of UnicodeString; Options: TStringSplitOptions): TUnicodeStringArray; overload;
  462. Function Split(const Separators: array of UnicodeString; ACount: SizeInt; Options: TStringSplitOptions): TUnicodeStringArray; overload;
  463. Function Split(const Separators: array of UnicodeChar; AQuote: UnicodeChar): TUnicodeStringArray; overload;
  464. Function Split(const Separators: array of UnicodeChar; AQuoteStart, AQuoteEnd: UnicodeChar): TUnicodeStringArray; overload;
  465. Function Split(const Separators: array of UnicodeChar; AQuoteStart, AQuoteEnd: UnicodeChar; Options: TStringSplitOptions): TUnicodeStringArray; overload;
  466. Function Split(const Separators: array of UnicodeChar; AQuoteStart, AQuoteEnd: UnicodeChar; ACount: SizeInt): TUnicodeStringArray; overload;
  467. Function Split(const Separators: array of UnicodeChar; AQuoteStart, AQuoteEnd: UnicodeChar; ACount: SizeInt; Options: TStringSplitOptions): TUnicodeStringArray; overload;
  468. Function Split(const Separators: array of UnicodeString; AQuote: UnicodeChar): TUnicodeStringArray; overload;
  469. Function Split(const Separators: array of UnicodeString; AQuoteStart, AQuoteEnd: UnicodeChar): TUnicodeStringArray; overload;
  470. Function Split(const Separators: array of UnicodeString; AQuoteStart, AQuoteEnd: UnicodeChar; Options: TStringSplitOptions): TUnicodeStringArray; overload;
  471. Function Split(const Separators: array of UnicodeString; AQuoteStart, AQuoteEnd: UnicodeChar; ACount: SizeInt): TUnicodeStringArray; overload;
  472. Function Split(const Separators: array of UnicodeString; AQuoteStart, AQuoteEnd: UnicodeChar; ACount: SizeInt; Options: TStringSplitOptions): TUnicodeStringArray; overload;
  473. Function StartsWith(const AValue: UnicodeString): Boolean; overload; inline;
  474. Function StartsWith(const AValue: UnicodeString; IgnoreCase: Boolean): Boolean; overload;
  475. Function Substring(AStartIndex: SizeInt): UnicodeString; overload;
  476. Function Substring(AStartIndex: SizeInt; ALen: SizeInt): UnicodeString; overload;
  477. Function ToBoolean: Boolean; overload; inline;
  478. Function ToInteger: Integer; overload; inline;
  479. Function ToInt64: Int64; overload; inline;
  480. Function ToSingle: Single; overload; inline;
  481. Function ToDouble: Double; overload; inline;
  482. Function ToExtended: Extended; overload; inline;
  483. Function ToCharArray: TCharArray; overload;
  484. Function ToCharArray(AStartIndex: SizeInt; ALen: SizeInt): TCharArray; overload;
  485. Function ToLower: UnicodeString; overload; inline;
  486. Function ToLowerInvariant: UnicodeString;
  487. Function ToUpper: UnicodeString; overload; inline;
  488. Function ToUpperInvariant: UnicodeString; inline;
  489. Function Trim: UnicodeString; overload;
  490. Function TrimLeft: UnicodeString; overload;
  491. Function TrimRight: UnicodeString; overload;
  492. Function Trim(const ATrimChars: array of UnicodeChar): UnicodeString; overload;
  493. Function TrimLeft(const ATrimChars: array of UnicodeChar): UnicodeString; overload;
  494. Function TrimRight(const ATrimChars: array of UnicodeChar): UnicodeString; overload;
  495. Function TrimEnd(const ATrimChars: array of UnicodeChar): UnicodeString; deprecated 'Use TrimRight';
  496. Function TrimStart(const ATrimChars: array of UnicodeChar): UnicodeString; deprecated 'Use TrimLeft';
  497. property Chars[AIndex: SizeInt]: UnicodeChar read GetChar;
  498. property Length: SizeInt read GetLength;
  499. end;
  500. { TShortStringHelper }
  501. TShortStringHelper = Type Helper for ShortString
  502. Private
  503. Function GetChar(AIndex : SizeInt) : AnsiChar;
  504. Function GetLength : SizeInt;
  505. public
  506. const Empty = '';
  507. // Methods
  508. Class Function Compare(const A: ShortString; const B: ShortString): Integer; overload; static; //inline;
  509. Class Function Compare(const A: ShortString; const B: ShortString; IgnoreCase: Boolean): Integer; overload; static; //inline; //deprecated 'Use same with TCompareOptions';
  510. Class Function Compare(const A: ShortString; const B: ShortString; Options: TCompareOptions): Integer; overload; static; // inline;
  511. Class Function Compare(const A: ShortString; IndexA: SizeInt; const B: ShortString; IndexB: SizeInt; ALen: SizeInt): Integer; overload; static; // inline;
  512. Class Function Compare(const A: ShortString; IndexA: SizeInt; const B: ShortString; IndexB: SizeInt; ALen: SizeInt; IgnoreCase: Boolean): Integer; overload; static; // inline; //deprecated 'Use same with TCompareOptions';
  513. Class Function Compare(const A: ShortString; IndexA: SizeInt; const B: ShortString; IndexB: SizeInt; ALen: SizeInt; Options: TCompareOptions): Integer; overload; static;// inline;
  514. Class Function CompareOrdinal(const A: ShortString; const B: ShortString): Integer; overload; static;
  515. Class Function CompareOrdinal(const A: ShortString; IndexA: SizeInt; const B: ShortString; IndexB: SizeInt; ALen: SizeInt): Integer; overload; static;
  516. Class Function CompareText(const A: ShortString; const B: ShortString): Integer; static; inline;
  517. Class Function Copy(const Str: ShortString): ShortString; inline; static;
  518. Class Function Create(AChar: AnsiChar; ACount: SizeInt): ShortString; overload; inline; static;
  519. Class Function Create(const AValue: array of AnsiChar): ShortString; overload; static;
  520. Class Function Create(const AValue: array of AnsiChar; StartIndex: SizeInt; ALen: SizeInt): ShortString; overload; static;
  521. Class Function EndsText(const ASubText, AText: ShortString): Boolean; static;
  522. Class Function Equals(const a: ShortString; const b: ShortString): Boolean; overload; static;
  523. Class Function Format(const AFormat: ShortString; const args: array of const): ShortString; overload; static;
  524. Class Function IsNullOrEmpty(const AValue: ShortString): Boolean; static;
  525. Class Function IsNullOrWhiteSpace(const AValue: ShortString): Boolean; static;
  526. Class Function Join(const Separator: ShortString; const Values: array of const): ShortString; overload; static;
  527. Class Function Join(const Separator: ShortString; const Values: array of ShortString): ShortString; overload; static;
  528. Class Function Join(const Separator: ShortString; const Values: array of ShortString; StartIndex: SizeInt; ACount: SizeInt): ShortString; overload; static;
  529. Class Function LowerCase(const S: ShortString): ShortString; overload; static; inline;
  530. Class Function Parse(const AValue: Boolean): ShortString; overload; static; inline;
  531. Class Function Parse(const AValue: Extended): ShortString; overload; static;inline;
  532. Class Function Parse(const AValue: Int64): ShortString; overload; static; inline;
  533. Class Function Parse(const AValue: Integer): ShortString; overload; static; inline;
  534. Class Function ToBoolean(const S: ShortString): Boolean; overload; static; inline;
  535. Class Function ToDouble(const S: ShortString): Double; overload; static; inline;
  536. Class Function ToExtended(const S: ShortString): Extended; overload; static; inline;
  537. Class Function ToInt64(const S: ShortString): Int64; overload; static; inline;
  538. Class Function ToInteger(const S: ShortString): Integer; overload; static; inline;
  539. Class Function ToSingle(const S: ShortString): Single; overload; static; inline;
  540. Class Function UpperCase(const S: ShortString): ShortString; overload; static; inline;
  541. Function CompareTo(const B: ShortString): Integer;
  542. Function Contains(const AValue: ShortString; IgnoreCase: Boolean = False): Boolean;
  543. procedure CopyTo(SourceIndex: SizeInt; var destination: array of AnsiChar; DestinationIndex: SizeInt; ACount: SizeInt);
  544. Function CountChar(const C: AnsiChar): SizeInt;
  545. Function DeQuotedString: ShortString; overload;
  546. Function DeQuotedString(const AQuoteChar: AnsiChar): ShortString; overload;
  547. Function EndsWith(const AValue: ShortString): Boolean; overload; inline;
  548. Function EndsWith(const AValue: ShortString; IgnoreCase: Boolean): Boolean; overload;
  549. Function Equals(const AValue: ShortString; IgnoreCase: Boolean = False): Boolean; overload;
  550. Function Format(const args: array of const): ShortString; overload;
  551. Function GetHashCode: Integer;
  552. Function IndexOf(AValue: AnsiChar): SizeInt; overload; inline;
  553. Function IndexOf(const AValue: ShortString): SizeInt; overload; inline;
  554. Function IndexOf(AValue: AnsiChar; StartIndex: SizeInt): SizeInt; overload;
  555. Function IndexOf(const AValue: ShortString; StartIndex: SizeInt): SizeInt; overload;
  556. Function IndexOf(AValue: AnsiChar; StartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  557. Function IndexOf(const AValue: ShortString; StartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  558. Function IndexOfUnQuoted(const AValue: ShortString; StartQuote, EndQuote: AnsiChar; StartIndex: SizeInt = 0): SizeInt; overload;
  559. Function IndexOfAny(const AnyOf: array of AnsiChar): SizeInt; overload;
  560. Function IndexOfAny(const AnyOf: array of AnsiChar; StartIndex: SizeInt): SizeInt; overload;
  561. Function IndexOfAny(const AnyOf: array of AnsiChar; StartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  562. Function IndexOfAny(const AnyOf: array of ShortString): SizeInt; overload;
  563. Function IndexOfAny(const AnyOf: array of ShortString; StartIndex: SizeInt): SizeInt; overload;
  564. Function IndexOfAny(const AnyOf: array of ShortString; StartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  565. Function IndexOfAny(const AnyOf: array of ShortString; StartIndex: SizeInt; ACount: SizeInt; Out AMatch : SizeInt): SizeInt; overload;
  566. Function IndexOfAnyUnquoted(const AnyOf: array of AnsiChar; StartQuote, EndQuote: AnsiChar): SizeInt; overload;
  567. Function IndexOfAnyUnquoted(const AnyOf: array of AnsiChar; StartQuote, EndQuote: AnsiChar; StartIndex: SizeInt): SizeInt; overload;
  568. Function IndexOfAnyUnquoted(const AnyOf: array of AnsiChar; StartQuote, EndQuote: AnsiChar; StartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  569. function IndexOfAnyUnquoted(const AnyOf: array of ShortString; StartQuote, EndQuote: AnsiChar; StartIndex: SizeInt; Out Matched: SizeInt): SizeInt; overload;
  570. Function Insert(StartIndex: SizeInt; const AValue: ShortString): ShortString;
  571. Function IsDelimiter(const Delimiters: ShortString; Index: SizeInt): Boolean;
  572. Function IsEmpty: Boolean;
  573. Function LastDelimiter(const Delims: ShortString): SizeInt;
  574. Function LastIndexOf(AValue: AnsiChar): SizeInt; overload;
  575. Function LastIndexOf(const AValue: ShortString): SizeInt; overload;
  576. Function LastIndexOf(AValue: AnsiChar; AStartIndex: SizeInt): SizeInt; overload;
  577. Function LastIndexOf(const AValue: ShortString; AStartIndex: SizeInt): SizeInt; overload;
  578. Function LastIndexOf(AValue: AnsiChar; AStartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  579. Function LastIndexOf(const AValue: ShortString; AStartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  580. Function LastIndexOfAny(const AnyOf: array of AnsiChar): SizeInt; overload;
  581. Function LastIndexOfAny(const AnyOf: array of AnsiChar; AStartIndex: SizeInt): SizeInt; overload;
  582. Function LastIndexOfAny(const AnyOf: array of AnsiChar; AStartIndex: SizeInt; ACount: SizeInt): SizeInt; overload;
  583. Function PadLeft(ATotalWidth: SizeInt): ShortString; overload; inline;
  584. Function PadLeft(ATotalWidth: SizeInt; PaddingChar: AnsiChar): ShortString; overload; inline;
  585. Function PadRight(ATotalWidth: SizeInt): ShortString; overload; inline;
  586. Function PadRight(ATotalWidth: SizeInt; PaddingChar: AnsiChar): ShortString; overload; inline;
  587. Function QuotedString: ShortString; overload;
  588. Function QuotedString(const AQuoteChar: AnsiChar): ShortString; overload;
  589. Function Remove(StartIndex: SizeInt): ShortString; overload; inline;
  590. Function Remove(StartIndex: SizeInt; ACount: SizeInt): ShortString; overload; inline;
  591. Function Replace(OldChar: AnsiChar; NewChar: AnsiChar): ShortString; overload;
  592. Function Replace(OldChar: AnsiChar; NewChar: AnsiChar; ReplaceFlags: TReplaceFlags): ShortString; overload;
  593. Function Replace(const OldValue: ShortString; const NewValue: ShortString): ShortString; overload;
  594. Function Replace(const OldValue: ShortString; const NewValue: ShortString; ReplaceFlags: TReplaceFlags): ShortString; overload;
  595. Function Split(const Separators: array of AnsiChar): TShortStringArray; overload;
  596. Function Split(const Separators: array of AnsiChar; ACount: SizeInt): TShortStringArray; overload;
  597. Function Split(const Separators: array of AnsiChar; Options: TStringSplitOptions): TShortStringArray; overload;
  598. Function Split(const Separators: array of AnsiChar; ACount: SizeInt; Options: TStringSplitOptions): TShortStringArray; overload;
  599. Function Split(const Separators: array of ShortString): TShortStringArray; overload;
  600. Function Split(const Separators: array of ShortString; ACount: SizeInt): TShortStringArray; overload;
  601. Function Split(const Separators: array of ShortString; Options: TStringSplitOptions): TShortStringArray; overload;
  602. Function Split(const Separators: array of ShortString; ACount: SizeInt; Options: TStringSplitOptions): TShortStringArray; overload;
  603. Function Split(const Separators: array of AnsiChar; AQuote: AnsiChar): TShortStringArray; overload;
  604. Function Split(const Separators: array of AnsiChar; AQuoteStart, AQuoteEnd: AnsiChar): TShortStringArray; overload;
  605. Function Split(const Separators: array of AnsiChar; AQuoteStart, AQuoteEnd: AnsiChar; Options: TStringSplitOptions): TShortStringArray; overload;
  606. Function Split(const Separators: array of AnsiChar; AQuoteStart, AQuoteEnd: AnsiChar; ACount: SizeInt): TShortStringArray; overload;
  607. Function Split(const Separators: array of AnsiChar; AQuoteStart, AQuoteEnd: AnsiChar; ACount: SizeInt; Options: TStringSplitOptions): TShortStringArray; overload;
  608. Function Split(const Separators: array of ShortString; AQuote: AnsiChar): TShortStringArray; overload;
  609. Function Split(const Separators: array of ShortString; AQuoteStart, AQuoteEnd: AnsiChar): TShortStringArray; overload;
  610. Function Split(const Separators: array of ShortString; AQuoteStart, AQuoteEnd: AnsiChar; Options: TStringSplitOptions): TShortStringArray; overload;
  611. Function Split(const Separators: array of ShortString; AQuoteStart, AQuoteEnd: AnsiChar; ACount: SizeInt): TShortStringArray; overload;
  612. Function Split(const Separators: array of ShortString; AQuoteStart, AQuoteEnd: AnsiChar; ACount: SizeInt; Options: TStringSplitOptions): TShortStringArray; overload;
  613. Function StartsWith(const AValue: ShortString): Boolean; overload; inline;
  614. Function StartsWith(const AValue: ShortString; IgnoreCase: Boolean): Boolean; overload;
  615. Function Substring(AStartIndex: SizeInt): ShortString; overload;
  616. Function Substring(AStartIndex: SizeInt; ALen: SizeInt): ShortString; overload;
  617. Function ToBoolean: Boolean; overload; inline;
  618. Function ToInteger: Integer; overload; inline;
  619. Function ToInt64: Int64; overload; inline;
  620. Function ToSingle: Single; overload; inline;
  621. Function ToDouble: Double; overload; inline;
  622. Function ToExtended: Extended; overload; inline;
  623. Function ToCharArray: TCharArray; overload;
  624. Function ToCharArray(AStartIndex: SizeInt; ALen: SizeInt): TCharArray; overload;
  625. Function ToLower: ShortString; overload; inline;
  626. Function ToLowerInvariant: ShortString;
  627. Function ToUpper: ShortString; overload; inline;
  628. Function ToUpperInvariant: ShortString; inline;
  629. Function Trim: ShortString; overload;
  630. Function TrimLeft: ShortString; overload;
  631. Function TrimRight: ShortString; overload;
  632. Function Trim(const ATrimChars: array of AnsiChar): ShortString; overload;
  633. Function TrimLeft(const ATrimChars: array of AnsiChar): ShortString; overload;
  634. Function TrimRight(const ATrimChars: array of AnsiChar): ShortString; overload;
  635. Function TrimEnd(const ATrimChars: array of AnsiChar): ShortString; deprecated 'Use TrimRight';
  636. Function TrimStart(const ATrimChars: array of AnsiChar): ShortString; deprecated 'Use TrimLeft';
  637. property Chars[AIndex: SizeInt]: AnsiChar read GetChar;
  638. property Length: SizeInt read GetLength;
  639. end;
  640. {$IFDEF FPC_HAS_TYPE_SINGLE}
  641. TSingleHelper = Type Helper for Single
  642. Private
  643. Function GetB(AIndex: Cardinal): Byte;
  644. Function GetW(AIndex: Cardinal): Word;
  645. Function GetE: QWord; inline;
  646. Function GetF: QWord; inline;
  647. Function GetS: Boolean; inline;
  648. procedure SetB(AIndex: Cardinal; const AValue: Byte);
  649. procedure SetW(AIndex: Cardinal; const AValue: Word);
  650. procedure SetE(AValue: QWord);
  651. procedure SetF(AValue: QWord);
  652. procedure SetS(AValue: Boolean);
  653. public
  654. {$push}
  655. {$R-}
  656. {$Q-}
  657. const
  658. Epsilon : Single = 1.4012984643248170709e-45;
  659. MaxValue : Single = 340282346638528859811704183484516925440.0;
  660. MinValue : Single = -340282346638528859811704183484516925440.0;
  661. PositiveInfinity : Single = 1.0/0.0;
  662. NegativeInfinity : Single = -1.0/0.0;
  663. NaN : Single = 0.0/0.0;
  664. {$POP}
  665. Class Function IsNan(const AValue: Single): Boolean; overload; inline; static;
  666. Class Function IsInfinity(const AValue: Single): Boolean; overload; inline; static;
  667. Class Function IsNegativeInfinity(const AValue: Single): Boolean; overload; inline; static;
  668. Class Function IsPositiveInfinity(const AValue: Single): Boolean; overload; inline; static;
  669. Class Function Parse(const AString: string): Single; overload; inline; static;
  670. Class Function Parse(const AString: string; const AFormatSettings: TFormatSettings): Single; overload; inline; static;
  671. Class Function Size: Integer; inline; static;
  672. Class Function ToString(const AValue: Single): string; overload; inline; static;
  673. Class Function ToString(const AValue: Single; const AFormatSettings: TFormatSettings): string; overload; inline; static;
  674. Class Function ToString(const AValue: Single; const AFormat: TFloatFormat; const APrecision, ADigits: Integer): string; overload; inline; static;
  675. Class Function ToString(const AValue: Single; const AFormat: TFloatFormat; const APrecision, ADigits: Integer;
  676. const AFormatSettings: TFormatSettings): string; overload; inline; static;
  677. Class Function TryParse(const AString: string; out AValue: Single): Boolean; overload; inline; static;
  678. Class Function TryParse(const AString: string; out AValue: Single; const AFormatSettings: TFormatSettings): Boolean; overload; inline; static;
  679. Procedure BuildUp(const ASignFlag: Boolean; const AMantissa: QWord; const AExponent: Integer);
  680. Function Exponent: Integer;
  681. Function Fraction: Extended;
  682. Function IsInfinity: Boolean; overload; inline;
  683. Function IsNan: Boolean; overload; inline;
  684. Function IsNegativeInfinity: Boolean; overload; inline;
  685. Function IsPositiveInfinity: Boolean; overload; inline;
  686. Function Mantissa: QWord;
  687. Function SpecialType: TFloatSpecial;
  688. Function ToString(const AFormat: TFloatFormat; const APrecision, ADigits: Integer): string; overload; inline;
  689. Function ToString(const AFormat: TFloatFormat; const APrecision, ADigits: Integer; const AFormatSettings: TFormatSettings): string; overload; inline;
  690. Function ToString(const AFormatSettings: TFormatSettings): string; overload; inline;
  691. Function ToString: string; overload; inline;
  692. property Bytes [AIndex: Cardinal]: Byte read GetB write SetB;
  693. property Words[AIndex: Cardinal]: Word read GetW write SetW;
  694. property Sign: Boolean read GetS write SetS;
  695. property Exp: QWord read GetE write SetE;
  696. property Frac: QWord read GetF write SetF;
  697. end;
  698. {$ENDIF FPC_HAS_TYPE_SINGLE}
  699. {$IFDEF FPC_HAS_TYPE_DOUBLE}
  700. TDoubleHelper = Type Helper for Double
  701. private
  702. Function GetB(AIndex: Cardinal): Byte;
  703. Function GetW(AIndex: Cardinal): Word;
  704. Function GetE: QWord; inline;
  705. Function GetF: QWord; inline;
  706. Function GetS: Boolean; inline;
  707. procedure SetB(AIndex: Cardinal; const AValue: Byte);
  708. procedure SetW(AIndex: Cardinal; const AValue: Word);
  709. procedure SetE(AValue: QWord);
  710. procedure SetF(AValue: QWord);
  711. procedure SetS(AValue: Boolean);
  712. public
  713. const
  714. {$push}
  715. {$R-}
  716. {$Q-}
  717. Epsilon : Double = 4.9406564584124654418e-324;
  718. MaxValue : Double = 1.7976931348623157081e+308;
  719. MinValue : Double = -1.7976931348623157081e+308;
  720. PositiveInfinity : Double = 1.0/0.0;
  721. NegativeInfinity : Double = -1.0/0.0;
  722. NaN : Double = 0.0/0.0;
  723. {$POP}
  724. Class Function IsInfinity(const AValue: Double): Boolean; overload; inline; static;
  725. Class Function IsNan(const AValue: Double): Boolean; overload; inline; static;
  726. Class Function IsNegativeInfinity(const AValue: Double): Boolean; overload; inline; static;
  727. Class Function IsPositiveInfinity(const AValue: Double): Boolean; overload; inline; static;
  728. Class Function Parse(const AString: string): Double; overload; inline; static;
  729. Class Function Parse(const AString: string; const AFormatSettings: TFormatSettings): Double; overload; inline; static;
  730. Class Function Size: Integer; inline; static;
  731. Class Function ToString(const AValue: Double): string; overload; inline; static;
  732. Class Function ToString(const AValue: Double; const AFormat: TFloatFormat; const APrecision, ADigits: Integer): string; overload; inline; static;
  733. Class Function ToString(const AValue: Double; const AFormat: TFloatFormat; const APrecision, ADigits: Integer; const AFormatSettings: TFormatSettings): string; overload; inline; static;
  734. Class Function ToString(const AValue: Double; const AFormatSettings: TFormatSettings): string; overload; inline; static;
  735. Class Function TryParse(const AString: string; out AValue: Double): Boolean; overload; inline; static;
  736. Class Function TryParse(const AString: string; out AValue: Double; const AFormatSettings: TFormatSettings): Boolean; overload; inline; static;
  737. Procedure BuildUp(const ASignFlag: Boolean; const AMantissa: QWord; const AExponent: Integer);
  738. Function Exponent: Integer;
  739. Function Fraction: Extended;
  740. Function IsInfinity: Boolean; overload; inline;
  741. Function IsNan: Boolean; overload; inline;
  742. Function IsNegativeInfinity: Boolean; overload; inline;
  743. Function IsPositiveInfinity: Boolean; overload; inline;
  744. Function Mantissa: QWord;
  745. Function SpecialType: TFloatSpecial;
  746. Function ToString(const AFormat: TFloatFormat; const APrecision, ADigits: Integer): string; overload; inline;
  747. Function ToString(const AFormat: TFloatFormat; const APrecision, ADigits: Integer; const AFormatSettings: TFormatSettings): string; overload; inline;
  748. Function ToString(const AFormatSettings: TFormatSettings): string; overload; inline;
  749. Function ToString: string; overload; inline;
  750. property Bytes [AIndex: Cardinal]: Byte read GetB write SetB; // 0..7
  751. property Words [AIndex: Cardinal]: Word read GetW write SetW; // 0..3
  752. property Sign: Boolean read GetS write SetS;
  753. property Exp: QWord read GetE write SetE;
  754. property Frac: QWord read GetF write SetF;
  755. end;
  756. {$ENDIF FPC_HAS_TYPE_DOUBLE}
  757. {$ifdef FPC_HAS_TYPE_EXTENDED}
  758. TExtendedHelper = Type Helper for Extended
  759. private
  760. Function GetB(AIndex: Cardinal): Byte;
  761. Function GetW(AIndex: Cardinal): Word;
  762. Function GetE: QWord; inline;
  763. Function GetF: QWord; inline;
  764. Function GetS: Boolean; inline;
  765. procedure SetB(AIndex: Cardinal; const AValue: Byte);
  766. procedure SetW(AIndex: Cardinal; const AValue: Word);
  767. procedure SetE(AValue: QWord);
  768. procedure SetF(AValue: QWord);
  769. procedure SetS(AValue: Boolean);
  770. public
  771. {$push}
  772. {$R-}
  773. {$Q-}
  774. const
  775. Epsilon : Extended = 3.64519953188247460253e-4951;
  776. MaxValue : Extended = 1.18973149535723176505e+4932;
  777. MinValue : Extended = -1.18973149535723176505e+4932;
  778. PositiveInfinity : Extended = 1.0/0.0;
  779. NegativeInfinity : Extended = -1.0/0.0;
  780. NaN : Extended = 0.0/0.0;
  781. {$POP}
  782. Class Function ToString(const AValue: Extended): string; overload; inline; static;
  783. Class Function ToString(const AValue: Extended; const AFormatSettings: TFormatSettings): string; overload; inline; static;
  784. Class Function ToString(const AValue: Extended; const AFormat: TFloatFormat; const APrecision, ADigits: Integer): string; overload; inline; static;
  785. Class Function ToString(const AValue: Extended; const AFormat: TFloatFormat; const APrecision, ADigits: Integer; const AFormatSettings: TFormatSettings): string; overload; inline; static;
  786. Class Function Parse(const AString: string): Extended; overload; inline; static;
  787. Class Function Parse(const AString: string; const AFormatSettings: TFormatSettings): Extended; overload; inline; static;
  788. Class Function TryParse(const AString: string; out AValue: Extended): Boolean; overload; inline; static;
  789. Class Function TryParse(const AString: string; out AValue: Extended; const AFormatSettings: TFormatSettings): Boolean; overload; inline; static;
  790. Class Function IsNan(const AValue: Extended): Boolean; overload; inline; static;
  791. Class Function IsInfinity(const AValue: Extended): Boolean; overload; inline; static;
  792. Class Function IsNegativeInfinity(const AValue: Extended): Boolean; overload; inline; static;
  793. Class Function IsPositiveInfinity(const AValue: Extended): Boolean; overload; inline; static;
  794. Class Function Size: Integer; inline; static;
  795. procedure BuildUp(const ASignFlag: Boolean; const AMantissa: QWord; Const AExponent: Integer);
  796. Function Exponent: Integer;
  797. Function Fraction: Extended;
  798. Function IsInfinity: Boolean; overload; inline;
  799. Function IsNan: Boolean; overload; inline;
  800. Function IsNegativeInfinity: Boolean; overload; inline;
  801. Function IsPositiveInfinity: Boolean; overload; inline;
  802. Function Mantissa: QWord;
  803. Function SpecialType: TFloatSpecial;
  804. Function ToString(const AFormat: TFloatFormat; const APrecision, ADigits: Integer): string; overload; inline;
  805. Function ToString(const AFormat: TFloatFormat; const APrecision, ADigits: Integer; const AFormatSettings: TFormatSettings): string; overload; inline;
  806. Function ToString(const AFormatSettings: TFormatSettings): string; overload; inline;
  807. Function ToString: string; overload; inline;
  808. property Bytes [AIndex: Cardinal]: Byte read GetB write SetB;
  809. property Words [AIndex: Cardinal]: Word read GetW write SetW;
  810. property Sign: Boolean read GetS write SetS;
  811. property Exp: QWord read GetE write SetE;
  812. property Frac: QWord read GetF write SetF;
  813. end;
  814. {$ENDIF FPC_HAS_TYPE_EXTENDED}
  815. nibble = 0..15;
  816. TNibbleBitIndex = 0..3;
  817. // TByteBitIndex is already defined
  818. TByteNibbleIndex = 0..1;
  819. TByteOverlay = bitpacked record case integer of // for fast extraction of bits
  820. 0: (AsBit: bitpacked array[TByteBitIndex] of boolean);
  821. 1: (AsNibble: bitpacked array[TByteNibbleIndex] of nibble);
  822. 2: (AsByte: byte);
  823. end;
  824. TByteHelper = Type Helper for Byte
  825. const
  826. MaxValue = High(byte);
  827. MinValue = Low(byte);
  828. MaxBit = High(TByteBitIndex);
  829. MinBit = Low(TByteBitIndex);
  830. MaxNibble = High(TByteNibbleIndex);
  831. MinNibble = Low(TByteNibbleIndex);
  832. public
  833. Class Function Parse(const AString: string): Byte; inline; static;
  834. Class Function Size: Integer; inline; static;
  835. Class Function ToString(const AValue: Byte): string; overload; inline; static;
  836. Class Function TryParse(const AString: string; out AValue: Byte): Boolean; inline; static;
  837. protected
  838. function GetBit(const aIndex: TByteBitIndex): boolean; inline;
  839. procedure PutBit(const aIndex: TByteBitIndex; const aNewValue: boolean); inline;
  840. function GetNibble(const aIndex: TByteNibbleIndex): nibble; inline;
  841. procedure PutNibble(const aIndex: TByteNibbleIndex; const aNewValue: nibble); inline;
  842. public
  843. Function ToBoolean: Boolean; inline;
  844. Function ToDouble: Double; inline;
  845. Function ToExtended: Extended; inline;
  846. Function ToBinString:string;
  847. Function ToHexString(const AMinDigits: Integer): string; overload; inline;
  848. Function ToHexString: string; overload; inline;
  849. Function ToSingle: Single; inline;
  850. Function ToString: string; overload; inline;
  851. Function SetBit(const Index: TByteBitIndex) : Byte; inline;
  852. Function ClearBit(const Index: TByteBitIndex) : Byte; inline;
  853. Function ToggleBit(const Index: TByteBitIndex) : Byte; inline;
  854. Function TestBit(const Index:TByteBitIndex):Boolean; inline;
  855. procedure Clear; inline;
  856. function HighestSetBitPos: int8; inline;
  857. function LowestSetBitPos: int8; inline;
  858. function SetBitsCount: byte; inline;
  859. property Bits [aIndex: TByteBitIndex]: boolean read GetBit write PutBit;
  860. property Nibbles [aIndex: TByteNibbleIndex]: nibble read GetNibble write PutNibble;
  861. end;
  862. // TShortIntBitIndex is already defined
  863. TShortIntNibbleIndex = TByteNibbleIndex;
  864. TShortIntOverlay = TByteOverlay;
  865. TShortIntHelper = Type Helper for ShortInt
  866. const
  867. MaxValue = High(shortint);
  868. MinValue = Low(shortint);
  869. MaxBit = High(TShortIntBitIndex);
  870. MinBit = Low(TShortIntBitIndex);
  871. MaxNibble = High(TShortIntNibbleIndex);
  872. MinNibble = Low(TShortIntNibbleIndex);
  873. public
  874. Class Function Parse(const AString: string): ShortInt; inline; static;
  875. Class Function Size: Integer; inline; static;
  876. Class Function ToString(const AValue: ShortInt): string; overload; inline; static;
  877. Class Function TryParse(const AString: string; out AValue: ShortInt): Boolean; inline; static;
  878. protected
  879. function GetBit(const aIndex: TShortIntBitIndex): boolean; inline;
  880. procedure PutBit(const aIndex: TShortIntBitIndex; const aNewValue: boolean); inline;
  881. function GetNibble(const aIndex: TShortIntNibbleIndex): nibble; inline;
  882. procedure PutNibble(const aIndex: TShortIntNibbleIndex; const aNewValue: nibble); inline;
  883. public
  884. Function ToBoolean: Boolean; inline;
  885. Function ToDouble: Double; inline;
  886. Function ToExtended: Extended; inline;
  887. Function ToBinString:string; inline;
  888. Function ToHexString(const AMinDigits: Integer): string; overload; inline;
  889. Function ToHexString: string; overload; inline;
  890. Function ToSingle: Single; inline;
  891. Function ToString: string; overload; inline;
  892. Function SetBit(const Index: TShortIntBitIndex): Shortint; inline;
  893. Function ClearBit(const Index: TShortIntBitIndex): Shortint; inline;
  894. Function ToggleBit(const Index: TShortIntBitIndex): Shortint; inline;
  895. Function TestBit(const Index:TShortIntBitIndex):Boolean;
  896. procedure Clear; inline;
  897. function HighestSetBitPos: int8; inline;
  898. function LowestSetBitPos: int8; inline;
  899. function SetBitsCount: byte; inline;
  900. property Bits [aIndex: TShortIntBitIndex]: boolean read GetBit write PutBit;
  901. property Nibbles [aIndex: TShortIntNibbleIndex]: nibble read GetNibble write PutNibble;
  902. end;
  903. // TWordBitIndex is already defined
  904. TWordByteIndex = 0..1;
  905. TWordNibbleIndex = 0..3;
  906. TWordOverlay = bitpacked record case integer of // for fast extraction of bytes and bits
  907. 0: (AsBit: bitpacked array[TWordBitIndex] of boolean);
  908. 1: (AsNibble: bitpacked array[TWordNibbleIndex] of nibble);
  909. 2: (AsByte: array[TWordByteIndex] of byte);
  910. 3: (AsWord: word);
  911. // recursive overlay:
  912. 4: (AsByteOverlay: array[TWordByteIndex] of TByteOverlay);
  913. end;
  914. TWordHelper = Type Helper for Word
  915. const
  916. MaxValue = High(word);
  917. MinValue = Low(word);
  918. MaxBit = High(TWordBitIndex);
  919. MinBit = Low(TWordBitIndex);
  920. MaxNibble = High(TWordNibbleIndex);
  921. MinNibble = Low(TWordNibbleIndex);
  922. MaxByte = High(TWordByteIndex);
  923. MinByte = Low(TWordByteIndex);
  924. public
  925. Class Function Parse(const AString: string): Word; inline; static;
  926. Class Function Size: Integer; inline; static;
  927. Class Function ToString(const AValue: Word): string; overload; inline; static;
  928. Class Function TryParse(const AString: string; out AValue: Word): Boolean; inline; static;
  929. protected
  930. function GetBit(const aIndex: TWordBitIndex): boolean; inline;
  931. procedure PutBit(const aIndex: TWordBitIndex; const aNewValue: boolean); inline;
  932. function GetNibble(const aIndex: TWordNibbleIndex): nibble; inline;
  933. procedure PutNibble(const aIndex: TWordNibbleIndex; const aNewValue: nibble); inline;
  934. function GetByte(const aIndex: TWordByteIndex): byte;
  935. procedure PutByte(const aIndex: TWordByteIndex; const aNewValue: byte);
  936. public
  937. Function ToBoolean: Boolean; inline;
  938. Function ToDouble: Double; inline;
  939. Function ToExtended: Extended; inline;
  940. Function ToBinString:string; inline;
  941. Function ToHexString(const AMinDigits: Integer): string; overload; inline;
  942. Function ToHexString: string; overload; inline;
  943. Function ToSingle: Single; inline;
  944. Function ToString: string; overload; inline;
  945. Function SetBit(const Index: TWordBitIndex) : Word; inline;
  946. Function ClearBit(const Index: TWordBitIndex) : Word; inline;
  947. Function ToggleBit(const Index: TWordBitIndex) : Word; inline;
  948. Function TestBit(const Index:TWordBitIndex):Boolean; inline;
  949. procedure Clear; inline;
  950. function HighestSetBitPos: int8; inline;
  951. function LowestSetBitPos: int8; inline;
  952. function SetBitsCount: byte; inline;
  953. property Bits [aIndex: TWordBitIndex]: boolean read GetBit write PutBit;
  954. property Nibbles [aIndex: TWordNibbleIndex]: nibble read GetNibble write PutNibble;
  955. property Bytes [aIndex: TWordByteIndex]: byte read GetByte write PutByte;
  956. end;
  957. // TSmallIntBitIndex is already defined
  958. TSmallIntByteIndex = TWordByteIndex;
  959. TSmallIntNibbleIndex = TWordNibbleIndex;
  960. TSmallIntOverlay = TWordOverlay;
  961. TSmallIntHelper = Type Helper for SmallInt
  962. const
  963. MaxValue = High(SmallInt);
  964. MinValue = Low(SmallInt);
  965. MaxBit = High(TSmallIntBitIndex);
  966. MinBit = Low(TSmallIntBitIndex);
  967. MaxNibble = High(TSmallIntNibbleIndex);
  968. MinNibble = Low(TSmallIntNibbleIndex);
  969. MaxByte = High(TSmallIntByteIndex);
  970. MinByte = Low(TSmallIntByteIndex);
  971. public
  972. Class Function Parse(const AString: string): SmallInt; inline; static;
  973. Class Function Size: Integer; inline; static;
  974. Class Function ToString(const AValue: SmallInt): string; overload; inline; static;
  975. Class Function TryParse(const AString: string; out AValue: SmallInt): Boolean; inline; static;
  976. protected
  977. function GetBit(const aIndex: TSmallIntBitIndex): boolean; inline;
  978. procedure PutBit(const aIndex: TSmallIntBitIndex; const aNewValue: boolean); inline;
  979. function GetNibble(const aIndex: TSmallIntNibbleIndex): nibble; inline;
  980. procedure PutNibble(const aIndex: TSmallIntNibbleIndex; const aNewValue: nibble); inline;
  981. function GetByte(const aIndex: TSmallIntByteIndex): byte;
  982. procedure PutByte(const aIndex: TSmallIntByteIndex; const aNewValue: byte);
  983. public
  984. Function ToString: string; overload; inline;
  985. Function ToBoolean: Boolean; inline;
  986. Function ToBinString:string; inline;
  987. Function ToHexString: string; overload; inline;
  988. Function ToHexString(const AMinDigits: Integer): string; overload; inline;
  989. Function ToSingle: Single; inline;
  990. Function ToDouble: Double; inline;
  991. Function ToExtended: Extended; inline;
  992. Function SetBit(const Index: TSmallIntBitIndex) : Smallint; inline;
  993. Function ClearBit(const Index: TSmallIntBitIndex) : Smallint; inline;
  994. Function ToggleBit(const Index: TSmallIntBitIndex) : Smallint; inline;
  995. Function TestBit(const Index:TSmallIntBitIndex):Boolean;
  996. procedure Clear; inline;
  997. function HighestSetBitPos: int8; inline;
  998. function LowestSetBitPos: int8; inline;
  999. function SetBitsCount: byte; inline;
  1000. property Bits [aIndex: TSmallIntBitIndex]: boolean read GetBit write PutBit;
  1001. property Nibbles [aIndex: TSmallIntNibbleIndex]: nibble read GetNibble write PutNibble;
  1002. property Bytes [aIndex: TSmallIntByteIndex]: byte read GetByte write PutByte;
  1003. end;
  1004. TDwordBitIndex = TCardinalBitIndex;
  1005. TDwordNibbleIndex = 0..7;
  1006. TDwordByteIndex = 0..3;
  1007. TDwordWordIndex = 0..1;
  1008. TDwordOverlay = bitpacked record case integer of // for fast extraction of words, bytes and bits
  1009. 0: (AsBit: bitpacked array[TDwordBitIndex] of boolean);
  1010. 1: (AsNibble: bitpacked array[TDwordNibbleIndex] of nibble);
  1011. 2: (AsByte: array[TDwordByteIndex] of byte);
  1012. 3: (AsWord: array[TDwordWordIndex] of word);
  1013. 4: (AsDword: dword);
  1014. // recursive overlays:
  1015. 5: (AsByteOverlay: array[TDwordByteIndex] of TByteOverlay);
  1016. 6: (AsWordOverlay: array[TDwordWordIndex] of TWordOverlay);
  1017. end;
  1018. // TCardinalBitIndex is already defined
  1019. TCardinalNibbleIndex = TDwordNibbleIndex;
  1020. TCardinalByteIndex = TDwordByteIndex;
  1021. TCardinalWordIndex = TDwordWordIndex;
  1022. TCardinalOverlay = TDwordOverlay;
  1023. TCardinalHelper = Type Helper for Cardinal { for LongWord Type too }
  1024. const
  1025. MaxValue = High(Cardinal);
  1026. MinValue = Low(Cardinal);
  1027. MaxBit = High(TCardinalBitIndex);
  1028. MinBit = Low(TCardinalBitIndex);
  1029. MaxNibble = High(TCardinalNibbleIndex);
  1030. MinNibble = Low(TCardinalNibbleIndex);
  1031. MaxByte = High(TCardinalByteIndex);
  1032. MinByte = Low(TCardinalByteIndex);
  1033. MaxWord = High(TCardinalWordIndex);
  1034. MinWord = Low(TCardinalWordIndex);
  1035. public
  1036. Class Function Parse(const AString: string): Cardinal; inline; static;
  1037. Class Function Size: Integer; inline; static;
  1038. Class Function ToString(const AValue: Cardinal): string; overload; inline; static;
  1039. Class Function TryParse(const AString: string; out AValue: Cardinal): Boolean; inline; static;
  1040. protected
  1041. function GetBit(const aIndex: TCardinalBitIndex): boolean; inline;
  1042. procedure PutBit(const aIndex: TCardinalBitIndex; const aNewValue: boolean); inline;
  1043. function GetNibble(const aIndex: TCardinalNibbleIndex): nibble; inline;
  1044. procedure PutNibble(const aIndex: TCardinalNibbleIndex; const aNewValue: nibble); inline;
  1045. function GetByte(const aIndex: TCardinalByteIndex): byte;
  1046. procedure PutByte(const aIndex: TCardinalByteIndex; const aNewValue: byte);
  1047. function GetWord(const aIndex: TCardinalWordIndex): word;
  1048. procedure PutWord(const aIndex: TCardinalWordIndex; const aNewValue: word);
  1049. public
  1050. Function ToBoolean: Boolean; inline;
  1051. Function ToDouble: Double; inline;
  1052. Function ToExtended: Extended; inline;
  1053. Function ToBinString:string; inline;
  1054. Function ToHexString(const AMinDigits: Integer): string; overload; inline;
  1055. Function ToHexString: string; overload; inline;
  1056. Function ToSingle: Single; inline;
  1057. Function ToString: string; overload; inline;
  1058. Function SetBit(const Index: TCardinalBitIndex) : Cardinal; inline;
  1059. Function ClearBit(const Index: TCardinalBitIndex) : Cardinal; inline;
  1060. Function ToggleBit(const Index: TCardinalBitIndex) : Cardinal; inline;
  1061. Function TestBit(const Index:TCardinalBitIndex):Boolean; inline;
  1062. procedure Clear; inline;
  1063. function HighestSetBitPos: int8; inline;
  1064. function LowestSetBitPos: int8; inline;
  1065. function SetBitsCount: byte; inline;
  1066. property Bits [aIndex: TCardinalBitIndex]: boolean read GetBit write PutBit;
  1067. property Nibbles[aIndex: TCardinalNibbleIndex]: nibble read GetNibble write PutNibble;
  1068. property Bytes [aIndex: TCardinalByteIndex]: byte read GetByte write PutByte;
  1069. property Words [aIndex: TCardinalWordIndex]: word read GetWord write PutWord;
  1070. end;
  1071. // TIntegerBitIndex is already defined
  1072. {$if sizeof(Integer)=2}
  1073. TIntegerNibbleIndex = TWordNibbleIndex;
  1074. TIntegerByteIndex = TWordByteIndex;
  1075. TIntegerOverlay = TWordOverlay;
  1076. {$elseif sizeof(Integer)=4}
  1077. TIntegerNibbleIndex = TDwordNibbleIndex;
  1078. TIntegerByteIndex = TDwordByteIndex;
  1079. TIntegerWordIndex = TDwordWordIndex;
  1080. TIntegerOverlay = TDwordOverlay;
  1081. {$else}
  1082. {$fatal Unsupported Integer type size}
  1083. {$endif}
  1084. TIntegerHelper = Type Helper for Integer
  1085. const
  1086. MaxValue = High(integer);
  1087. MinValue = Low(integer);
  1088. MaxBit = High(TIntegerBitIndex);
  1089. MinBit = Low(TIntegerBitIndex);
  1090. MaxNibble = High(TIntegerNibbleIndex);
  1091. MinNibble = Low(TIntegerNibbleIndex);
  1092. MaxByte = High(TIntegerByteIndex);
  1093. MinByte = Low(TIntegerByteIndex);
  1094. {$if sizeof(Integer)>=4}
  1095. MaxWord = High(TIntegerWordIndex);
  1096. MinWord = Low(TIntegerWordIndex);
  1097. {$endif}
  1098. public
  1099. Class Function Size: Integer; inline; static;
  1100. Class Function ToString(const AValue: Integer): string; overload; inline; static;
  1101. Class Function Parse(const AString: string): Integer; inline; static;
  1102. Class Function TryParse(const AString: string; out AValue: Integer): Boolean; inline; static;
  1103. protected
  1104. function GetBit(const aIndex: TIntegerBitIndex): boolean; inline;
  1105. procedure PutBit(const aIndex: TIntegerBitIndex; const aNewValue: boolean); inline;
  1106. function GetNibble(const aIndex: TIntegerNibbleIndex): nibble; inline;
  1107. procedure PutNibble(const aIndex: TIntegerNibbleIndex; const aNewValue: nibble); inline;
  1108. function GetByte(const aIndex: TIntegerByteIndex): byte;
  1109. procedure PutByte(const aIndex: TIntegerByteIndex; const aNewValue: byte);
  1110. {$if sizeof(Integer)>=4}
  1111. function GetWord(const aIndex: TIntegerWordIndex): word;
  1112. procedure PutWord(const aIndex: TIntegerWordIndex; const aNewValue: word);
  1113. {$endif}
  1114. public
  1115. Function ToBoolean: Boolean; inline;
  1116. Function ToDouble: Double; inline;
  1117. Function ToExtended: Extended; inline;
  1118. Function ToBinString:string; inline;
  1119. Function ToHexString(const AMinDigits: Integer): string; overload; inline;
  1120. Function ToHexString: string; overload; inline;
  1121. Function ToSingle: Single; inline;
  1122. Function ToString: string; overload; inline;
  1123. Function SetBit(const Index: TIntegerBitIndex) : Integer; inline;
  1124. Function ClearBit(const Index: TIntegerBitIndex) : Integer; inline;
  1125. Function ToggleBit(const Index: TIntegerBitIndex) : Integer; inline;
  1126. Function TestBit(const Index:TIntegerBitIndex):Boolean; inline;
  1127. procedure Clear; inline;
  1128. function HighestSetBitPos: int8; inline;
  1129. function LowestSetBitPos: int8; inline;
  1130. function SetBitsCount: byte; inline;
  1131. property Bits [aIndex: TIntegerBitIndex]: boolean read GetBit write PutBit;
  1132. property Nibbles[aIndex: TIntegerNibbleIndex]: nibble read GetNibble write PutNibble;
  1133. property Bytes [aIndex: TIntegerByteIndex]: byte read GetByte write PutByte;
  1134. {$if sizeof(Integer)>=4}
  1135. property Words [aIndex: TIntegerWordIndex]: word read GetWord write PutWord;
  1136. {$endif}
  1137. end;
  1138. // TLongIntBitIndex is already defined
  1139. TLongIntNibbleIndex = TDwordNibbleIndex;
  1140. TLongIntByteIndex = TDwordByteIndex;
  1141. TLongIntWordIndex = TDwordWordIndex;
  1142. TLongIntOverlay = TDwordOverlay;
  1143. TLongIntHelper = Type Helper for LongInt
  1144. const
  1145. MaxValue = High(LongInt);
  1146. MinValue = Low(LongInt);
  1147. MaxBit = High(TLongIntBitIndex);
  1148. MinBit = Low(TLongIntBitIndex);
  1149. MaxNibble = High(TLongIntNibbleIndex);
  1150. MinNibble = Low(TLongIntNibbleIndex);
  1151. MaxByte = High(TLongIntByteIndex);
  1152. MinByte = Low(TLongIntByteIndex);
  1153. MaxWord = High(TLongIntWordIndex);
  1154. MinWord = Low(TLongIntWordIndex);
  1155. public
  1156. Class Function Size: Integer; inline; static;
  1157. Class Function ToString(const AValue: LongInt): string; overload; inline; static;
  1158. Class Function Parse(const AString: string): LongInt; inline; static;
  1159. Class Function TryParse(const AString: string; out AValue: LongInt): Boolean; inline; static;
  1160. protected
  1161. function GetBit(const aIndex: TLongIntBitIndex): boolean; inline;
  1162. procedure PutBit(const aIndex: TLongIntBitIndex; const aNewValue: boolean); inline;
  1163. function GetNibble(const aIndex: TLongIntNibbleIndex): nibble; inline;
  1164. procedure PutNibble(const aIndex: TLongIntNibbleIndex; const aNewValue: nibble); inline;
  1165. function GetByte(const aIndex: TLongIntByteIndex): byte;
  1166. procedure PutByte(const aIndex: TLongIntByteIndex; const aNewValue: byte);
  1167. function GetWord(const aIndex: TLongIntWordIndex): word;
  1168. procedure PutWord(const aIndex: TLongIntWordIndex; const aNewValue: word);
  1169. public
  1170. Function ToBoolean: Boolean; inline;
  1171. Function ToDouble: Double; inline;
  1172. Function ToExtended: Extended; inline;
  1173. Function ToBinString:string; inline;
  1174. Function ToHexString(const AMinDigits: Integer): string; overload; inline;
  1175. Function ToHexString: string; overload; inline;
  1176. Function ToSingle: Single; inline;
  1177. Function ToString: string; overload; inline;
  1178. Function SetBit(const Index: TLongIntBitIndex) : LongInt; inline;
  1179. Function ClearBit(const Index: TLongIntBitIndex) : LongInt; inline;
  1180. Function ToggleBit(const Index: TLongIntBitIndex) : LongInt; inline;
  1181. Function TestBit(const Index:TLongIntBitIndex):Boolean; inline;
  1182. procedure Clear; inline;
  1183. function HighestSetBitPos: int8; inline;
  1184. function LowestSetBitPos: int8; inline;
  1185. function SetBitsCount: byte; inline;
  1186. property Bits [aIndex: TLongIntBitIndex]: boolean read GetBit write PutBit;
  1187. property Nibbles[aIndex: TLongIntNibbleIndex]: nibble read GetNibble write PutNibble;
  1188. property Bytes [aIndex: TLongIntByteIndex]: byte read GetByte write PutByte;
  1189. property Words [aIndex: TLongIntWordIndex]: word read GetWord write PutWord;
  1190. end;
  1191. // TQwordBitIndex is already defined
  1192. TQwordNibbleIndex = 0..15;
  1193. TQwordByteIndex = 0..7;
  1194. TQwordWordIndex = 0..3;
  1195. TQwordDwordIndex = 0..1;
  1196. TQwordOverlay = bitpacked record case integer of // for fast extraction of longwords, words, bytes and bits
  1197. 0: (AsBit: bitpacked array[TQwordBitIndex] of boolean);
  1198. 1: (AsNibble: bitpacked array[TQwordNibbleIndex] of nibble);
  1199. 2: (AsByte: array[TQwordByteIndex] of byte);
  1200. 3: (AsWord: array[TQwordWordIndex] of word);
  1201. 4: (AsDword: array[TQwordDwordIndex] of dword);
  1202. 5: (AsQword: qword);
  1203. // recursive overlays:
  1204. 6: (AsByteOverlay: array[TQwordByteIndex] of TByteOverlay);
  1205. 7: (AsWordOverlay: array[TQwordWordIndex] of TWordOverlay);
  1206. 8: (AsDwordOverlay: array[TQwordDwordIndex] of TDwordOverlay);
  1207. end;
  1208. TQWordHelper = Type Helper for QWord
  1209. const
  1210. MaxValue = High(qword);
  1211. MinValue = Low(qword);
  1212. MaxBit = High(TQwordBitIndex);
  1213. MinBit = Low(TQwordBitIndex);
  1214. MaxNibble = High(TQwordNibbleIndex);
  1215. MinNibble = Low(TQwordNibbleIndex);
  1216. MaxByte = High(TQwordByteIndex);
  1217. MinByte = Low(TQwordByteIndex);
  1218. MaxWord = High(TQwordWordIndex);
  1219. MinWord = Low(TQwordWordIndex);
  1220. MaxDword = High(TQwordDwordIndex);
  1221. MinDword = Low(TQwordDwordIndex);
  1222. public
  1223. Class Function Parse(const AString: string): Qword; inline; static;
  1224. Class Function Size: Integer; inline; static;
  1225. Class Function ToString(const AValue: Qword): string; overload; inline; static;
  1226. Class Function TryParse(const AString: string; out AValue: Qword): Boolean; inline; static;
  1227. protected
  1228. function GetBit(const aIndex: TQwordBitIndex): boolean; inline;
  1229. procedure PutBit(const aIndex: TQwordBitIndex; const aNewValue: boolean); inline;
  1230. function GetNibble(const aIndex: TQwordNibbleIndex): nibble; inline;
  1231. procedure PutNibble(const aIndex: TQwordNibbleIndex; const aNewValue: nibble); inline;
  1232. function GetByte(const aIndex: TQwordByteIndex): byte;
  1233. procedure PutByte(const aIndex: TQwordByteIndex; const aNewValue: byte);
  1234. function GetWord(const aIndex: TQwordWordIndex): word;
  1235. procedure PutWord(const aIndex: TQwordWordIndex; const aNewValue: word);
  1236. function GetDword(const aIndex: TQwordDwordIndex): dword;
  1237. procedure PutDword(const aIndex: TQwordDwordIndex; const aNewValue: dword);
  1238. public
  1239. Function ToBoolean: Boolean; inline;
  1240. Function ToDouble: Double; inline;
  1241. Function ToExtended: Extended; inline;
  1242. Function ToBinString:string; inline;
  1243. Function ToHexString(const AMinDigits: Integer): string; overload; inline;
  1244. Function ToHexString: string; overload; inline;
  1245. Function ToSingle: Single; inline;
  1246. Function ToString: string; overload; inline;
  1247. Function SetBit(const Index: TQwordBitIndex): Qword; inline;
  1248. Function ClearBit(const Index: TQwordBitIndex): Qword; inline;
  1249. Function ToggleBit(const Index: TQwordBitIndex): Qword; inline;
  1250. Function TestBit(const Index:TQwordBitIndex): Boolean; inline;
  1251. procedure Clear; inline;
  1252. function HighestSetBitPos: int8; inline;
  1253. function LowestSetBitPos: int8; inline;
  1254. function SetBitsCount: byte; inline;
  1255. property Bits [aIndex: TQwordBitIndex]: boolean read GetBit write PutBit;
  1256. property Nibbles[aIndex: TQwordNibbleIndex]: nibble read GetNibble write PutNibble;
  1257. property Bytes [aIndex: TQwordByteIndex]: byte read GetByte write PutByte;
  1258. property Words [aIndex: TQwordWordIndex]: word read GetWord write PutWord;
  1259. property DWords [aIndex: TQwordDwordIndex]: dword read GetDWord write PutDWord;
  1260. end;
  1261. // TInt64BitIndex is already defined
  1262. TInt64NibbleIndex = TQwordNibbleIndex;
  1263. TInt64ByteIndex = TQwordByteIndex;
  1264. TInt64WordIndex = TQwordWordIndex;
  1265. TInt64DwordIndex = TQwordDwordIndex;
  1266. TInt64Overlay = TQwordOverlay;
  1267. TInt64Helper = Type Helper for Int64
  1268. const
  1269. MaxValue = High(int64);
  1270. MinValue = Low(int64);
  1271. MaxBit = High(TInt64BitIndex);
  1272. MinBit = Low(TInt64BitIndex);
  1273. MaxNibble = High(TInt64NibbleIndex);
  1274. MinNibble = Low(TInt64NibbleIndex);
  1275. MaxByte = High(TInt64ByteIndex);
  1276. MinByte = Low(TInt64ByteIndex);
  1277. MaxWord = High(TInt64WordIndex);
  1278. MinWord = Low(TInt64WordIndex);
  1279. MaxDword = High(TInt64DwordIndex);
  1280. MinDword = Low(TInt64DwordIndex);
  1281. public
  1282. Class Function Parse(const AString: string): Int64; inline; static;
  1283. Class Function Size: Integer; inline; static;
  1284. Class Function ToString(const AValue: Int64): string; overload; inline; static;
  1285. Class Function TryParse(const AString: string; out AValue: Int64): Boolean; inline; static;
  1286. protected
  1287. function GetBit(const aIndex: TInt64BitIndex): boolean; inline;
  1288. procedure PutBit(const aIndex: TInt64BitIndex; const aNewValue: boolean); inline;
  1289. function GetNibble(const aIndex: TInt64NibbleIndex): nibble; inline;
  1290. procedure PutNibble(const aIndex: TInt64NibbleIndex; const aNewValue: nibble); inline;
  1291. function GetByte(const aIndex: TInt64ByteIndex): byte;
  1292. procedure PutByte(const aIndex: TInt64ByteIndex; const aNewValue: byte);
  1293. function GetWord(const aIndex: TInt64WordIndex): word;
  1294. procedure PutWord(const aIndex: TInt64WordIndex; const aNewValue: word);
  1295. function GetDword(const aIndex: TInt64DwordIndex): dword;
  1296. procedure PutDword(const aIndex: TInt64DwordIndex; const aNewValue: dword);
  1297. public
  1298. Function ToBoolean: Boolean; inline;
  1299. Function ToDouble: Double; inline;
  1300. Function ToExtended: Extended; inline;
  1301. Function ToBinString:string; inline;
  1302. Function ToHexString(const AMinDigits: Integer): string; overload; inline;
  1303. Function ToHexString: string; overload; inline;
  1304. Function ToSingle: Single; inline;
  1305. Function ToString: string; overload; inline;
  1306. Function SetBit(const Index: TInt64BitIndex) : Int64; inline;
  1307. Function ClearBit(const Index: TInt64BitIndex) : Int64; inline;
  1308. Function ToggleBit(const Index: TInt64BitIndex) : Int64; inline;
  1309. Function TestBit(const Index: TInt64BitIndex): Boolean; inline;
  1310. procedure Clear; inline;
  1311. function HighestSetBitPos: int8; inline;
  1312. function LowestSetBitPos: int8; inline;
  1313. function SetBitsCount: byte; inline;
  1314. property Bits [aIndex: TInt64BitIndex]: boolean read GetBit write PutBit;
  1315. property Nibbles[aIndex: TInt64NibbleIndex]: nibble read GetNibble write PutNibble;
  1316. property Bytes [aIndex: TInt64ByteIndex]: byte read GetByte write PutByte;
  1317. property Words [aIndex: TInt64WordIndex]: word read GetWord write PutWord;
  1318. property DWords [aIndex: TInt64DwordIndex]: dword read GetDWord write PutDWord;
  1319. end;
  1320. // TNativeIntBitIndex is already defined
  1321. {$if sizeof(NativeInt)=2}
  1322. TNativeIntNibbleIndex = TSmallIntNibbleIndex;
  1323. TNativeIntByteIndex = TSmallIntByteIndex;
  1324. TNativeIntOverlay = TSmallIntOverlay;
  1325. {$elseif sizeof(NativeInt)=4}
  1326. TNativeIntNibbleIndex = TLongIntNibbleIndex;
  1327. TNativeIntByteIndex = TLongIntByteIndex;
  1328. TNativeIntWordIndex = TLongIntWordIndex;
  1329. TNativeIntOverlay = TLongIntOverlay;
  1330. {$elseif sizeof(NativeInt)=8}
  1331. TNativeIntNibbleIndex = TInt64NibbleIndex;
  1332. TNativeIntByteIndex = TInt64ByteIndex;
  1333. TNativeIntWordIndex = TInt64WordIndex;
  1334. TNativeIntDwordIndex = TInt64DWordIndex;
  1335. TNativeIntOverlay = TInt64Overlay;
  1336. {$else}
  1337. {$fatal Unsupported NativeInt type size}
  1338. {$endif}
  1339. TNativeIntHelper = Type Helper for NativeInt
  1340. const
  1341. MaxValue = High(NativeInt);
  1342. MinValue = Low(NativeInt);
  1343. MaxBit = High(TNativeIntBitIndex);
  1344. MinBit = Low(TNativeIntBitIndex);
  1345. MaxNibble = High(TNativeIntNibbleIndex);
  1346. MinNibble = Low(TNativeIntNibbleIndex);
  1347. // NativeInt on cpu16 has 2 bytes, so no need for cpu16 check because we always need MaxByte and MinByte
  1348. MaxByte = High(TNativeIntByteIndex);
  1349. MinByte = Low(TNativeIntByteIndex);
  1350. {$if sizeof(NativeInt)>=4}
  1351. MaxWord = High(TNativeIntWordIndex);
  1352. MinWord = Low(TNativeIntWordIndex);
  1353. {$endif}
  1354. {$ifdef sizeof(NativeInt)>=8}
  1355. MaxDword = High(TNativeIntDwordIndex);
  1356. MinDword = Low(TNativeIntDwordIndex);
  1357. {$endif}
  1358. public
  1359. Class Function Parse(const AString: string): NativeInt; inline; static;
  1360. Class Function Size: Integer; inline; static;
  1361. Class Function ToString(const AValue: NativeInt): string; overload; inline; static;
  1362. Class Function TryParse(const AString: string; out AValue: NativeInt): Boolean; inline; static;
  1363. protected
  1364. function GetBit(const aIndex: TNativeIntBitIndex): boolean; inline;
  1365. procedure PutBit(const aIndex: TNativeIntBitIndex; const aNewValue: boolean); inline;
  1366. function GetNibble(const aIndex: TNativeIntNibbleIndex): nibble; inline;
  1367. procedure PutNibble(const aIndex: TNativeIntNibbleIndex; const aNewValue: nibble); inline;
  1368. // NativeInt on cpu16 has 2 bytes, so no need for cpu16 check because we always need GetByte and PutByte
  1369. function GetByte(const aIndex: TNativeIntByteIndex): byte;
  1370. procedure PutByte(const aIndex: TNativeIntByteIndex; const aNewValue: byte);
  1371. {$if sizeof(NativeInt)>=4}
  1372. function GetWord(const aIndex: TNativeIntWordIndex): word;
  1373. procedure PutWord(const aIndex: TNativeIntWordIndex; const aNewValue: word);
  1374. {$endif}
  1375. {$if sizeof(NativeInt)>=8}
  1376. function GetDword(const aIndex: TNativeIntDwordIndex): dword;
  1377. procedure PutDword(const aIndex: TNativeIntDwordIndex; const aNewValue: dword);
  1378. {$endif}
  1379. public
  1380. Function ToBoolean: Boolean; inline;
  1381. Function ToDouble: Double; inline;
  1382. Function ToExtended: Extended; inline;
  1383. Function ToBinString:string; inline;
  1384. Function ToHexString(const AMinDigits: Integer): string; overload; inline;
  1385. Function ToHexString: string; overload; inline;
  1386. Function ToSingle: Single; inline;
  1387. Function ToString: string; overload; inline;
  1388. Function SetBit(const Index: TNativeIntBitIndex) : NativeInt; inline;
  1389. Function ClearBit(const Index: TNativeIntBitIndex) : NativeInt; inline;
  1390. Function ToggleBit(const Index: TNativeIntBitIndex) : NativeInt; inline;
  1391. Function TestBit(const Index:TNativeIntBitIndex):Boolean; inline;
  1392. procedure Clear; inline;
  1393. function HighestSetBitPos: int8; inline;
  1394. function LowestSetBitPos: int8; inline;
  1395. function SetBitsCount: byte; inline;
  1396. property Bits [aIndex: TNativeIntBitIndex]: boolean read GetBit write PutBit;
  1397. property Nibbles [aIndex: TNativeIntNibbleIndex]: nibble read GetNibble write PutNibble;
  1398. // NativeInt on cpu16 has 2 bytes, so no need for cpu16 check because we always need Byte[]
  1399. property Bytes [aIndex: TNativeIntByteIndex]: byte read GetByte write PutByte;
  1400. {$if sizeof(NativeInt)>=4}
  1401. property Words [aIndex: TNativeIntWordIndex]: word read GetWord write PutWord;
  1402. {$endif}
  1403. {$if sizeof(NativeInt)>=8}
  1404. property DWords [aIndex: TNativeIntDwordIndex]: dword read GetDWord write PutDWord;
  1405. {$endif}
  1406. end;
  1407. // TNativeUIntBitIndex is already defined
  1408. {$if sizeof(NativeUInt)=2}
  1409. TNativeUIntNibbleIndex = TWordNibbleIndex;
  1410. TNativeUIntByteIndex = TWordByteIndex;
  1411. TNativeUIntOverlay = TWordOverlay;
  1412. {$elseif sizeof(NativeUInt)=4}
  1413. TNativeUIntNibbleIndex = TDwordNibbleIndex;
  1414. TNativeUIntByteIndex = TDwordByteIndex;
  1415. TNativeUIntWordIndex = TDwordWordIndex;
  1416. TNativeUIntOverlay = TDwordOverlay;
  1417. {$elseif sizeof(NativeUInt)=8}
  1418. TNativeUIntNibbleIndex = TQwordNibbleIndex;
  1419. TNativeUIntByteIndex = TQwordByteIndex;
  1420. TNativeUIntWordIndex = TQwordWordIndex;
  1421. TNativeUIntDwordIndex = TQwordDWordIndex;
  1422. TNativeUIntOverlay = TQwordOverlay;
  1423. {$else}
  1424. {$fatal Unsupported NativeUInt type size}
  1425. {$endif}
  1426. TNativeUIntHelper = Type Helper for NativeUInt
  1427. const
  1428. MaxValue = High(NativeUInt);
  1429. MinValue = 0;
  1430. MaxBit = High(TNativeUIntBitIndex);
  1431. MinBit = Low(TNativeUIntBitIndex);
  1432. MaxNibble = High(TNativeUIntNibbleIndex);
  1433. MinNibble = Low(TNativeUIntNibbleIndex);
  1434. // NativeInt on cpu16 has 2 bytes, so no need for cpu16 check because we always need MaxByte and MinByte
  1435. MaxByte = High(TNativeUIntByteIndex);
  1436. MinByte = Low(TNativeUIntByteIndex);
  1437. {$if sizeof(NativeUInt)>=4}
  1438. MaxWord = High(TNativeUIntWordIndex);
  1439. MinWord = Low(TNativeUIntWordIndex);
  1440. {$endif}
  1441. {$if sizeof(NativeUInt)>=8}
  1442. MaxDword = High(TNativeUIntDwordIndex);
  1443. MinDword = Low(TNativeUIntDwordIndex);
  1444. {$endif}
  1445. public
  1446. Class Function Parse(const AString: string): NativeUInt; inline; static;
  1447. Class Function Size: Integer; inline; static;
  1448. Class Function ToString(const AValue: NativeUInt): string; overload; inline; static;
  1449. Class Function TryParse(const AString: string; out AValue: NativeUInt): Boolean; inline; static;
  1450. protected
  1451. function GetBit(const aIndex: TNativeUIntBitIndex): boolean; inline;
  1452. procedure PutBit(const aIndex: TNativeUIntBitIndex; const aNewValue: boolean); inline;
  1453. function GetNibble(const aIndex: TNativeUIntNibbleIndex): nibble; inline;
  1454. procedure PutNibble(const aIndex: TNativeUIntNibbleIndex; const aNewValue: nibble); inline;
  1455. // NativeInt on cpu16 has 2 bytes, so no need for cpu16 check because we always need GetByte and PutByte
  1456. function GetByte(const aIndex: TNativeUIntByteIndex): byte;
  1457. procedure PutByte(const aIndex: TNativeUIntByteIndex; const aNewValue: byte);
  1458. {$if sizeof(NativeUInt)>=4}
  1459. function GetWord(const aIndex: TNativeUIntWordIndex): word;
  1460. procedure PutWord(const aIndex: TNativeUIntWordIndex; const aNewValue: word);
  1461. {$endif}
  1462. {$if sizeof(NativeUInt)>=8}
  1463. function GetDword(const aIndex: TNativeUIntDwordIndex): dword;
  1464. procedure PutDword(const aIndex: TNativeUIntDwordIndex; const aNewValue: dword);
  1465. {$endif}
  1466. public
  1467. Function ToBoolean: Boolean; inline;
  1468. Function ToDouble: Double; inline;
  1469. Function ToExtended: Extended; inline;
  1470. Function ToBinString:string; inline;
  1471. Function ToHexString(const AMinDigits: Integer): string; overload; inline;
  1472. Function ToHexString: string; overload; inline;
  1473. Function ToSingle: Single; inline;
  1474. Function ToString: string; overload; inline;
  1475. Function SetBit(const Index: TNativeUIntBitIndex) : NativeUint; inline;
  1476. Function ClearBit(const Index: TNativeUIntBitIndex): NativeUint; inline;
  1477. Function ToggleBit(const Index: TNativeUIntBitIndex) : NativeUint; inline;
  1478. Function TestBit(const Index:TNativeUIntBitIndex) :Boolean; inline;
  1479. procedure Clear; inline;
  1480. function HighestSetBitPos: int8; inline;
  1481. function LowestSetBitPos: int8; inline;
  1482. function SetBitsCount: byte; inline;
  1483. property Bits [aIndex: TNativeUIntBitIndex]: boolean read GetBit write PutBit;
  1484. property Nibbles [aIndex: TNativeUIntNibbleIndex]: nibble read GetNibble write PutNibble;
  1485. // NativeInt on cpu16 has 2 bytes, so no need for cpu16 check because we always need Byte[]
  1486. property Bytes [aIndex: TNativeUIntByteIndex]: byte read GetByte write PutByte;
  1487. {$if sizeof(NativeUInt)>=4}
  1488. property Words [aIndex: TNativeUIntWordIndex]: word read GetWord write PutWord;
  1489. {$endif}
  1490. {$if sizeof(NativeUInt)>=8}
  1491. property DWords [aIndex: TNativeUIntDwordIndex]: dword read GetDWord write PutDWord;
  1492. {$endif}
  1493. end;
  1494. {$SCOPEDENUMS ON}
  1495. TUseBoolStrs = (False, True);
  1496. {$SCOPEDENUMS OFF}
  1497. TBooleanHelper = Type Helper for Boolean
  1498. public
  1499. Class Function Parse(const S: string): Boolean; inline; static;
  1500. Class Function Size: Integer; inline; static;
  1501. Class Function ToString(const AValue: Boolean; UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline; static;
  1502. Class Function TryToParse(const S: string; out AValue: Boolean): Boolean; inline; static;
  1503. Public
  1504. Function ToInteger: Integer; inline;
  1505. Function ToString(UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline;
  1506. end;
  1507. TBoolean8Helper = Type Helper for Boolean8
  1508. public
  1509. Class Function Parse(const S: string): Boolean; inline; static;
  1510. Class Function Size: Integer; inline; static;
  1511. Class Function ToString(const AValue: Boolean; UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline; static;
  1512. Class Function TryToParse(const S: string; out AValue: Boolean): Boolean; inline; static;
  1513. Public
  1514. Function ToInteger: Integer; inline;
  1515. Function ToString(UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline;
  1516. end;
  1517. TBoolean16Helper = Type Helper for Boolean16
  1518. public
  1519. Class Function Parse(const S: string): Boolean; inline; static;
  1520. Class Function Size: Integer; inline; static;
  1521. Class Function ToString(const AValue: Boolean; UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline; static;
  1522. Class Function TryToParse(const S: string; out AValue: Boolean): Boolean; inline; static;
  1523. Public
  1524. Function ToInteger: Integer; inline;
  1525. Function ToString(UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline;
  1526. end;
  1527. TBoolean32Helper = Type Helper for Boolean32
  1528. public
  1529. Class Function Parse(const S: string): Boolean; inline; static;
  1530. Class Function Size: Integer; inline; static;
  1531. Class Function ToString(const AValue: Boolean; UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline; static;
  1532. Class Function TryToParse(const S: string; out AValue: Boolean): Boolean; inline; static;
  1533. Public
  1534. Function ToInteger: Integer; inline;
  1535. Function ToString(UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline;
  1536. end;
  1537. TBoolean64Helper = Type Helper for Boolean64
  1538. public
  1539. Class Function Parse(const S: string): Boolean; inline; static;
  1540. Class Function Size: Integer; inline; static;
  1541. Class Function ToString(const AValue: Boolean; UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline; static;
  1542. Class Function TryToParse(const S: string; out AValue: Boolean): Boolean; inline; static;
  1543. Public
  1544. Function ToInteger: Integer; inline;
  1545. Function ToString(UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline;
  1546. end;
  1547. TByteBoolHelper = Type Helper for ByteBool
  1548. public
  1549. Class Function Parse(const S: string): Boolean; inline; static;
  1550. Class Function Size: Integer; inline; static;
  1551. Class Function ToString(const AValue: Boolean; UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline; static;
  1552. Class Function TryToParse(const S: string; out AValue: Boolean): Boolean; inline; static;
  1553. Public
  1554. Function ToInteger: Integer; inline;
  1555. Function ToString(UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline;
  1556. end;
  1557. TWordBoolHelper = Type Helper for WordBool
  1558. public
  1559. Class Function Parse(const S: string): Boolean; inline; static;
  1560. Class Function Size: Integer; inline; static;
  1561. Class Function ToString(const AValue: Boolean; UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline; static;
  1562. Class Function TryToParse(const S: string; out AValue: Boolean): Boolean; inline; static;
  1563. Public
  1564. Function ToInteger: Integer; inline;
  1565. Function ToString(UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline;
  1566. end;
  1567. TLongBoolHelper = Type Helper for LongBool
  1568. public
  1569. Class Function Parse(const S: string): Boolean; inline; static;
  1570. Class Function Size: Integer; inline; static;
  1571. Class Function ToString(const AValue: Boolean; UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline; static;
  1572. Class Function TryToParse(const S: string; out AValue: Boolean): Boolean; inline; static;
  1573. public
  1574. Function ToInteger: Integer; inline;
  1575. Function ToString(UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline;
  1576. end;
  1577. TQWordBoolHelper = Type Helper for QWordBool
  1578. public
  1579. Class Function Parse(const S: string): Boolean; inline; static;
  1580. Class Function Size: Integer; inline; static;
  1581. Class Function ToString(const AValue: Boolean; UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline; static;
  1582. Class Function TryToParse(const S: string; out AValue: Boolean): Boolean; inline; static;
  1583. public
  1584. Function ToInteger: Integer; inline;
  1585. Function ToString(UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline;
  1586. end;