syshelph.inc 102 KB

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