syshelph.inc 102 KB

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