2
0

syshelph.inc 102 KB

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