syshelph.inc 103 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673
  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. {$IFNDEF VER3_2}
  764. TRealHelper = Type Helper(TDoubleHelper) for Real
  765. end;
  766. {$ENDIF}
  767. {$ENDIF FPC_HAS_TYPE_DOUBLE}
  768. {$ifdef FPC_HAS_TYPE_EXTENDED}
  769. TExtendedHelper = Type Helper for Extended
  770. private
  771. Function GetB(AIndex: Cardinal): Byte;
  772. Function GetW(AIndex: Cardinal): Word;
  773. Function GetE: QWord; inline;
  774. Function GetF: QWord; inline;
  775. Function GetS: Boolean; inline;
  776. procedure SetB(AIndex: Cardinal; const AValue: Byte);
  777. procedure SetW(AIndex: Cardinal; const AValue: Word);
  778. procedure SetE(AValue: QWord);
  779. procedure SetF(AValue: QWord);
  780. procedure SetS(AValue: Boolean);
  781. public
  782. {$push}
  783. {$R-}
  784. {$Q-}
  785. const
  786. Epsilon : Extended = 3.64519953188247460253e-4951;
  787. MaxValue : Extended = 1.18973149535723176505e+4932;
  788. MinValue : Extended = -1.18973149535723176505e+4932;
  789. PositiveInfinity : Extended = 1.0/0.0;
  790. NegativeInfinity : Extended = -1.0/0.0;
  791. NaN : Extended = 0.0/0.0;
  792. {$POP}
  793. Class Function ToString(const AValue: Extended): string; overload; inline; static;
  794. Class Function ToString(const AValue: Extended; const AFormatSettings: TFormatSettings): string; overload; inline; static;
  795. Class Function ToString(const AValue: Extended; const AFormat: TFloatFormat; const APrecision, ADigits: Integer): string; overload; inline; static;
  796. Class Function ToString(const AValue: Extended; const AFormat: TFloatFormat; const APrecision, ADigits: Integer; const AFormatSettings: TFormatSettings): string; overload; inline; static;
  797. Class Function Parse(const AString: string): Extended; overload; inline; static;
  798. Class Function Parse(const AString: string; const AFormatSettings: TFormatSettings): Extended; overload; inline; static;
  799. Class Function TryParse(const AString: string; out AValue: Extended): Boolean; overload; inline; static;
  800. Class Function TryParse(const AString: string; out AValue: Extended; const AFormatSettings: TFormatSettings): Boolean; overload; inline; static;
  801. Class Function IsNan(const AValue: Extended): Boolean; overload; inline; static;
  802. Class Function IsInfinity(const AValue: Extended): Boolean; overload; inline; static;
  803. Class Function IsNegativeInfinity(const AValue: Extended): Boolean; overload; inline; static;
  804. Class Function IsPositiveInfinity(const AValue: Extended): Boolean; overload; inline; static;
  805. Class Function Size: Integer; inline; static;
  806. procedure BuildUp(const ASignFlag: Boolean; const AMantissa: QWord; Const AExponent: Integer);
  807. Function Exponent: Integer;
  808. Function Fraction: Extended;
  809. Function IsInfinity: Boolean; overload; inline;
  810. Function IsNan: Boolean; overload; inline;
  811. Function IsNegativeInfinity: Boolean; overload; inline;
  812. Function IsPositiveInfinity: Boolean; overload; inline;
  813. Function Mantissa: QWord;
  814. Function SpecialType: TFloatSpecial;
  815. Function ToString(const AFormat: TFloatFormat; const APrecision, ADigits: Integer): string; overload; inline;
  816. Function ToString(const AFormat: TFloatFormat; const APrecision, ADigits: Integer; const AFormatSettings: TFormatSettings): string; overload; inline;
  817. Function ToString(const AFormatSettings: TFormatSettings): string; overload; inline;
  818. Function ToString: string; overload; inline;
  819. property Bytes [AIndex: Cardinal]: Byte read GetB write SetB;
  820. property Words [AIndex: Cardinal]: Word read GetW write SetW;
  821. property Sign: Boolean read GetS write SetS;
  822. property Exp: QWord read GetE write SetE;
  823. property Frac: QWord read GetF write SetF;
  824. end;
  825. {$ENDIF FPC_HAS_TYPE_EXTENDED}
  826. nibble = 0..15;
  827. TNibbleBitIndex = 0..3;
  828. // TByteBitIndex is already defined
  829. TByteNibbleIndex = 0..1;
  830. TByteOverlay = bitpacked record case integer of // for fast extraction of bits
  831. 0: (AsBit: bitpacked array[TByteBitIndex] of boolean);
  832. 1: (AsNibble: bitpacked array[TByteNibbleIndex] of nibble);
  833. 2: (AsByte: byte);
  834. end;
  835. TByteHelper = Type Helper for Byte
  836. const
  837. MaxValue = High(byte);
  838. MinValue = Low(byte);
  839. MaxBit = High(TByteBitIndex);
  840. MinBit = Low(TByteBitIndex);
  841. MaxNibble = High(TByteNibbleIndex);
  842. MinNibble = Low(TByteNibbleIndex);
  843. public
  844. Class Function Parse(const AString: string): Byte; inline; static;
  845. Class Function Size: Integer; inline; static;
  846. Class Function ToString(const AValue: Byte): string; overload; inline; static;
  847. Class Function TryParse(const AString: string; out AValue: Byte): Boolean; inline; static;
  848. protected
  849. function GetBit(const aIndex: TByteBitIndex): boolean; inline;
  850. procedure PutBit(const aIndex: TByteBitIndex; const aNewValue: boolean); inline;
  851. function GetNibble(const aIndex: TByteNibbleIndex): nibble; inline;
  852. procedure PutNibble(const aIndex: TByteNibbleIndex; const aNewValue: nibble); inline;
  853. public
  854. Function ToBoolean: Boolean; inline;
  855. Function ToDouble: Double; inline;
  856. Function ToExtended: Extended; inline;
  857. Function ToBinString:string;
  858. Function ToHexString(const AMinDigits: Integer): string; overload; inline;
  859. Function ToHexString: string; overload; inline;
  860. Function ToSingle: Single; inline;
  861. Function ToString: string; overload; inline;
  862. Function SetBit(const Index: TByteBitIndex) : Byte; inline;
  863. Function ClearBit(const Index: TByteBitIndex) : Byte; inline;
  864. Function ToggleBit(const Index: TByteBitIndex) : Byte; inline;
  865. Function TestBit(const Index:TByteBitIndex):Boolean; inline;
  866. procedure Clear; inline;
  867. function HighestSetBitPos: int8; inline;
  868. function LowestSetBitPos: int8; inline;
  869. function SetBitsCount: byte; inline;
  870. property Bits [aIndex: TByteBitIndex]: boolean read GetBit write PutBit;
  871. property Nibbles [aIndex: TByteNibbleIndex]: nibble read GetNibble write PutNibble;
  872. end;
  873. // TShortIntBitIndex is already defined
  874. TShortIntNibbleIndex = TByteNibbleIndex;
  875. TShortIntOverlay = TByteOverlay;
  876. TShortIntHelper = Type Helper for ShortInt
  877. const
  878. MaxValue = High(shortint);
  879. MinValue = Low(shortint);
  880. MaxBit = High(TShortIntBitIndex);
  881. MinBit = Low(TShortIntBitIndex);
  882. MaxNibble = High(TShortIntNibbleIndex);
  883. MinNibble = Low(TShortIntNibbleIndex);
  884. public
  885. Class Function Parse(const AString: string): ShortInt; inline; static;
  886. Class Function Size: Integer; inline; static;
  887. Class Function ToString(const AValue: ShortInt): string; overload; inline; static;
  888. Class Function TryParse(const AString: string; out AValue: ShortInt): Boolean; inline; static;
  889. protected
  890. function GetBit(const aIndex: TShortIntBitIndex): boolean; inline;
  891. procedure PutBit(const aIndex: TShortIntBitIndex; const aNewValue: boolean); inline;
  892. function GetNibble(const aIndex: TShortIntNibbleIndex): nibble; inline;
  893. procedure PutNibble(const aIndex: TShortIntNibbleIndex; const aNewValue: nibble); inline;
  894. public
  895. Function ToBoolean: Boolean; inline;
  896. Function ToDouble: Double; inline;
  897. Function ToExtended: Extended; inline;
  898. Function ToBinString:string; inline;
  899. Function ToHexString(const AMinDigits: Integer): string; overload; inline;
  900. Function ToHexString: string; overload; inline;
  901. Function ToSingle: Single; inline;
  902. Function ToString: string; overload; inline;
  903. Function SetBit(const Index: TShortIntBitIndex): Shortint; inline;
  904. Function ClearBit(const Index: TShortIntBitIndex): Shortint; inline;
  905. Function ToggleBit(const Index: TShortIntBitIndex): Shortint; inline;
  906. Function TestBit(const Index:TShortIntBitIndex):Boolean;
  907. procedure Clear; inline;
  908. function HighestSetBitPos: int8; inline;
  909. function LowestSetBitPos: int8; inline;
  910. function SetBitsCount: byte; inline;
  911. property Bits [aIndex: TShortIntBitIndex]: boolean read GetBit write PutBit;
  912. property Nibbles [aIndex: TShortIntNibbleIndex]: nibble read GetNibble write PutNibble;
  913. end;
  914. // TWordBitIndex is already defined
  915. TWordByteIndex = 0..1;
  916. TWordNibbleIndex = 0..3;
  917. TWordOverlay = bitpacked record case integer of // for fast extraction of bytes and bits
  918. 0: (AsBit: bitpacked array[TWordBitIndex] of boolean);
  919. 1: (AsNibble: bitpacked array[TWordNibbleIndex] of nibble);
  920. 2: (AsByte: array[TWordByteIndex] of byte);
  921. 3: (AsWord: word);
  922. // recursive overlay:
  923. 4: (AsByteOverlay: array[TWordByteIndex] of TByteOverlay);
  924. end;
  925. TWordHelper = Type Helper for Word
  926. const
  927. MaxValue = High(word);
  928. MinValue = Low(word);
  929. MaxBit = High(TWordBitIndex);
  930. MinBit = Low(TWordBitIndex);
  931. MaxNibble = High(TWordNibbleIndex);
  932. MinNibble = Low(TWordNibbleIndex);
  933. MaxByte = High(TWordByteIndex);
  934. MinByte = Low(TWordByteIndex);
  935. public
  936. Class Function Parse(const AString: string): Word; inline; static;
  937. Class Function Size: Integer; inline; static;
  938. Class Function ToString(const AValue: Word): string; overload; inline; static;
  939. Class Function TryParse(const AString: string; out AValue: Word): Boolean; inline; static;
  940. protected
  941. function GetBit(const aIndex: TWordBitIndex): boolean; inline;
  942. procedure PutBit(const aIndex: TWordBitIndex; const aNewValue: boolean); inline;
  943. function GetNibble(const aIndex: TWordNibbleIndex): nibble; inline;
  944. procedure PutNibble(const aIndex: TWordNibbleIndex; const aNewValue: nibble); inline;
  945. function GetByte(const aIndex: TWordByteIndex): byte;
  946. procedure PutByte(const aIndex: TWordByteIndex; const aNewValue: byte);
  947. public
  948. Function ToBoolean: Boolean; inline;
  949. Function ToDouble: Double; inline;
  950. Function ToExtended: Extended; inline;
  951. Function ToBinString:string; inline;
  952. Function ToHexString(const AMinDigits: Integer): string; overload; inline;
  953. Function ToHexString: string; overload; inline;
  954. Function ToSingle: Single; inline;
  955. Function ToString: string; overload; inline;
  956. Function SetBit(const Index: TWordBitIndex) : Word; inline;
  957. Function ClearBit(const Index: TWordBitIndex) : Word; inline;
  958. Function ToggleBit(const Index: TWordBitIndex) : Word; inline;
  959. Function TestBit(const Index:TWordBitIndex):Boolean; inline;
  960. procedure Clear; inline;
  961. function HighestSetBitPos: int8; inline;
  962. function LowestSetBitPos: int8; inline;
  963. function SetBitsCount: byte; inline;
  964. property Bits [aIndex: TWordBitIndex]: boolean read GetBit write PutBit;
  965. property Nibbles [aIndex: TWordNibbleIndex]: nibble read GetNibble write PutNibble;
  966. property Bytes [aIndex: TWordByteIndex]: byte read GetByte write PutByte;
  967. end;
  968. // TSmallIntBitIndex is already defined
  969. TSmallIntByteIndex = TWordByteIndex;
  970. TSmallIntNibbleIndex = TWordNibbleIndex;
  971. TSmallIntOverlay = TWordOverlay;
  972. TSmallIntHelper = Type Helper for SmallInt
  973. const
  974. MaxValue = High(SmallInt);
  975. MinValue = Low(SmallInt);
  976. MaxBit = High(TSmallIntBitIndex);
  977. MinBit = Low(TSmallIntBitIndex);
  978. MaxNibble = High(TSmallIntNibbleIndex);
  979. MinNibble = Low(TSmallIntNibbleIndex);
  980. MaxByte = High(TSmallIntByteIndex);
  981. MinByte = Low(TSmallIntByteIndex);
  982. public
  983. Class Function Parse(const AString: string): SmallInt; inline; static;
  984. Class Function Size: Integer; inline; static;
  985. Class Function ToString(const AValue: SmallInt): string; overload; inline; static;
  986. Class Function TryParse(const AString: string; out AValue: SmallInt): Boolean; inline; static;
  987. protected
  988. function GetBit(const aIndex: TSmallIntBitIndex): boolean; inline;
  989. procedure PutBit(const aIndex: TSmallIntBitIndex; const aNewValue: boolean); inline;
  990. function GetNibble(const aIndex: TSmallIntNibbleIndex): nibble; inline;
  991. procedure PutNibble(const aIndex: TSmallIntNibbleIndex; const aNewValue: nibble); inline;
  992. function GetByte(const aIndex: TSmallIntByteIndex): byte;
  993. procedure PutByte(const aIndex: TSmallIntByteIndex; const aNewValue: byte);
  994. public
  995. Function ToString: string; overload; inline;
  996. Function ToBoolean: Boolean; inline;
  997. Function ToBinString:string; inline;
  998. Function ToHexString: string; overload; inline;
  999. Function ToHexString(const AMinDigits: Integer): string; overload; inline;
  1000. Function ToSingle: Single; inline;
  1001. Function ToDouble: Double; inline;
  1002. Function ToExtended: Extended; inline;
  1003. Function SetBit(const Index: TSmallIntBitIndex) : Smallint; inline;
  1004. Function ClearBit(const Index: TSmallIntBitIndex) : Smallint; inline;
  1005. Function ToggleBit(const Index: TSmallIntBitIndex) : Smallint; inline;
  1006. Function TestBit(const Index:TSmallIntBitIndex):Boolean;
  1007. procedure Clear; inline;
  1008. function HighestSetBitPos: int8; inline;
  1009. function LowestSetBitPos: int8; inline;
  1010. function SetBitsCount: byte; inline;
  1011. property Bits [aIndex: TSmallIntBitIndex]: boolean read GetBit write PutBit;
  1012. property Nibbles [aIndex: TSmallIntNibbleIndex]: nibble read GetNibble write PutNibble;
  1013. property Bytes [aIndex: TSmallIntByteIndex]: byte read GetByte write PutByte;
  1014. end;
  1015. TDwordBitIndex = TCardinalBitIndex;
  1016. TDwordNibbleIndex = 0..7;
  1017. TDwordByteIndex = 0..3;
  1018. TDwordWordIndex = 0..1;
  1019. TDwordOverlay = bitpacked record case integer of // for fast extraction of words, bytes and bits
  1020. 0: (AsBit: bitpacked array[TDwordBitIndex] of boolean);
  1021. 1: (AsNibble: bitpacked array[TDwordNibbleIndex] of nibble);
  1022. 2: (AsByte: array[TDwordByteIndex] of byte);
  1023. 3: (AsWord: array[TDwordWordIndex] of word);
  1024. 4: (AsDword: dword);
  1025. // recursive overlays:
  1026. 5: (AsByteOverlay: array[TDwordByteIndex] of TByteOverlay);
  1027. 6: (AsWordOverlay: array[TDwordWordIndex] of TWordOverlay);
  1028. end;
  1029. // TCardinalBitIndex is already defined
  1030. TCardinalNibbleIndex = TDwordNibbleIndex;
  1031. TCardinalByteIndex = TDwordByteIndex;
  1032. TCardinalWordIndex = TDwordWordIndex;
  1033. TCardinalOverlay = TDwordOverlay;
  1034. TCardinalHelper = Type Helper for Cardinal { for LongWord Type too }
  1035. const
  1036. MaxValue = High(Cardinal);
  1037. MinValue = Low(Cardinal);
  1038. MaxBit = High(TCardinalBitIndex);
  1039. MinBit = Low(TCardinalBitIndex);
  1040. MaxNibble = High(TCardinalNibbleIndex);
  1041. MinNibble = Low(TCardinalNibbleIndex);
  1042. MaxByte = High(TCardinalByteIndex);
  1043. MinByte = Low(TCardinalByteIndex);
  1044. MaxWord = High(TCardinalWordIndex);
  1045. MinWord = Low(TCardinalWordIndex);
  1046. public
  1047. Class Function Parse(const AString: string): Cardinal; inline; static;
  1048. Class Function Size: Integer; inline; static;
  1049. Class Function ToString(const AValue: Cardinal): string; overload; inline; static;
  1050. Class Function TryParse(const AString: string; out AValue: Cardinal): Boolean; inline; static;
  1051. protected
  1052. function GetBit(const aIndex: TCardinalBitIndex): boolean; inline;
  1053. procedure PutBit(const aIndex: TCardinalBitIndex; const aNewValue: boolean); inline;
  1054. function GetNibble(const aIndex: TCardinalNibbleIndex): nibble; inline;
  1055. procedure PutNibble(const aIndex: TCardinalNibbleIndex; const aNewValue: nibble); inline;
  1056. function GetByte(const aIndex: TCardinalByteIndex): byte;
  1057. procedure PutByte(const aIndex: TCardinalByteIndex; const aNewValue: byte);
  1058. function GetWord(const aIndex: TCardinalWordIndex): word;
  1059. procedure PutWord(const aIndex: TCardinalWordIndex; const aNewValue: word);
  1060. public
  1061. Function ToBoolean: Boolean; inline;
  1062. Function ToDouble: Double; inline;
  1063. Function ToExtended: Extended; inline;
  1064. Function ToBinString:string; inline;
  1065. Function ToHexString(const AMinDigits: Integer): string; overload; inline;
  1066. Function ToHexString: string; overload; inline;
  1067. Function ToSingle: Single; inline;
  1068. Function ToString: string; overload; inline;
  1069. Function SetBit(const Index: TCardinalBitIndex) : Cardinal; inline;
  1070. Function ClearBit(const Index: TCardinalBitIndex) : Cardinal; inline;
  1071. Function ToggleBit(const Index: TCardinalBitIndex) : Cardinal; inline;
  1072. Function TestBit(const Index:TCardinalBitIndex):Boolean; inline;
  1073. procedure Clear; inline;
  1074. function HighestSetBitPos: int8; inline;
  1075. function LowestSetBitPos: int8; inline;
  1076. function SetBitsCount: byte; inline;
  1077. property Bits [aIndex: TCardinalBitIndex]: boolean read GetBit write PutBit;
  1078. property Nibbles[aIndex: TCardinalNibbleIndex]: nibble read GetNibble write PutNibble;
  1079. property Bytes [aIndex: TCardinalByteIndex]: byte read GetByte write PutByte;
  1080. property Words [aIndex: TCardinalWordIndex]: word read GetWord write PutWord;
  1081. end;
  1082. // TIntegerBitIndex is already defined
  1083. {$if sizeof(Integer)=2}
  1084. TIntegerNibbleIndex = TWordNibbleIndex;
  1085. TIntegerByteIndex = TWordByteIndex;
  1086. TIntegerOverlay = TWordOverlay;
  1087. {$elseif sizeof(Integer)=4}
  1088. TIntegerNibbleIndex = TDwordNibbleIndex;
  1089. TIntegerByteIndex = TDwordByteIndex;
  1090. TIntegerWordIndex = TDwordWordIndex;
  1091. TIntegerOverlay = TDwordOverlay;
  1092. {$else}
  1093. {$fatal Unsupported Integer type size}
  1094. {$endif}
  1095. TIntegerHelper = Type Helper for Integer
  1096. const
  1097. MaxValue = High(integer);
  1098. MinValue = Low(integer);
  1099. MaxBit = High(TIntegerBitIndex);
  1100. MinBit = Low(TIntegerBitIndex);
  1101. MaxNibble = High(TIntegerNibbleIndex);
  1102. MinNibble = Low(TIntegerNibbleIndex);
  1103. MaxByte = High(TIntegerByteIndex);
  1104. MinByte = Low(TIntegerByteIndex);
  1105. {$if sizeof(Integer)>=4}
  1106. MaxWord = High(TIntegerWordIndex);
  1107. MinWord = Low(TIntegerWordIndex);
  1108. {$endif}
  1109. public
  1110. Class Function Size: Integer; inline; static;
  1111. Class Function ToString(const AValue: Integer): string; overload; inline; static;
  1112. Class Function Parse(const AString: string): Integer; inline; static;
  1113. Class Function TryParse(const AString: string; out AValue: Integer): Boolean; inline; static;
  1114. protected
  1115. function GetBit(const aIndex: TIntegerBitIndex): boolean; inline;
  1116. procedure PutBit(const aIndex: TIntegerBitIndex; const aNewValue: boolean); inline;
  1117. function GetNibble(const aIndex: TIntegerNibbleIndex): nibble; inline;
  1118. procedure PutNibble(const aIndex: TIntegerNibbleIndex; const aNewValue: nibble); inline;
  1119. function GetByte(const aIndex: TIntegerByteIndex): byte;
  1120. procedure PutByte(const aIndex: TIntegerByteIndex; const aNewValue: byte);
  1121. {$if sizeof(Integer)>=4}
  1122. function GetWord(const aIndex: TIntegerWordIndex): word;
  1123. procedure PutWord(const aIndex: TIntegerWordIndex; const aNewValue: word);
  1124. {$endif}
  1125. public
  1126. Function ToBoolean: Boolean; inline;
  1127. Function ToDouble: Double; inline;
  1128. Function ToExtended: Extended; inline;
  1129. Function ToBinString:string; inline;
  1130. Function ToHexString(const AMinDigits: Integer): string; overload; inline;
  1131. Function ToHexString: string; overload; inline;
  1132. Function ToSingle: Single; inline;
  1133. Function ToString: string; overload; inline;
  1134. Function SetBit(const Index: TIntegerBitIndex) : Integer; inline;
  1135. Function ClearBit(const Index: TIntegerBitIndex) : Integer; inline;
  1136. Function ToggleBit(const Index: TIntegerBitIndex) : Integer; inline;
  1137. Function TestBit(const Index:TIntegerBitIndex):Boolean; inline;
  1138. procedure Clear; inline;
  1139. function HighestSetBitPos: int8; inline;
  1140. function LowestSetBitPos: int8; inline;
  1141. function SetBitsCount: byte; inline;
  1142. property Bits [aIndex: TIntegerBitIndex]: boolean read GetBit write PutBit;
  1143. property Nibbles[aIndex: TIntegerNibbleIndex]: nibble read GetNibble write PutNibble;
  1144. property Bytes [aIndex: TIntegerByteIndex]: byte read GetByte write PutByte;
  1145. {$if sizeof(Integer)>=4}
  1146. property Words [aIndex: TIntegerWordIndex]: word read GetWord write PutWord;
  1147. {$endif}
  1148. end;
  1149. // TLongIntBitIndex is already defined
  1150. TLongIntNibbleIndex = TDwordNibbleIndex;
  1151. TLongIntByteIndex = TDwordByteIndex;
  1152. TLongIntWordIndex = TDwordWordIndex;
  1153. TLongIntOverlay = TDwordOverlay;
  1154. TLongIntHelper = Type Helper for LongInt
  1155. const
  1156. MaxValue = High(LongInt);
  1157. MinValue = Low(LongInt);
  1158. MaxBit = High(TLongIntBitIndex);
  1159. MinBit = Low(TLongIntBitIndex);
  1160. MaxNibble = High(TLongIntNibbleIndex);
  1161. MinNibble = Low(TLongIntNibbleIndex);
  1162. MaxByte = High(TLongIntByteIndex);
  1163. MinByte = Low(TLongIntByteIndex);
  1164. MaxWord = High(TLongIntWordIndex);
  1165. MinWord = Low(TLongIntWordIndex);
  1166. public
  1167. Class Function Size: Integer; inline; static;
  1168. Class Function ToString(const AValue: LongInt): string; overload; inline; static;
  1169. Class Function Parse(const AString: string): LongInt; inline; static;
  1170. Class Function TryParse(const AString: string; out AValue: LongInt): Boolean; inline; static;
  1171. protected
  1172. function GetBit(const aIndex: TLongIntBitIndex): boolean; inline;
  1173. procedure PutBit(const aIndex: TLongIntBitIndex; const aNewValue: boolean); inline;
  1174. function GetNibble(const aIndex: TLongIntNibbleIndex): nibble; inline;
  1175. procedure PutNibble(const aIndex: TLongIntNibbleIndex; const aNewValue: nibble); inline;
  1176. function GetByte(const aIndex: TLongIntByteIndex): byte;
  1177. procedure PutByte(const aIndex: TLongIntByteIndex; const aNewValue: byte);
  1178. function GetWord(const aIndex: TLongIntWordIndex): word;
  1179. procedure PutWord(const aIndex: TLongIntWordIndex; const aNewValue: word);
  1180. public
  1181. Function ToBoolean: Boolean; inline;
  1182. Function ToDouble: Double; inline;
  1183. Function ToExtended: Extended; inline;
  1184. Function ToBinString:string; inline;
  1185. Function ToHexString(const AMinDigits: Integer): string; overload; inline;
  1186. Function ToHexString: string; overload; inline;
  1187. Function ToSingle: Single; inline;
  1188. Function ToString: string; overload; inline;
  1189. Function SetBit(const Index: TLongIntBitIndex) : LongInt; inline;
  1190. Function ClearBit(const Index: TLongIntBitIndex) : LongInt; inline;
  1191. Function ToggleBit(const Index: TLongIntBitIndex) : LongInt; inline;
  1192. Function TestBit(const Index:TLongIntBitIndex):Boolean; inline;
  1193. procedure Clear; inline;
  1194. function HighestSetBitPos: int8; inline;
  1195. function LowestSetBitPos: int8; inline;
  1196. function SetBitsCount: byte; inline;
  1197. property Bits [aIndex: TLongIntBitIndex]: boolean read GetBit write PutBit;
  1198. property Nibbles[aIndex: TLongIntNibbleIndex]: nibble read GetNibble write PutNibble;
  1199. property Bytes [aIndex: TLongIntByteIndex]: byte read GetByte write PutByte;
  1200. property Words [aIndex: TLongIntWordIndex]: word read GetWord write PutWord;
  1201. end;
  1202. // TQwordBitIndex is already defined
  1203. TQwordNibbleIndex = 0..15;
  1204. TQwordByteIndex = 0..7;
  1205. TQwordWordIndex = 0..3;
  1206. TQwordDwordIndex = 0..1;
  1207. TQwordOverlay = bitpacked record case integer of // for fast extraction of longwords, words, bytes and bits
  1208. 0: (AsBit: bitpacked array[TQwordBitIndex] of boolean);
  1209. 1: (AsNibble: bitpacked array[TQwordNibbleIndex] of nibble);
  1210. 2: (AsByte: array[TQwordByteIndex] of byte);
  1211. 3: (AsWord: array[TQwordWordIndex] of word);
  1212. 4: (AsDword: array[TQwordDwordIndex] of dword);
  1213. 5: (AsQword: qword);
  1214. // recursive overlays:
  1215. 6: (AsByteOverlay: array[TQwordByteIndex] of TByteOverlay);
  1216. 7: (AsWordOverlay: array[TQwordWordIndex] of TWordOverlay);
  1217. 8: (AsDwordOverlay: array[TQwordDwordIndex] of TDwordOverlay);
  1218. end;
  1219. TQWordHelper = Type Helper for QWord
  1220. const
  1221. MaxValue = High(qword);
  1222. MinValue = Low(qword);
  1223. MaxBit = High(TQwordBitIndex);
  1224. MinBit = Low(TQwordBitIndex);
  1225. MaxNibble = High(TQwordNibbleIndex);
  1226. MinNibble = Low(TQwordNibbleIndex);
  1227. MaxByte = High(TQwordByteIndex);
  1228. MinByte = Low(TQwordByteIndex);
  1229. MaxWord = High(TQwordWordIndex);
  1230. MinWord = Low(TQwordWordIndex);
  1231. MaxDword = High(TQwordDwordIndex);
  1232. MinDword = Low(TQwordDwordIndex);
  1233. public
  1234. Class Function Parse(const AString: string): Qword; inline; static;
  1235. Class Function Size: Integer; inline; static;
  1236. Class Function ToString(const AValue: Qword): string; overload; inline; static;
  1237. Class Function TryParse(const AString: string; out AValue: Qword): Boolean; inline; static;
  1238. protected
  1239. function GetBit(const aIndex: TQwordBitIndex): boolean; inline;
  1240. procedure PutBit(const aIndex: TQwordBitIndex; const aNewValue: boolean); inline;
  1241. function GetNibble(const aIndex: TQwordNibbleIndex): nibble; inline;
  1242. procedure PutNibble(const aIndex: TQwordNibbleIndex; const aNewValue: nibble); inline;
  1243. function GetByte(const aIndex: TQwordByteIndex): byte;
  1244. procedure PutByte(const aIndex: TQwordByteIndex; const aNewValue: byte);
  1245. function GetWord(const aIndex: TQwordWordIndex): word;
  1246. procedure PutWord(const aIndex: TQwordWordIndex; const aNewValue: word);
  1247. function GetDword(const aIndex: TQwordDwordIndex): dword;
  1248. procedure PutDword(const aIndex: TQwordDwordIndex; const aNewValue: dword);
  1249. public
  1250. Function ToBoolean: Boolean; inline;
  1251. Function ToDouble: Double; inline;
  1252. Function ToExtended: Extended; inline;
  1253. Function ToBinString:string; inline;
  1254. Function ToHexString(const AMinDigits: Integer): string; overload; inline;
  1255. Function ToHexString: string; overload; inline;
  1256. Function ToSingle: Single; inline;
  1257. Function ToString: string; overload; inline;
  1258. Function SetBit(const Index: TQwordBitIndex): Qword; inline;
  1259. Function ClearBit(const Index: TQwordBitIndex): Qword; inline;
  1260. Function ToggleBit(const Index: TQwordBitIndex): Qword; inline;
  1261. Function TestBit(const Index:TQwordBitIndex): Boolean; inline;
  1262. procedure Clear; inline;
  1263. function HighestSetBitPos: int8; inline;
  1264. function LowestSetBitPos: int8; inline;
  1265. function SetBitsCount: byte; inline;
  1266. property Bits [aIndex: TQwordBitIndex]: boolean read GetBit write PutBit;
  1267. property Nibbles[aIndex: TQwordNibbleIndex]: nibble read GetNibble write PutNibble;
  1268. property Bytes [aIndex: TQwordByteIndex]: byte read GetByte write PutByte;
  1269. property Words [aIndex: TQwordWordIndex]: word read GetWord write PutWord;
  1270. property DWords [aIndex: TQwordDwordIndex]: dword read GetDWord write PutDWord;
  1271. end;
  1272. // TInt64BitIndex is already defined
  1273. TInt64NibbleIndex = TQwordNibbleIndex;
  1274. TInt64ByteIndex = TQwordByteIndex;
  1275. TInt64WordIndex = TQwordWordIndex;
  1276. TInt64DwordIndex = TQwordDwordIndex;
  1277. TInt64Overlay = TQwordOverlay;
  1278. TInt64Helper = Type Helper for Int64
  1279. const
  1280. MaxValue = High(int64);
  1281. MinValue = Low(int64);
  1282. MaxBit = High(TInt64BitIndex);
  1283. MinBit = Low(TInt64BitIndex);
  1284. MaxNibble = High(TInt64NibbleIndex);
  1285. MinNibble = Low(TInt64NibbleIndex);
  1286. MaxByte = High(TInt64ByteIndex);
  1287. MinByte = Low(TInt64ByteIndex);
  1288. MaxWord = High(TInt64WordIndex);
  1289. MinWord = Low(TInt64WordIndex);
  1290. MaxDword = High(TInt64DwordIndex);
  1291. MinDword = Low(TInt64DwordIndex);
  1292. public
  1293. Class Function Parse(const AString: string): Int64; inline; static;
  1294. Class Function Size: Integer; inline; static;
  1295. Class Function ToString(const AValue: Int64): string; overload; inline; static;
  1296. Class Function TryParse(const AString: string; out AValue: Int64): Boolean; inline; static;
  1297. protected
  1298. function GetBit(const aIndex: TInt64BitIndex): boolean; inline;
  1299. procedure PutBit(const aIndex: TInt64BitIndex; const aNewValue: boolean); inline;
  1300. function GetNibble(const aIndex: TInt64NibbleIndex): nibble; inline;
  1301. procedure PutNibble(const aIndex: TInt64NibbleIndex; const aNewValue: nibble); inline;
  1302. function GetByte(const aIndex: TInt64ByteIndex): byte;
  1303. procedure PutByte(const aIndex: TInt64ByteIndex; const aNewValue: byte);
  1304. function GetWord(const aIndex: TInt64WordIndex): word;
  1305. procedure PutWord(const aIndex: TInt64WordIndex; const aNewValue: word);
  1306. function GetDword(const aIndex: TInt64DwordIndex): dword;
  1307. procedure PutDword(const aIndex: TInt64DwordIndex; const aNewValue: dword);
  1308. public
  1309. Function ToBoolean: Boolean; inline;
  1310. Function ToDouble: Double; inline;
  1311. Function ToExtended: Extended; inline;
  1312. Function ToBinString:string; inline;
  1313. Function ToHexString(const AMinDigits: Integer): string; overload; inline;
  1314. Function ToHexString: string; overload; inline;
  1315. Function ToSingle: Single; inline;
  1316. Function ToString: string; overload; inline;
  1317. Function SetBit(const Index: TInt64BitIndex) : Int64; inline;
  1318. Function ClearBit(const Index: TInt64BitIndex) : Int64; inline;
  1319. Function ToggleBit(const Index: TInt64BitIndex) : Int64; inline;
  1320. Function TestBit(const Index: TInt64BitIndex): Boolean; inline;
  1321. procedure Clear; inline;
  1322. function HighestSetBitPos: int8; inline;
  1323. function LowestSetBitPos: int8; inline;
  1324. function SetBitsCount: byte; inline;
  1325. property Bits [aIndex: TInt64BitIndex]: boolean read GetBit write PutBit;
  1326. property Nibbles[aIndex: TInt64NibbleIndex]: nibble read GetNibble write PutNibble;
  1327. property Bytes [aIndex: TInt64ByteIndex]: byte read GetByte write PutByte;
  1328. property Words [aIndex: TInt64WordIndex]: word read GetWord write PutWord;
  1329. property DWords [aIndex: TInt64DwordIndex]: dword read GetDWord write PutDWord;
  1330. end;
  1331. // TNativeIntBitIndex is already defined
  1332. {$if sizeof(NativeInt)=2}
  1333. TNativeIntNibbleIndex = TSmallIntNibbleIndex;
  1334. TNativeIntByteIndex = TSmallIntByteIndex;
  1335. TNativeIntOverlay = TSmallIntOverlay;
  1336. {$elseif sizeof(NativeInt)=4}
  1337. TNativeIntNibbleIndex = TLongIntNibbleIndex;
  1338. TNativeIntByteIndex = TLongIntByteIndex;
  1339. TNativeIntWordIndex = TLongIntWordIndex;
  1340. TNativeIntOverlay = TLongIntOverlay;
  1341. {$elseif sizeof(NativeInt)=8}
  1342. TNativeIntNibbleIndex = TInt64NibbleIndex;
  1343. TNativeIntByteIndex = TInt64ByteIndex;
  1344. TNativeIntWordIndex = TInt64WordIndex;
  1345. TNativeIntDwordIndex = TInt64DWordIndex;
  1346. TNativeIntOverlay = TInt64Overlay;
  1347. {$else}
  1348. {$fatal Unsupported NativeInt type size}
  1349. {$endif}
  1350. TNativeIntHelper = Type Helper for NativeInt
  1351. const
  1352. MaxValue = High(NativeInt);
  1353. MinValue = Low(NativeInt);
  1354. MaxBit = High(TNativeIntBitIndex);
  1355. MinBit = Low(TNativeIntBitIndex);
  1356. MaxNibble = High(TNativeIntNibbleIndex);
  1357. MinNibble = Low(TNativeIntNibbleIndex);
  1358. // NativeInt on cpu16 has 2 bytes, so no need for cpu16 check because we always need MaxByte and MinByte
  1359. MaxByte = High(TNativeIntByteIndex);
  1360. MinByte = Low(TNativeIntByteIndex);
  1361. {$if sizeof(NativeInt)>=4}
  1362. MaxWord = High(TNativeIntWordIndex);
  1363. MinWord = Low(TNativeIntWordIndex);
  1364. {$endif}
  1365. {$ifdef sizeof(NativeInt)>=8}
  1366. MaxDword = High(TNativeIntDwordIndex);
  1367. MinDword = Low(TNativeIntDwordIndex);
  1368. {$endif}
  1369. public
  1370. Class Function Parse(const AString: string): NativeInt; inline; static;
  1371. Class Function Size: Integer; inline; static;
  1372. Class Function ToString(const AValue: NativeInt): string; overload; inline; static;
  1373. Class Function TryParse(const AString: string; out AValue: NativeInt): Boolean; inline; static;
  1374. protected
  1375. function GetBit(const aIndex: TNativeIntBitIndex): boolean; inline;
  1376. procedure PutBit(const aIndex: TNativeIntBitIndex; const aNewValue: boolean); inline;
  1377. function GetNibble(const aIndex: TNativeIntNibbleIndex): nibble; inline;
  1378. procedure PutNibble(const aIndex: TNativeIntNibbleIndex; const aNewValue: nibble); inline;
  1379. // NativeInt on cpu16 has 2 bytes, so no need for cpu16 check because we always need GetByte and PutByte
  1380. function GetByte(const aIndex: TNativeIntByteIndex): byte;
  1381. procedure PutByte(const aIndex: TNativeIntByteIndex; const aNewValue: byte);
  1382. {$if sizeof(NativeInt)>=4}
  1383. function GetWord(const aIndex: TNativeIntWordIndex): word;
  1384. procedure PutWord(const aIndex: TNativeIntWordIndex; const aNewValue: word);
  1385. {$endif}
  1386. {$if sizeof(NativeInt)>=8}
  1387. function GetDword(const aIndex: TNativeIntDwordIndex): dword;
  1388. procedure PutDword(const aIndex: TNativeIntDwordIndex; const aNewValue: dword);
  1389. {$endif}
  1390. public
  1391. Function ToBoolean: Boolean; inline;
  1392. Function ToDouble: Double; inline;
  1393. Function ToExtended: Extended; inline;
  1394. Function ToBinString:string; inline;
  1395. Function ToHexString(const AMinDigits: Integer): string; overload; inline;
  1396. Function ToHexString: string; overload; inline;
  1397. Function ToSingle: Single; inline;
  1398. Function ToString: string; overload; inline;
  1399. Function SetBit(const Index: TNativeIntBitIndex) : NativeInt; inline;
  1400. Function ClearBit(const Index: TNativeIntBitIndex) : NativeInt; inline;
  1401. Function ToggleBit(const Index: TNativeIntBitIndex) : NativeInt; inline;
  1402. Function TestBit(const Index:TNativeIntBitIndex):Boolean; inline;
  1403. procedure Clear; inline;
  1404. function HighestSetBitPos: int8; inline;
  1405. function LowestSetBitPos: int8; inline;
  1406. function SetBitsCount: byte; inline;
  1407. property Bits [aIndex: TNativeIntBitIndex]: boolean read GetBit write PutBit;
  1408. property Nibbles [aIndex: TNativeIntNibbleIndex]: nibble read GetNibble write PutNibble;
  1409. // NativeInt on cpu16 has 2 bytes, so no need for cpu16 check because we always need Byte[]
  1410. property Bytes [aIndex: TNativeIntByteIndex]: byte read GetByte write PutByte;
  1411. {$if sizeof(NativeInt)>=4}
  1412. property Words [aIndex: TNativeIntWordIndex]: word read GetWord write PutWord;
  1413. {$endif}
  1414. {$if sizeof(NativeInt)>=8}
  1415. property DWords [aIndex: TNativeIntDwordIndex]: dword read GetDWord write PutDWord;
  1416. {$endif}
  1417. end;
  1418. // TNativeUIntBitIndex is already defined
  1419. {$if sizeof(NativeUInt)=2}
  1420. TNativeUIntNibbleIndex = TWordNibbleIndex;
  1421. TNativeUIntByteIndex = TWordByteIndex;
  1422. TNativeUIntOverlay = TWordOverlay;
  1423. {$elseif sizeof(NativeUInt)=4}
  1424. TNativeUIntNibbleIndex = TDwordNibbleIndex;
  1425. TNativeUIntByteIndex = TDwordByteIndex;
  1426. TNativeUIntWordIndex = TDwordWordIndex;
  1427. TNativeUIntOverlay = TDwordOverlay;
  1428. {$elseif sizeof(NativeUInt)=8}
  1429. TNativeUIntNibbleIndex = TQwordNibbleIndex;
  1430. TNativeUIntByteIndex = TQwordByteIndex;
  1431. TNativeUIntWordIndex = TQwordWordIndex;
  1432. TNativeUIntDwordIndex = TQwordDWordIndex;
  1433. TNativeUIntOverlay = TQwordOverlay;
  1434. {$else}
  1435. {$fatal Unsupported NativeUInt type size}
  1436. {$endif}
  1437. TNativeUIntHelper = Type Helper for NativeUInt
  1438. const
  1439. MaxValue = High(NativeUInt);
  1440. MinValue = 0;
  1441. MaxBit = High(TNativeUIntBitIndex);
  1442. MinBit = Low(TNativeUIntBitIndex);
  1443. MaxNibble = High(TNativeUIntNibbleIndex);
  1444. MinNibble = Low(TNativeUIntNibbleIndex);
  1445. // NativeInt on cpu16 has 2 bytes, so no need for cpu16 check because we always need MaxByte and MinByte
  1446. MaxByte = High(TNativeUIntByteIndex);
  1447. MinByte = Low(TNativeUIntByteIndex);
  1448. {$if sizeof(NativeUInt)>=4}
  1449. MaxWord = High(TNativeUIntWordIndex);
  1450. MinWord = Low(TNativeUIntWordIndex);
  1451. {$endif}
  1452. {$if sizeof(NativeUInt)>=8}
  1453. MaxDword = High(TNativeUIntDwordIndex);
  1454. MinDword = Low(TNativeUIntDwordIndex);
  1455. {$endif}
  1456. public
  1457. Class Function Parse(const AString: string): NativeUInt; inline; static;
  1458. Class Function Size: Integer; inline; static;
  1459. Class Function ToString(const AValue: NativeUInt): string; overload; inline; static;
  1460. Class Function TryParse(const AString: string; out AValue: NativeUInt): Boolean; inline; static;
  1461. protected
  1462. function GetBit(const aIndex: TNativeUIntBitIndex): boolean; inline;
  1463. procedure PutBit(const aIndex: TNativeUIntBitIndex; const aNewValue: boolean); inline;
  1464. function GetNibble(const aIndex: TNativeUIntNibbleIndex): nibble; inline;
  1465. procedure PutNibble(const aIndex: TNativeUIntNibbleIndex; const aNewValue: nibble); inline;
  1466. // NativeInt on cpu16 has 2 bytes, so no need for cpu16 check because we always need GetByte and PutByte
  1467. function GetByte(const aIndex: TNativeUIntByteIndex): byte;
  1468. procedure PutByte(const aIndex: TNativeUIntByteIndex; const aNewValue: byte);
  1469. {$if sizeof(NativeUInt)>=4}
  1470. function GetWord(const aIndex: TNativeUIntWordIndex): word;
  1471. procedure PutWord(const aIndex: TNativeUIntWordIndex; const aNewValue: word);
  1472. {$endif}
  1473. {$if sizeof(NativeUInt)>=8}
  1474. function GetDword(const aIndex: TNativeUIntDwordIndex): dword;
  1475. procedure PutDword(const aIndex: TNativeUIntDwordIndex; const aNewValue: dword);
  1476. {$endif}
  1477. public
  1478. Function ToBoolean: Boolean; inline;
  1479. Function ToDouble: Double; inline;
  1480. Function ToExtended: Extended; inline;
  1481. Function ToBinString:string; inline;
  1482. Function ToHexString(const AMinDigits: Integer): string; overload; inline;
  1483. Function ToHexString: string; overload; inline;
  1484. Function ToSingle: Single; inline;
  1485. Function ToString: string; overload; inline;
  1486. Function SetBit(const Index: TNativeUIntBitIndex) : NativeUint; inline;
  1487. Function ClearBit(const Index: TNativeUIntBitIndex): NativeUint; inline;
  1488. Function ToggleBit(const Index: TNativeUIntBitIndex) : NativeUint; inline;
  1489. Function TestBit(const Index:TNativeUIntBitIndex) :Boolean; inline;
  1490. procedure Clear; inline;
  1491. function HighestSetBitPos: int8; inline;
  1492. function LowestSetBitPos: int8; inline;
  1493. function SetBitsCount: byte; inline;
  1494. property Bits [aIndex: TNativeUIntBitIndex]: boolean read GetBit write PutBit;
  1495. property Nibbles [aIndex: TNativeUIntNibbleIndex]: nibble read GetNibble write PutNibble;
  1496. // NativeInt on cpu16 has 2 bytes, so no need for cpu16 check because we always need Byte[]
  1497. property Bytes [aIndex: TNativeUIntByteIndex]: byte read GetByte write PutByte;
  1498. {$if sizeof(NativeUInt)>=4}
  1499. property Words [aIndex: TNativeUIntWordIndex]: word read GetWord write PutWord;
  1500. {$endif}
  1501. {$if sizeof(NativeUInt)>=8}
  1502. property DWords [aIndex: TNativeUIntDwordIndex]: dword read GetDWord write PutDWord;
  1503. {$endif}
  1504. end;
  1505. {$SCOPEDENUMS ON}
  1506. TUseBoolStrs = (False, True);
  1507. {$SCOPEDENUMS OFF}
  1508. TBooleanHelper = Type Helper for Boolean
  1509. public
  1510. Class Function Parse(const S: string): Boolean; inline; static;
  1511. Class Function Size: Integer; inline; static;
  1512. Class Function ToString(const AValue: Boolean; UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline; static;
  1513. Class Function TryToParse(const S: string; out AValue: Boolean): Boolean; inline; static;
  1514. Public
  1515. Function ToInteger: Integer; inline;
  1516. Function ToString(UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline;
  1517. end;
  1518. TBoolean8Helper = Type Helper for Boolean8
  1519. public
  1520. Class Function Parse(const S: string): Boolean; inline; static;
  1521. Class Function Size: Integer; inline; static;
  1522. Class Function ToString(const AValue: Boolean; UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline; static;
  1523. Class Function TryToParse(const S: string; out AValue: Boolean): Boolean; inline; static;
  1524. Public
  1525. Function ToInteger: Integer; inline;
  1526. Function ToString(UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline;
  1527. end;
  1528. TBoolean16Helper = Type Helper for Boolean16
  1529. public
  1530. Class Function Parse(const S: string): Boolean; inline; static;
  1531. Class Function Size: Integer; inline; static;
  1532. Class Function ToString(const AValue: Boolean; UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline; static;
  1533. Class Function TryToParse(const S: string; out AValue: Boolean): Boolean; inline; static;
  1534. Public
  1535. Function ToInteger: Integer; inline;
  1536. Function ToString(UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline;
  1537. end;
  1538. TBoolean32Helper = Type Helper for Boolean32
  1539. public
  1540. Class Function Parse(const S: string): Boolean; inline; static;
  1541. Class Function Size: Integer; inline; static;
  1542. Class Function ToString(const AValue: Boolean; UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline; static;
  1543. Class Function TryToParse(const S: string; out AValue: Boolean): Boolean; inline; static;
  1544. Public
  1545. Function ToInteger: Integer; inline;
  1546. Function ToString(UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline;
  1547. end;
  1548. TBoolean64Helper = Type Helper for Boolean64
  1549. public
  1550. Class Function Parse(const S: string): Boolean; inline; static;
  1551. Class Function Size: Integer; inline; static;
  1552. Class Function ToString(const AValue: Boolean; UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline; static;
  1553. Class Function TryToParse(const S: string; out AValue: Boolean): Boolean; inline; static;
  1554. Public
  1555. Function ToInteger: Integer; inline;
  1556. Function ToString(UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline;
  1557. end;
  1558. TByteBoolHelper = Type Helper for ByteBool
  1559. public
  1560. Class Function Parse(const S: string): Boolean; inline; static;
  1561. Class Function Size: Integer; inline; static;
  1562. Class Function ToString(const AValue: Boolean; UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline; static;
  1563. Class Function TryToParse(const S: string; out AValue: Boolean): Boolean; inline; static;
  1564. Public
  1565. Function ToInteger: Integer; inline;
  1566. Function ToString(UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline;
  1567. end;
  1568. TWordBoolHelper = Type Helper for WordBool
  1569. public
  1570. Class Function Parse(const S: string): Boolean; inline; static;
  1571. Class Function Size: Integer; inline; static;
  1572. Class Function ToString(const AValue: Boolean; UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline; static;
  1573. Class Function TryToParse(const S: string; out AValue: Boolean): Boolean; inline; static;
  1574. Public
  1575. Function ToInteger: Integer; inline;
  1576. Function ToString(UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline;
  1577. end;
  1578. TLongBoolHelper = Type Helper for LongBool
  1579. public
  1580. Class Function Parse(const S: string): Boolean; inline; static;
  1581. Class Function Size: Integer; inline; static;
  1582. Class Function ToString(const AValue: Boolean; UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline; static;
  1583. Class Function TryToParse(const S: string; out AValue: Boolean): Boolean; inline; static;
  1584. public
  1585. Function ToInteger: Integer; inline;
  1586. Function ToString(UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline;
  1587. end;
  1588. TQWordBoolHelper = Type Helper for QWordBool
  1589. public
  1590. Class Function Parse(const S: string): Boolean; inline; static;
  1591. Class Function Size: Integer; inline; static;
  1592. Class Function ToString(const AValue: Boolean; UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline; static;
  1593. Class Function TryToParse(const S: string; out AValue: Boolean): Boolean; inline; static;
  1594. public
  1595. Function ToInteger: Integer; inline;
  1596. Function ToString(UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline;
  1597. end;