12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751 |
- {%mainunit syshelpers.pp}
- { ---------------------------------------------------------------------
- TGUIDHelper
- ---------------------------------------------------------------------}
- Procedure NotImplemented(S : String);
- begin
- Raise Exception.Create('Not yet implemented : '+S);
- end;
- Class function TGUIDHelper.Create(const Data; BigEndian: Boolean): TGUID; overload; static;
- Const
- GUIDSize = SizeOf(TGUID);
- Var
- B : Array[1..GUIDSize] of Byte;
- begin
- Move(Data,B,GUIDSize);
- Result:=Create(B,0,BigEndian);
- end;
- class function TGUIDHelper.Create(const Data: array of Byte; AStartIndex: Cardinal; BigEndian: Boolean): TGUID; overload; static;
- Var
- A : Cardinal;
- B,C : Word;
- begin
- if ((System.Length(Data)-AStartIndex)<16) then
- raise EArgumentException.CreateFmt('The length of a GUID array must be at least %d',[]);
- Move(Data[AStartIndex],A,SizeOf(Cardinal));
- Move(Data[AStartIndex+4],B,SizeOf(Word));
- Move(Data[AStartIndex+6],C,SizeOf(Word));
- // Writeln('BigEndian : ',BigEndian,', CPU bigendian : ',(CPUendian=TEndian.Big));
- if BigEndian<>(CPUendian=TEndian.Big) then
- begin
- // Writeln('Swapping');
- A:=SwapEndian(A);
- B:=SwapEndian(B);
- C:=SwapEndian(C);
- end;
- Result:=Create(A,B,C,Data[AStartIndex+8],Data[AStartIndex+9],Data[AStartIndex+10],Data[AStartIndex+11],Data[AStartIndex+12],Data[AStartIndex+13],Data[AStartIndex+14],Data[AStartIndex+15]);
- end;
- Class Function TGUIDHelper.Create(const Data; DataEndian: TEndian = CPUEndian): TGUID; overload; static; inline;
- begin
- Result:=Create(Data,DataEndian=TEndian.Big)
- end;
- Class Function TGUIDHelper.Create(const B: TBytes; DataEndian: TEndian = CPUEndian): TGUID; overload; static; inline;
- begin
- Result:=Create(B,0,DataEndian);
- end;
- Class Function TGUIDHelper.Create(const B: TBytes; AStartIndex: Cardinal; DataEndian: TEndian = CPUEndian): TGUID; overload; static;
- begin
- if ((System.Length(B)-AStartIndex)<16) then
- raise EArgumentException.CreateFmt('The length of a GUID array must be at least %d',[]);
- Result:=Create(B,AStartIndex,DataEndian=TEndian.Big);
- end;
- Class Function TGUIDHelper.Create(const S: string): TGUID; overload; static;
- begin
- Result:=StringToGUID(S);
- end;
- Class Function TGUIDHelper.Create(A: Integer; B: SmallInt; C: SmallInt; const D: TBytes): TGUID; overload; static;
- begin
- if (System.Length(D)<>8) then
- raise EArgumentException.CreateFmt('The length of a GUID array must be %d',[]);
- Result:=Create(Cardinal(A),Word(B),Word(C),D[0],D[1],D[2],D[3],D[4],D[5],D[6],D[7]);
- end;
- Class Function TGUIDHelper.Create(A: Integer; B: SmallInt; C: SmallInt; D, E, F, G, H, I, J, K: Byte): TGUID; overload; static;
- begin
- Result:=Create(Cardinal(A),Word(B),Word(C),D,E,F,G,H,I,J,K);
- end;
- Class Function TGUIDHelper.Create(A: Cardinal; B: Word; C: Word; D, E, F, G, H, I, J, K: Byte): TGUID; overload; static;
- begin
- Result.D1 := Cardinal(A);
- Result.D2 := Word(B);
- Result.D3 := Word(C);
- Result.D4[0] := D;
- Result.D4[1] := E;
- Result.D4[2] := F;
- Result.D4[3] := G;
- Result.D4[4] := H;
- Result.D4[5] := I;
- Result.D4[6] := J;
- Result.D4[7] := K;
- end;
- Class Function TGUIDHelper.NewGuid: TGUID; static;
- begin
- CreateGUID(Result)
- end;
- Function TGUIDHelper.ToByteArray(DataEndian: TEndian = CPUEndian): TBytes;
- begin
- SetLength(Result, 16);
- if DataEndian<>CPUEndian then
- begin
- PCardinal(@Result[0])^ := SwapEndian(D1);
- PWord(@Result[4])^ := SwapEndian(D2);
- PWord(@Result[6])^ := SwapEndian(D3);
- Move(D4, Result[8], 8);
- end
- else
- Move(D1, Result[0], SizeOf(Self));
- end;
- Function TGUIDHelper.ToString(SkipBrackets : Boolean = False): string;
- begin
- Result:=GuidToString(Self);
- If SkipBrackets then
- Result:=Copy(Result,2,Length(Result)-2);
- end;
- { ---------------------------------------------------------------------
- TStringHelper
- ---------------------------------------------------------------------}
- Function HaveChar(AChar : Char; const AList: array of Char) : Boolean;
- Var
- I : SizeInt;
- begin
- I:=0;
- Result:=False;
- While (Not Result) and (I<Length(AList)) do
- begin
- Result:=(AList[i]=AChar);
- Inc(I);
- end;
- end;
- function TStringHelper.GetChar(AIndex: SizeInt): Char;
- begin
- Result:=Self[AIndex+1];
- end;
- function TStringHelper.GetLength: SizeInt;
- begin
- Result:=System.Length(Self);
- end;
- class function TStringHelper.Compare(const A: string; const B: string): Integer;
- begin
- Result:=Compare(A,0,B,0,System.Length(B),[]);
- end;
- class function TStringHelper.Compare(const A: string; const B: string;
- IgnoreCase: Boolean): Integer; //deprecated 'Use same with TCompareOptions';
- begin
- if IgnoreCase then
- Result:=Compare(A,B,[coIgnoreCase])
- else
- Result:=Compare(A,B,[]);
- end;
- class function TStringHelper.Compare(const A: string; const B: string;
- Options: TCompareOptions): Integer;
- begin
- Result:=Compare(A,0,B,0,System.Length(B),Options);
- end;
- class function TStringHelper.Compare(const A: string; IndexA: SizeInt;
- const B: string; IndexB: SizeInt; ALen: SizeInt): Integer;
- begin
- Result:=Compare(A,IndexA,B,IndexB,ALen,[]);
- end;
- class function TStringHelper.Compare(const A: string; IndexA: SizeInt;
- const B: string; IndexB: SizeInt; ALen: SizeInt; IgnoreCase: Boolean
- ): Integer; //deprecated 'Use same with TCompareOptions';
- begin
- if IgnoreCase then
- Result:=Compare(A,IndexA,B,IndexB,ALen,[coIgnoreCase])
- else
- Result:=Compare(A,IndexA,B,IndexB,ALen,[])
- end;
- class function TStringHelper.Compare(const A: string; IndexA: SizeInt;
- const B: string; IndexB: SizeInt; ALen: SizeInt; Options: TCompareOptions
- ): Integer;
- Var
- L : SizeInt;
- begin
- L:=ALen;
- If (L>system.Length(A)-IndexA) then
- L:=system.Length(A)-IndexA;
- If (L>system.Length(B)-IndexB) then
- L:=system.Length(B)-IndexB;
- if (coIgnoreCase in Options) then
- begin
- Result:=strlicomp(PAnsiChar(@A[IndexA+1]),PAnsiChar(@B[IndexB+1]),L)
- end
- else
- Result:=strlcomp(PAnsiChar(@A[IndexA+1]),PAnsiChar(@B[IndexB+1]),L);
- end;
- class function TStringHelper.CompareOrdinal(const A: string; const B: string
- ): Integer;
- Var
- L : SizeInt;
- begin
- L:=System.Length(B);
- if L>System.Length(A) then
- L:=System.Length(A);
- Result:=CompareOrdinal(A,0,B,0,L);
- end;
- class function TStringHelper.CompareOrdinal(const A: string; IndexA: SizeInt;
- const B: string; IndexB: SizeInt; ALen: SizeInt): Integer;
- begin
- Result:=StrLComp(PAnsiChar(@A[IndexA+1]), PAnsiChar(@B[IndexB+1]), ALen);
- end;
- class function TStringHelper.CompareText(const A: string; const B: string
- ): Integer;
- begin
- Result:=Sysutils.CompareText(A,B);
- end;
- class function TStringHelper.Copy(const Str: string): string;
- begin
- Result:=Str;
- UniqueString(Result);
- end;
- class function TStringHelper.Create(AChar: Char; ACount: SizeInt): string;
- begin
- Result:=StringOfChar(AChar,ACount);
- end;
- class function TStringHelper.Create(const AValue: array of Char): string;
- begin
- Result:=Create(AValue,0,System.Length(AValue));
- end;
- class function TStringHelper.Create(const AValue: array of Char;
- StartIndex: SizeInt; ALen: SizeInt): string;
- begin
- SetLength(Result,ALen);
- if ALen>0 then
- Move(AValue[StartIndex],Result[1],ALen);
- end;
- class function TStringHelper.EndsText(const ASubText, AText: string): Boolean;
- begin
- Result:=(ASubText<>'') and (sysutils.CompareText(System.Copy(AText,System.Length(AText)-System.Length(ASubText)+1,System.Length(ASubText)),ASubText)=0);
- end;
- class function TStringHelper.Equals(const a: string; const b: string): Boolean;
- begin
- Result:=A=B;
- end;
- class function TStringHelper.Format(const AFormat: string;
- const args: array of const): string;
- begin
- Result:=Sysutils.Format(AFormat,Args);
- end;
- class function TStringHelper.IsNullOrEmpty(const AValue: string): Boolean;
- begin
- Result:=system.Length(AValue)=0;
- end;
- class function TStringHelper.IsNullOrWhiteSpace(const AValue: string): Boolean;
- begin
- Result:=system.Length(SysUtils.Trim(AValue))=0;
- end;
- class function TStringHelper.Join(const Separator: string;
- const Values: array of const): string;
- Var
- SValues : Array of string;
- I,L : SizeInt;
- S : String;
- P : ^TVarRec;
- begin
- L:=System.Length(Values);
- SetLength(SValues,L);
- Dec(L);
- for I:=0 to L do
- begin
- S:='';
- P:=@Values[I];
- Case P^.VType of
- vtInteger : S:=IntToStr(P^.VInteger);
- vtBoolean : S:=BoolToStr(P^.VBoolean, True);
- vtChar : S:=P^.VChar;
- vtPChar : S:= string(P^.VPChar);
- {$ifndef FPUNONE}
- vtExtended : S:=FloatToStr(P^.VExtended^);
- {$endif}
- vtObject : S:=TObject(P^.VObject).Classname;
- vtClass : S:=P^.VClass.Classname;
- vtCurrency : S:=CurrToStr(P^.VCurrency^);
- vtVariant : S:=(P^.VVariant^);
- vtInt64 : S:=IntToStr(PInt64(P^.VInt64)^);
- vtQword : S:=IntToStr(PQWord(P^.VQword)^);
- vtWideChar : S:=WideString(P^.VWideChar);
- vtPWideChar : S:=WideString(P^.VPWideChar);
- vtUnicodeString : S:=UnicodeString(P^.VUnicodeString);
- vtAnsiString : S:=Ansistring(P^.VAnsiString);
- else
- S:=Format('Unknown type: %d',[P^.VType]);
- end;
- SValues[I]:=S;
- end;
- Result:=Join(Separator,SValues);
- end;
- class function TStringHelper.Join(const Separator: string;
- const Values: array of string): string;
- begin
- Result:=Join(Separator,Values,0,System.Length(Values));
- end;
- class function TStringHelper.Join(const Separator: string;
- const Values: array of string; StartIndex: SizeInt; ACount: SizeInt): string;
- Var
- VLen,I,CountLim,NR,NSep,N : SizeInt;
- Rp: PChar;
- begin
- VLen:=System.Length(Values);
- If (ACount=0) then
- Exit('');
- CountLim:=VLen-StartIndex;
- if ACount>CountLim then
- ACount:=CountLim;
- If (ACount<0) or (StartIndex>VLen) or (StartIndex<0) then
- raise ERangeError.Create(SRangeError);
- if ACount=1 then
- exit(Values[StartIndex]);
- NSep:=System.Length(Separator);
- NR:=(ACount-1)*NSep;
- for I:=StartIndex to StartIndex+ACount-1 do
- NR:=NR+System.Length(Values[I]);
- SetLength(Result,NR);
- Rp:=@Result[1];
- for I:=StartIndex to StartIndex+ACount-1 do
- begin
- if I>StartIndex then
- begin
- Move(separator[1],Rp^,NSep*sizeof(Char));
- Rp:=Rp+NSep;
- end;
- N:=System.Length(Values[I]);
- Move(Values[I][1],Rp^,N*sizeof(Char));
- Rp:=Rp+N;
- end;
- end;
- class function TStringHelper.LowerCase(const S: string): string;
- begin
- Result:=sysutils.Lowercase(S);
- end;
- class function TStringHelper.Parse(const AValue: Boolean): string;
- begin
- Result:=BoolToStr(AValue);
- end;
- class function TStringHelper.Parse(const AValue: Extended): string;
- begin
- Result:=FloatToStr(AValue);
- end;
- class function TStringHelper.Parse(const AValue: Int64): string;
- begin
- Result:=IntToStr(AValue);
- end;
- class function TStringHelper.Parse(const AValue: Integer): string;
- begin
- Result:=IntToStr(AValue);
- end;
- class function TStringHelper.ToBoolean(const S: string): Boolean;
- begin
- Result:=StrToBool(S);
- end;
- class function TStringHelper.ToDouble(const S: string): Double;
- begin
- Result:=StrToFloat(S);
- end;
- class function TStringHelper.ToExtended(const S: string): Extended;
- begin
- Result:=StrToFloat(S);
- end;
- class function TStringHelper.ToInt64(const S: string): Int64;
- begin
- Result:=StrToInt64(S);
- end;
- class function TStringHelper.ToInteger(const S: string): Integer;
- begin
- Result:=StrToInt(S);
- end;
- class function TStringHelper.ToSingle(const S: string): Single;
- begin
- Result:=StrToFloat(S);
- end;
- class function TStringHelper.UpperCase(const S: string): string;
- begin
- Result:=sysutils.Uppercase(S);
- end;
- function TStringHelper.CompareTo(const B: string): Integer;
- begin
- // Order is important
- Result:=sysUtils.StrComp(PChar(Self),PChar(B));
- end;
- procedure TStringHelper.CopyTo(SourceIndex: SizeInt; var destination: array of Char; DestinationIndex: SizeInt; ACount: SizeInt);
- Var
- P1,P2 : PChar;
- begin
- // Writeln('((',DestinationIndex,'+',ACount,')<',System.Length(Destination),') : ', ((DestinationIndex+ACount)<System.Length(Destination)));
- if ((DestinationIndex+ACount)<=System.Length(Destination)) then
- begin
- // Writeln('AHA');
- P1:=@Self[SourceIndex+1];
- P2:=@Destination[DestinationIndex];
- Move(P1^,P2^,ACount*SizeOf(Char));
- end;
- end;
- function TStringHelper.Contains(const AValue: string): Boolean;
- begin
- Result:=Pos(AValue,Self)>0;
- end;
- function TStringHelper.CountChar(const C: Char): SizeInt;
- Var
- S : Char;
- begin
- Result:=0;
- For S in Self do
- if (S=C) then
- Inc(Result);
- end;
- function TStringHelper.DeQuotedString: string;
- begin
- Result:=DeQuotedString('''');
- end;
- function TStringHelper.DeQuotedString(const AQuoteChar: Char): string;
- var
- L,I : SizeInt;
- Res : Array of Char;
- PS,PD : PChar;
- IsQuote : Boolean;
- begin
- L:=System.Length(Self);
- if (L<2) or Not ((Self[1]=AQuoteChar) and (Self[L]=AQuoteChar)) then
- Exit(Self);
- SetLength(Res,L);
- IsQuote:=False;
- PS:=@Self[2];
- PD:=@Res[0];
- For I:=2 to L-1 do
- begin
- if (PS^=AQuoteChar) then
- begin
- IsQuote:=Not IsQuote;
- if Not IsQuote then
- begin
- PD^:=PS^;
- Inc(PD);
- end;
- end
- else
- begin
- if IsQuote then
- IsQuote:=false;
- PD^:=PS^;
- Inc(PD);
- end;
- Inc(PS);
- end;
- SetString(Result,@Res[0],PD-@Res[0]);
- end;
- function TStringHelper.EndsWith(const AValue: string): Boolean;
- begin
- Result:=EndsWith(AValue,False);
- end;
- function TStringHelper.EndsWith(const AValue: string; IgnoreCase: Boolean): Boolean;
- Var
- L : SizeInt;
- S : String;
-
- begin
- L:=system.Length(AVAlue);
- Result:=L=0;
- if Not Result then
- begin
- S:=system.Copy(Self,Length-L+1,L);
- Result:=system.Length(S)=L;
- if Result then
- if IgnoreCase then
- Result:=CompareText(S,AValue)=0
- else
- Result:=S=AValue;
- end;
- end;
- function TStringHelper.Equals(const AValue: string): Boolean;
- begin
- Result:=(Self=AValue);
- end;
- function TStringHelper.Format(const args: array of const): string;
- begin
- Result:=Format(Self,Args);
- end;
- function TStringHelper.GetHashCode: Integer;
- // Taken from contnrs, fphash
- var
- P,pmax : PChar;
- begin
- {$push}
- {$Q-}
- Result:=0;
- P:=Pchar(Self);
- pmax:=p+length;
- while (p<pmax) do
- begin
- Result:=LongWord(LongInt(Result shl 5) - LongInt(Result)) xor LongWord(P^);
- Inc(p);
- end;
- {$pop}
- end;
- function TStringHelper.IndexOf(AValue: Char): SizeInt;
- begin
- Result:=IndexOf(AValue,0,Length);
- end;
- function TStringHelper.IndexOf(const AValue: string): SizeInt;
- begin
- Result:=IndexOf(AValue,0,Length);
- end;
- function TStringHelper.IndexOf(AValue: Char; StartIndex: SizeInt): SizeInt;
- begin
- Result:=IndexOf(AValue,StartIndex,Length);
- end;
- function TStringHelper.IndexOf(const AValue: string; StartIndex: SizeInt
- ): SizeInt;
- begin
- Result:=IndexOf(AValue,StartIndex,Length);
- end;
- function TStringHelper.IndexOf(AValue: Char; StartIndex: SizeInt;
- ACount: SizeInt): SizeInt;
- Var
- CountLim : SizeInt;
- begin
- if StartIndex<0 then
- StartIndex:=0;
- CountLim:=System.Length(Self)-StartIndex;
- if ACount>CountLim then
- ACount:=CountLim;
- if ACount<=0 then
- Exit(-1);
- // pointer casts are to access self as 0 based index!
- Result:=IndexChar(PChar(Pointer(self))[StartIndex],ACount,AValue);
- if Result>=0 then
- Result:=Result+StartIndex;
- end;
- function TStringHelper.IndexOf(const AValue: string; StartIndex: SizeInt;
- ACount: SizeInt): SizeInt;
- Var
- CountLim,NV,Ofs : SizeInt;
- SP,SE : PChar;
- begin
- if StartIndex<0 then
- StartIndex:=0;
- CountLim:=System.Length(Self)-StartIndex;
- if ACount>CountLim then
- ACount:=CountLim;
- NV:=System.Length(AValue);
- if (NV>0) and (ACount>=NV) then
- begin
- SP:=PChar(Pointer(Self))+StartIndex;
- SE:=SP+ACount-NV+1;
- repeat
- Ofs:=IndexChar(SP^,SE-SP,PChar(Pointer(AValue))[0]);
- if Ofs<0 then
- Break;
- SP:=SP+Ofs+1;
- if CompareChar(SP^,PChar(Pointer(AValue))[1],NV-1)=0 then
- Exit(SP-PChar(Pointer(Self))-1);
- until false;
- end;
- Result:=-1;
- end;
- function TStringHelper.IndexOfUnQuoted(const AValue: string; StartQuote,
- EndQuote: Char; StartIndex: SizeInt = 0): SizeInt;
- Var
- LV : SizeInt;
- Function MatchAt(I : SizeInt) : Boolean ; Inline;
- Var
- J : SizeInt;
- begin
- J:=1;
- Repeat
- Result:=(Self[I+J-1]=AValue[j]);
- Inc(J);
- Until (Not Result) or (J>LV);
- end;
- Var
- I,L,Q: SizeInt;
- begin
- Result:=-1;
- LV:=system.Length(AValue);
- L:=Length-LV+1;
- if L<0 then
- L:=0;
- I:=StartIndex+1;
- Q:=0;
- if StartQuote=EndQuote then
- begin
- While (Result=-1) and (I<=L) do
- begin
- if (Self[I]=StartQuote) then
- Q:=1-Q;
- if (Q=0) and MatchAt(i) then
- Result:=I-1;
- Inc(I);
- end;
- end
- else
- begin
- While (Result=-1) and (I<=L) do
- begin
- if Self[I]=StartQuote then
- Inc(Q)
- else if (Self[I]=EndQuote) and (Q>0) then
- Dec(Q);
- if (Q=0) and MatchAt(i) then
- Result:=I-1;
- Inc(I);
- end;
- end;
- end;
- function TStringHelper.IndexOfAny(const AnyOf: array of Char): SizeInt;
- begin
- Result:=IndexOfAny(AnyOf,0,Length);
- end;
- function TStringHelper.IndexOfAny(const AnyOf: array of Char;
- StartIndex: SizeInt): SizeInt;
- begin
- Result:=IndexOfAny(AnyOf,StartIndex,Length);
- end;
- function TStringHelper.IndexOfAny(const AnyOf: array of Char;
- StartIndex: SizeInt; ACount: SizeInt): SizeInt;
- Var
- i,L : SizeInt;
- begin
- I:=StartIndex+1;
- L:=I+ACount-1;
- If L>Length then
- L:=Length;
- Result:=-1;
- While (Result=-1) and (I<=L) do
- begin
- if HaveChar(Self[i],AnyOf) then
- Result:=I-1;
- Inc(I);
- end;
- end;
- function TStringHelper.IndexOfAny(const AnyOf: array of String): SizeInt;
- begin
- Result:=IndexOfAny(AnyOf,0,Length);
- end;
- function TStringHelper.IndexOfAny(const AnyOf: array of String;
- StartIndex: SizeInt): SizeInt;
- begin
- Result:=IndexOfAny(AnyOf,StartIndex,Length-StartIndex);
- end;
- function TStringHelper.IndexOfAny(const AnyOf: array of String;
- StartIndex: SizeInt; ACount: SizeInt): SizeInt;
- Var
- M : SizeInt;
- begin
- Result:=IndexOfAny(AnyOf,StartIndex,ACount,M);
- end;
- function TStringHelper.IndexOfAny(const AnyOf: array of String;
- StartIndex: SizeInt; ACount: SizeInt; out AMatch: SizeInt): SizeInt;
- Var
- L,I : SizeInt;
- begin
- Result:=-1;
- For I:=0 to System.Length(AnyOf)-1 do
- begin
- L:=IndexOf(AnyOf[i],StartIndex,ACount);
- If (L>=0) and ((Result=-1) or (L<Result)) then
- begin
- Result:=L;
- AMatch:=I;
- end;
- end;
- end;
- function TStringHelper.IndexOfAnyUnquoted(const AnyOf: array of Char;
- StartQuote, EndQuote: Char): SizeInt;
- begin
- Result:=IndexOfAnyUnquoted(AnyOf,StartQuote,EndQuote,0,Length);
- end;
- function TStringHelper.IndexOfAnyUnquoted(const AnyOf: array of Char;
- StartQuote, EndQuote: Char; StartIndex: SizeInt): SizeInt;
- begin
- Result:=IndexOfAnyUnquoted(AnyOf,StartQuote,EndQuote,StartIndex,Length);
- end;
- function TStringHelper.IndexOfAnyUnquoted(const AnyOf: array of Char;
- StartQuote, EndQuote: Char; StartIndex: SizeInt; ACount: SizeInt): SizeInt;
- Var
- I,L : SizeInt;
- Q : SizeInt;
- begin
- Result:=-1;
- L:=StartIndex+ACount-1;
- if L>Length then
- L:=Length;
- I:=StartIndex+1;
- Q:=0;
- if StartQuote=EndQuote then
- begin
- While (Result=-1) and (I<=L) do
- begin
- if (Self[I]=StartQuote) then
- Q:=1-Q;
- if (Q=0) and HaveChar(Self[i],AnyOf) then
- Result:=I-1;
- Inc(I);
- end;
- end
- else
- begin
- While (Result=-1) and (I<=L) do
- begin
- if Self[I]=StartQuote then
- Inc(Q)
- else if (Self[I]=EndQuote) and (Q>0) then
- Dec(Q);
- if (Q=0) and HaveChar(Self[i],AnyOf) then
- Result:=I-1;
- Inc(I);
- end;
- end;
- end;
- function TStringHelper.IndexOfAnyUnquoted(const AnyOf: array of string;
- StartQuote, EndQuote: Char; StartIndex: SizeInt; out Matched: SizeInt
- ): SizeInt;
- Var
- L,I : SizeInt;
- begin
- Result:=-1;
- For I:=0 to System.Length(AnyOf)-1 do
- begin
- L:=IndexOfUnquoted(AnyOf[i],StartQuote,EndQuote,StartIndex);
- If (L>=0) and ((Result=-1) or (L<Result)) then
- begin
- Result:=L;
- Matched:=I;
- end;
- end;
- end;
- function TStringHelper.Insert(StartIndex: SizeInt; const AValue: string
- ): string;
- begin
- system.Insert(AValue,Self,StartIndex+1);
- Result:=Self;
- end;
- function TStringHelper.IsDelimiter(const Delimiters: string; Index: SizeInt
- ): Boolean;
- begin
- Result:=sysutils.IsDelimiter(Delimiters,Self,Index+1);
- end;
- function TStringHelper.IsEmpty: Boolean;
- begin
- Result:=(Length=0)
- end;
- function TStringHelper.LastDelimiter(const Delims: string): SizeInt;
- begin
- Result:=sysutils.LastDelimiter(Delims,Self)-1;
- end;
- function TStringHelper.LastIndexOf(AValue: Char): SizeInt;
- begin
- Result:=LastIndexOf(AValue,Length-1,Length);
- end;
- function TStringHelper.LastIndexOf(const AValue: string): SizeInt;
- begin
- Result:=LastIndexOf(AValue,Length-1,Length);
- end;
- function TStringHelper.LastIndexOf(AValue: Char; AStartIndex: SizeInt): SizeInt;
- begin
- Result:=LastIndexOf(AValue,AStartIndex,Length);
- end;
- function TStringHelper.LastIndexOf(const AValue: string; AStartIndex: SizeInt
- ): SizeInt;
- begin
- Result:=LastIndexOf(AValue,AStartIndex,Length);
- end;
- function TStringHelper.LastIndexOf(AValue: Char; AStartIndex: SizeInt;
- ACount: SizeInt): SizeInt;
- Var
- Min : SizeInt;
- begin
- Result:=AStartIndex+1;
- Min:=Result-ACount+1;
- If Min<1 then
- Min:=1;
- While (Result>=Min) and (Self[Result]<>AValue) do
- Dec(Result);
- if Result<Min then
- Result:=-1
- else
- Result:=Result-1;
- end;
- function TStringHelper.LastIndexOf(const AValue: string; AStartIndex: SizeInt; ACount: SizeInt): SizeInt;
-
- var
- I,L,LS,M : SizeInt;
- S : String;
- P : PChar;
-
- begin
- Result:=-1;
- LS:=system.Length(Self);
- L:=system.Length(AValue);
- if (L=0) or (L>LS) then
- Exit;
- P:=PChar(AValue);
- S:=Self;
- I:=AStartIndex+1; // 1 based
- if (I>LS) then
- I:=LS;
- I:=I-L+1;
- M:=AStartIndex-ACount+2; // 1 based
- if M<1 then
- M:=1;
- while (Result=-1) and (I>=M) do
- begin
- if (0=StrLComp(PChar(@S[I]),P,L)) then
- Result:=I-1;
- Dec(I);
- end;
- end;
- function TStringHelper.LastIndexOfAny(const AnyOf: array of Char): SizeInt;
- begin
- Result:=LastIndexOfAny(AnyOf,Length-1,Length);
- end;
- function TStringHelper.LastIndexOfAny(const AnyOf: array of Char;
- AStartIndex: SizeInt): SizeInt;
- begin
- Result:=LastIndexOfAny(AnyOf,AStartIndex,Length);
- end;
- function TStringHelper.LastIndexOfAny(const AnyOf: array of Char;
- AStartIndex: SizeInt; ACount: SizeInt): SizeInt;
- Var
- Min : SizeInt;
- begin
- Result:=AStartIndex+1;
- Min:=Result-ACount+1;
- If Min<1 then
- Min:=1;
- While (Result>=Min) and Not HaveChar(Self[Result],AnyOf) do
- Dec(Result);
- if Result<Min then
- Result:=-1
- else
- Result:=Result-1;
- end;
- function TStringHelper.PadLeft(ATotalWidth: SizeInt): string;
- begin
- Result:=PadLeft(ATotalWidth,' ');
- end;
- function TStringHelper.PadLeft(ATotalWidth: SizeInt; PaddingChar: Char): string;
- Var
- L : SizeInt;
- begin
- Result:=Self;
- L:=ATotalWidth-Length;
- If L>0 then
- Result:=StringOfChar(PaddingChar,L)+Result;
- end;
- function TStringHelper.PadRight(ATotalWidth: SizeInt): string;
- begin
- Result:=PadRight(ATotalWidth,' ');
- end;
- function TStringHelper.PadRight(ATotalWidth: SizeInt; PaddingChar: Char
- ): string;
- Var
- L : SizeInt;
- begin
- Result:=Self;
- L:=ATotalWidth-Length;
- If L>0 then
- Result:=Result+StringOfChar(PaddingChar,L);
- end;
- function TStringHelper.QuotedString: string;
- begin
- Result:=QuotedStr(Self);
- end;
- function TStringHelper.QuotedString(const AQuoteChar: Char): string;
- begin
- Result:=AnsiQuotedStr(Self,AQuoteChar);
- end;
- function TStringHelper.Remove(StartIndex: SizeInt): string;
- begin
- Result:=Remove(StartIndex,Self.Length-StartIndex);
- end;
- function TStringHelper.Remove(StartIndex: SizeInt; ACount: SizeInt): string;
- begin
- Result:=Self;
- System.Delete(Result,StartIndex+1,ACount);
- end;
- function TStringHelper.Replace(OldChar: Char; NewChar: Char): string;
- begin
- Result:=Replace(OldChar,NewChar,[rfReplaceAll]);
- end;
- function TStringHelper.Replace(OldChar: Char; NewChar: Char;
- ReplaceFlags: TReplaceFlags): string;
- var
- Sp,Se,Rp : PChar;
- Ofs : SizeInt;
- begin
- if rfIgnoreCase in ReplaceFlags then
- exit(StringReplace(Self,OldChar,NewChar,ReplaceFlags));
- Sp:=PChar(Pointer(Self));
- Se:=Sp+System.Length(Self);
- Ofs:=IndexChar(Sp^,Se-Sp,OldChar);
- if Ofs<0 then
- exit(Self);
- SetLength(Result,Se-Sp);
- Rp:=PChar(Pointer(Result));
- repeat
- Move(Sp^,Rp^,Ofs*sizeof(Char));
- Sp:=Sp+Ofs+1;
- Rp[Ofs]:=NewChar;
- Rp:=Rp+Ofs+1;
- if not (rfReplaceAll in ReplaceFlags) then
- break;
- { This loop can be removed entirely, but greatly speeds up replacing streaks of characters. }
- while (Sp<Se) and (Sp^=OldChar) do
- begin
- Rp^:=NewChar;
- Sp:=Sp+1;
- Rp:=Rp+1;
- end;
- Ofs:=IndexChar(Sp^,Se-Sp,OldChar);
- until Ofs<0;
- Move(Sp^,Rp^,(Se-Sp)*sizeof(Char));
- end;
- function TStringHelper.Replace(const OldValue: string; const NewValue: string
- ): string;
- begin
- Result:=Replace(OldValue,NewValue,[rfReplaceAll]);
- end;
- function TStringHelper.Replace(const OldValue: string; const NewValue: string;
- ReplaceFlags: TReplaceFlags): string;
- begin
- Result:=StringReplace(Self,OldValue,NewValue,ReplaceFlags);
- end;
- function TStringHelper.Split(const Separators: array of Char): TStringArray;
- begin
- Result:=Split(Separators,#0,#0,Length+1,TStringSplitOptions.None);
- end;
- function TStringHelper.Split(const Separators: array of Char; ACount: SizeInt
- ): TStringArray;
- begin
- Result:=Split(Separators,#0,#0,ACount,TStringSplitOptions.None);
- end;
- function TStringHelper.Split(const Separators: array of Char;
- Options: TStringSplitOptions): TStringArray;
- begin
- Result:=Split(Separators,Length+1,Options);
- end;
- function TStringHelper.Split(const Separators: array of Char; ACount: SizeInt;
- Options: TStringSplitOptions): TStringArray;
- begin
- Result:=Split(Separators,#0,#0,ACount,Options);
- end;
- function TStringHelper.Split(const Separators: array of string): TStringArray;
- begin
- Result:=Split(Separators,Length+1);
- end;
- function TStringHelper.Split(const Separators: array of string; ACount: SizeInt
- ): TStringArray;
- begin
- Result:=Split(Separators,ACount,TStringSplitOptions.None);
- end;
- function TStringHelper.Split(const Separators: array of string;
- Options: TStringSplitOptions): TStringArray;
- begin
- Result:=Split(Separators,Length+1,Options);
- end;
- function TStringHelper.Split(const Separators: array of string;
- ACount: SizeInt; Options: TStringSplitOptions): TStringArray;
- begin
- Result:=Split(Separators,#0,#0,ACount,Options);
- end;
- function TStringHelper.Split(const Separators: array of Char; AQuote: Char
- ): TStringArray;
- begin
- Result:=Split(Separators,AQuote,AQuote);
- end;
- function TStringHelper.Split(const Separators: array of Char; AQuoteStart,
- AQuoteEnd: Char): TStringArray;
- begin
- Result:=Split(Separators,AQuoteStart,AQuoteEnd,TStringSplitOptions.None);
- end;
- function TStringHelper.Split(const Separators: array of Char; AQuoteStart,
- AQuoteEnd: Char; Options: TStringSplitOptions): TStringArray;
- begin
- Result:=Split(Separators,AQuoteStart,AQuoteEnd,Length+1,Options);
- end;
- function TStringHelper.Split(const Separators: array of Char; AQuoteStart,
- AQuoteEnd: Char; ACount: SizeInt): TStringArray;
- begin
- Result:=Split(Separators,AQuoteStart,AQuoteEnd,ACount,TStringSplitOptions.None);
- end;
- function TStringHelper.Split(const Separators: array of Char; AQuoteStart,
- AQuoteEnd: Char; ACount: SizeInt; Options: TStringSplitOptions): TStringArray;
- Const
- BlockSize = 10;
- Function NextSep(StartIndex : SizeInt) : SizeInt;
- begin
- if (AQuoteStart<>#0) then
- Result:=Self.IndexOfAnyUnQuoted(Separators,AQuoteStart,AQuoteEnd,StartIndex)
- else
- Result:=Self.IndexOfAny(Separators,StartIndex);
- end;
- Procedure MaybeGrow(Curlen : SizeInt);
- begin
- if System.Length(Result)<=CurLen then
- SetLength(Result,System.Length(Result)+BlockSize);
- end;
- Var
- Sep,LastSep,Len : SizeInt;
- T : String;
- begin
- SetLength(Result,BlockSize);
- Len:=0;
- LastSep:=0;
- Sep:=NextSep(0);
- While (Sep<>-1) and ((ACount=0) or (Len<ACount)) do
- begin
- T:=SubString(LastSep,Sep-LastSep);
- // Writeln('Examining >',T,'< at pos ',LastSep,', till pos ',Sep);
- If (T<>'') or (not (TStringSplitOptions.ExcludeEmpty=Options)) then
- begin
- MaybeGrow(Len);
- Result[Len]:=T;
- Inc(Len);
- end;
- LastSep:=Sep+1;
- Sep:=NextSep(LastSep);
- end;
- if (LastSep<=Length) and ((ACount=0) or (Len<ACount)) then
- begin
- T:=SubString(LastSep);
- // Writeln('Examining >',T,'< at pos,',LastSep,' till pos ',Sep);
- If (T<>'') or (not (TStringSplitOptions.ExcludeEmpty=Options)) then
- begin
- MaybeGrow(Len);
- Result[Len]:=T;
- Inc(Len);
- end;
- end;
- if (TStringSplitOptions.ExcludeLastEmpty=Options) then
- if (Len > 0) and (Result[Len-1] = '') then
- dec(Len);
- SetLength(Result,Len);
- end;
- function TStringHelper.Split(const Separators: array of string; AQuote: Char
- ): TStringArray;
- begin
- Result:=SPlit(Separators,AQuote,AQuote);
- end;
- function TStringHelper.Split(const Separators: array of string; AQuoteStart,
- AQuoteEnd: Char): TStringArray;
- begin
- Result:=SPlit(Separators,AQuoteStart,AQuoteEnd,Length+1,TStringSplitOptions.None);
- end;
- function TStringHelper.Split(const Separators: array of string; AQuoteStart,
- AQuoteEnd: Char; Options: TStringSplitOptions): TStringArray;
- begin
- Result:=SPlit(Separators,AQuoteStart,AQuoteEnd,Length+1,Options);
- end;
- function TStringHelper.Split(const Separators: array of string; AQuoteStart,
- AQuoteEnd: Char; ACount: SizeInt): TStringArray;
- begin
- Result:=SPlit(Separators,AQuoteStart,AQuoteEnd,ACount,TStringSplitOptions.None);
- end;
- function TStringHelper.Split(const Separators: array of string; AQuoteStart,
- AQuoteEnd: Char; ACount: SizeInt; Options: TStringSplitOptions): TStringArray;
- Const
- BlockSize = 10;
- Function NextSep(StartIndex : SizeInt; out Match : SizeInt) : SizeInt;
- begin
- if (AQuoteStart<>#0) then
- Result:=Self.IndexOfAnyUnQuoted(Separators,AQuoteStart,AQuoteEnd,StartIndex,Match)
- else
- Result:=Self.IndexOfAny(Separators,StartIndex,Length,Match);
- if Result<>-1 then
- end;
- Procedure MaybeGrow(Curlen : SizeInt);
- begin
- if System.Length(Result)<=CurLen then
- SetLength(Result,System.Length(Result)+BlockSize);
- end;
- Var
- Sep,LastSep,Len,Match : SizeInt;
- T : String;
- begin
- SetLength(Result,BlockSize);
- Len:=0;
- LastSep:=0;
- Sep:=NextSep(0,Match);
- While (Sep<>-1) and ((ACount=0) or (Len<ACount)) do
- begin
- T:=SubString(LastSep,Sep-LastSep);
- If (T<>'') or (not (TStringSplitOptions.ExcludeEmpty=Options)) then
- begin
- MaybeGrow(Len);
- Result[Len]:=T;
- Inc(Len);
- end;
- LastSep:=Sep+System.Length(Separators[Match]);
- Sep:=NextSep(LastSep,Match);
- end;
- if (LastSep<=Length) and ((ACount=0) or (Len<ACount)) then
- begin
- T:=SubString(LastSep);
- // Writeln('Examining >',T,'< at pos,',LastSep,' till pos ',Sep);
- If (T<>'') or (not (TStringSplitOptions.ExcludeEmpty=Options)) then
- begin
- MaybeGrow(Len);
- Result[Len]:=T;
- Inc(Len);
- end;
- end;
- If (TStringSplitOptions.ExcludeLastEmpty=Options) then
- if (Len > 0) and (Result[Len-1] = '') then
- dec(Len);
- SetLength(Result,Len);
- end;
- function TStringHelper.StartsWith(const AValue: string): Boolean;
- begin
- Result:=StartsWith(AValue,False);
- end;
- function TStringHelper.StartsWith(const AValue: string; IgnoreCase: Boolean
- ): Boolean;
- Var
- L : SizeInt;
- S : String;
-
- begin
- L:=System.Length(AValue);
- Result:=L<=0;
- if not Result then
- begin
- S:=System.Copy(Self,1,L);
- Result:=(System.Length(S)=L);
- if Result then
- if IgnoreCase then
- Result:=SameText(S,aValue)
- else
- Result:=SameStr(S,AValue);
- end;
- end;
- function TStringHelper.Substring(AStartIndex: SizeInt): string;
- begin
- Result:=Self.SubString(AStartIndex,Self.Length-AStartIndex);
- end;
- function TStringHelper.Substring(AStartIndex: SizeInt; ALen: SizeInt): string;
- begin
- Result:=system.Copy(Self,AStartIndex+1,ALen);
- end;
- function TStringHelper.ToBoolean: Boolean;
- begin
- Result:=StrToBool(Self);
- end;
- function TStringHelper.ToInteger: Integer;
- begin
- Result:=StrToInt(Self);
- end;
- function TStringHelper.ToInt64: Int64;
- begin
- Result:=StrToInt64(Self);
- end;
- function TStringHelper.ToSingle: Single;
- begin
- Result:=StrToFLoat(Self);
- end;
- function TStringHelper.ToDouble: Double;
- begin
- Result:=StrToFLoat(Self);
- end;
- function TStringHelper.ToExtended: Extended;
- begin
- Result:=StrToFLoat(Self);
- end;
- function TStringHelper.ToCharArray: TCharArray;
- begin
- Result:=ToCharArray(0,Self.Length);
- end;
- function TStringHelper.ToCharArray(AStartIndex: SizeInt; ALen: SizeInt
- ): TCharArray;
- Var
- I : SizeInt;
- begin
- SetLength(Result,ALen);
- For I:=0 to ALen-1 do
- Result[I]:=Self[AStartIndex+I+1];
- end;
- function TStringHelper.ToLower: string;
- begin
- Result:=LowerCase(Self);
- end;
- function TStringHelper.ToLowerInvariant: string;
- begin
- Result:=LowerCase(Self);
- end;
- function TStringHelper.ToUpper: string;
- begin
- Result:=UpperCase(Self);
- end;
- function TStringHelper.ToUpperInvariant: string;
- begin
- Result:=UpperCase(Self);
- end;
- function TStringHelper.Trim: string;
- begin
- Result:=SysUtils.Trim(Self);
- end;
- function TStringHelper.TrimLeft: string;
- begin
- Result:=SysUtils.TrimLeft(Self);
- end;
- function TStringHelper.TrimRight: string;
- begin
- Result:=SysUtils.TrimRight(Self);
- end;
- function TStringHelper.Trim(const ATrimChars: array of Char): string;
- begin
- Result:=Self.TrimLeft(ATrimChars).TrimRight(ATrimChars);
- end;
- function TStringHelper.TrimLeft(const ATrimChars: array of Char): string;
- Var
- I,Len : SizeInt;
- begin
- I:=1;
- Len:=Self.Length;
- While (I<=Len) and HaveChar(Self[i],ATrimChars) do Inc(I);
- if I=1 then
- Result:=Self
- else if I>Len then
- Result:=''
- else
- Result:=system.Copy(Self,I,Len-I+1);
- end;
- function TStringHelper.TrimRight(const ATrimChars: array of Char): string;
- Var
- I,Len : SizeInt;
- begin
- Len:=Self.Length;
- I:=Len;
- While (I>=1) and HaveChar(Self[i],ATrimChars) do Dec(I);
- if I<1 then
- Result:=''
- else if I=Len then
- Result:=Self
- else
- Result:=system.Copy(Self,1,I);
- end;
- function TStringHelper.TrimEnd(const ATrimChars: array of Char): string;
- begin
- Result:=TrimRight(ATrimChars);
- end;
- function TStringHelper.TrimStart(const ATrimChars: array of Char): string;
- begin
- Result:=TrimLeft(ATrimChars);
- end;
- { ---------------------------------------------------------------------
- TSingleHelper
- ---------------------------------------------------------------------}
- {$MACRO ON}
- {$IFDEF FPC_HAS_TYPE_SINGLE}
- {$define TFLOATHELPER:=TSingleHelper}
- {$define FLOATTYPE:=Single}
- {$define TFloatRec:=TSingleRec}
- {$i syshelpf.inc}
- {$UNDEF TFloatRec}
- {$ENDIF FPC_HAS_TYPE_SINGLE}
- { ---------------------------------------------------------------------
- TDoubleHelper
- ---------------------------------------------------------------------}
- {$IFDEF FPC_HAS_TYPE_DOUBLE}
- {$define TFLOATHELPER:=TDoubleHelper}
- {$define FLOATTYPE:=Double}
- {$define TFloatRec:=TDoubleRec}
- {$i syshelpf.inc}
- {$UNDEF TFloatRec}
- {$ENDIF FPC_HAS_TYPE_DOUBLE}
- { ---------------------------------------------------------------------
- TExtendedHelper
- ---------------------------------------------------------------------}
- {$ifdef FPC_HAS_TYPE_EXTENDED}
- {$define TFLOATHELPER:=TExtendedHelper}
- {$define FLOATTYPE:=Extended}
- {$define TFloatRec:=TExtended80Rec}
- {$i syshelpf.inc}
- {$UNDEF TFloatRec}
- {$ENDIF FPC_HAS_TYPE_EXTENDED}
- { ---------------------------------------------------------------------
- TByteHelper
- ---------------------------------------------------------------------}
- {$define TORDINALHELPER:=TByteHelper}
- {$define TORDINALTYPE:=Byte}
- {$define TORDINALBITINDEX:=TByteBitIndex}
- {$i syshelpo.inc}
- { ---------------------------------------------------------------------
- TShortintHelper
- ---------------------------------------------------------------------}
- {$define TORDINALHELPER:=TShortIntHelper}
- {$define TORDINALTYPE:=ShortInt}
- {$define TORDINALBITINDEX:=TShortIntBitIndex}
- {$i syshelpo.inc}
- { ---------------------------------------------------------------------
- TSmallintHelper
- ---------------------------------------------------------------------}
- {$define TORDINALHELPER:=TSmallIntHelper}
- {$define TORDINALTYPE:=SmallInt}
- {$define TORDINALBITINDEX:=TSmallIntBitIndex}
- {$i syshelpo.inc}
- { ---------------------------------------------------------------------
- TWordHelper
- ---------------------------------------------------------------------}
- {$define TORDINALHELPER:=TWordHelper}
- {$define TORDINALTYPE:=Word}
- {$define TORDINALBITINDEX:=TWordBitIndex}
- {$i syshelpo.inc}
- { ---------------------------------------------------------------------
- TCardinalHelper
- ---------------------------------------------------------------------}
- {$define TORDINALHELPER:=TCardinalHelper}
- {$define TORDINALTYPE:=Cardinal}
- {$define TORDINALBITINDEX:=TCardinalBitIndex}
- {$i syshelpo.inc}
- { ---------------------------------------------------------------------
- TIntegerHelper
- ---------------------------------------------------------------------}
- {$define TORDINALHELPER:=TIntegerHelper}
- {$define TORDINALTYPE:=Integer}
- {$define TORDINALBITINDEX:=TIntegerBitIndex}
- {$i syshelpo.inc}
- { ---------------------------------------------------------------------
- TInt64Helper
- ---------------------------------------------------------------------}
- {$define TORDINALHELPER:=TInt64Helper}
- {$define TORDINALTYPE:=Int64}
- {$define TORDINALBITINDEX:=TInt64BitIndex}
- {$i syshelpo.inc}
- { ---------------------------------------------------------------------
- TQWordHelper
- ---------------------------------------------------------------------}
- {$define TORDINALHELPER:=TQWordHelper}
- {$define TORDINALTYPE:=QWord}
- {$define TORDINALBITINDEX:=TQwordBitIndex}
- {$i syshelpo.inc}
- { ---------------------------------------------------------------------
- TNativeIntHelper
- ---------------------------------------------------------------------}
- {$define TORDINALHELPER:=TNativeIntHelper}
- {$define TORDINALTYPE:=NativeInt}
- {$define TORDINALBITINDEX:=TNativeIntBitIndex}
- {$i syshelpo.inc}
- { ---------------------------------------------------------------------
- TNativeUIntHelper
- ---------------------------------------------------------------------}
- {$define TORDINALHELPER:=TNativeUIntHelper}
- {$define TORDINALTYPE:=NativeUInt}
- {$define TORDINALBITINDEX:=TNativeUIntBitIndex}
- {$i syshelpo.inc}
- { ---------------------------------------------------------------------
- TBooleanHelper
- ---------------------------------------------------------------------}
- {$define TBOOLHELPER:=TBooleanHelper}
- {$define TBOOLTYPE:=Boolean}
- {$i syshelpb.inc}
- { ---------------------------------------------------------------------
- TByteBoolHelper
- ---------------------------------------------------------------------}
- {$define TBOOLHELPER:=TByteBoolHelper}
- {$define TBOOLTYPE:=ByteBool}
- {$i syshelpb.inc}
- { ---------------------------------------------------------------------
- TWordBoolHelper
- ---------------------------------------------------------------------}
- {$define TBOOLHELPER:=TWordBoolHelper}
- {$define TBOOLTYPE:=WordBool}
- {$i syshelpb.inc}
- { ---------------------------------------------------------------------
- TLongBoolHelper
- ---------------------------------------------------------------------}
- {$define TBOOLHELPER:=TLongBoolHelper}
- {$define TBOOLTYPE:=LongBool}
- {$i syshelpb.inc}
|