mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-11 09:59:35 +01:00
* Type helpers, compatible to Delphi XE 8
git-svn-id: trunk@32262 -
This commit is contained in:
parent
094a3c4350
commit
fde42ca8ef
5
.gitattributes
vendored
5
.gitattributes
vendored
@ -9349,6 +9349,11 @@ rtl/objpas/sysutils/syscodepagesh.inc svneol=native#text/pascal
|
|||||||
rtl/objpas/sysutils/sysencoding.inc svneol=native#text/pascal
|
rtl/objpas/sysutils/sysencoding.inc svneol=native#text/pascal
|
||||||
rtl/objpas/sysutils/sysencodingh.inc svneol=native#text/pascal
|
rtl/objpas/sysutils/sysencodingh.inc svneol=native#text/pascal
|
||||||
rtl/objpas/sysutils/sysformt.inc svneol=native#text/plain
|
rtl/objpas/sysutils/sysformt.inc svneol=native#text/plain
|
||||||
|
rtl/objpas/sysutils/syshelp.inc svneol=native#text/plain
|
||||||
|
rtl/objpas/sysutils/syshelpb.inc svneol=native#text/plain
|
||||||
|
rtl/objpas/sysutils/syshelpf.inc svneol=native#text/plain
|
||||||
|
rtl/objpas/sysutils/syshelph.inc svneol=native#text/plain
|
||||||
|
rtl/objpas/sysutils/syshelpo.inc svneol=native#text/plain
|
||||||
rtl/objpas/sysutils/sysint.inc svneol=native#text/plain
|
rtl/objpas/sysutils/sysint.inc svneol=native#text/plain
|
||||||
rtl/objpas/sysutils/sysinth.inc svneol=native#text/plain
|
rtl/objpas/sysutils/sysinth.inc svneol=native#text/plain
|
||||||
rtl/objpas/sysutils/syspch.inc svneol=native#text/plain
|
rtl/objpas/sysutils/syspch.inc svneol=native#text/plain
|
||||||
|
|||||||
@ -27,6 +27,8 @@ interface
|
|||||||
{$MODESWITCH OUT}
|
{$MODESWITCH OUT}
|
||||||
{ force ansistrings }
|
{ force ansistrings }
|
||||||
{$H+}
|
{$H+}
|
||||||
|
{$modeswitch typehelpers}
|
||||||
|
{$modeswitch advancedrecords}
|
||||||
|
|
||||||
{$DEFINE OS_FILESETDATEBYNAME}
|
{$DEFINE OS_FILESETDATEBYNAME}
|
||||||
{$DEFINE HAS_SLEEP}
|
{$DEFINE HAS_SLEEP}
|
||||||
|
|||||||
@ -22,6 +22,8 @@ interface
|
|||||||
|
|
||||||
{$DEFINE HAS_SLEEP}
|
{$DEFINE HAS_SLEEP}
|
||||||
{$DEFINE HAS_OSERROR}
|
{$DEFINE HAS_OSERROR}
|
||||||
|
{$modeswitch typehelpers}
|
||||||
|
{$modeswitch advancedrecords}
|
||||||
|
|
||||||
{ used OS file system APIs use ansistring }
|
{ used OS file system APIs use ansistring }
|
||||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||||
|
|||||||
@ -21,6 +21,8 @@ interface
|
|||||||
{$MODESWITCH OUT}
|
{$MODESWITCH OUT}
|
||||||
{ force ansistrings }
|
{ force ansistrings }
|
||||||
{$H+}
|
{$H+}
|
||||||
|
{$modeswitch typehelpers}
|
||||||
|
{$modeswitch advancedrecords}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Dos;
|
Dos;
|
||||||
|
|||||||
@ -28,6 +28,8 @@ interface
|
|||||||
{$MODESWITCH OUT}
|
{$MODESWITCH OUT}
|
||||||
{ force ansistrings }
|
{ force ansistrings }
|
||||||
{$H+}
|
{$H+}
|
||||||
|
{$modeswitch typehelpers}
|
||||||
|
{$modeswitch advancedrecords}
|
||||||
|
|
||||||
{$DEFINE HAS_SLEEP}
|
{$DEFINE HAS_SLEEP}
|
||||||
{$DEFINE HAS_OSERROR}
|
{$DEFINE HAS_OSERROR}
|
||||||
|
|||||||
@ -23,6 +23,8 @@ interface
|
|||||||
{$MODESWITCH out}
|
{$MODESWITCH out}
|
||||||
{ force ansistrings }
|
{ force ansistrings }
|
||||||
{$H+}
|
{$H+}
|
||||||
|
{$modeswitch typehelpers}
|
||||||
|
{$modeswitch advancedrecords}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
go32,dos;
|
go32,dos;
|
||||||
|
|||||||
@ -52,7 +52,11 @@ procedure DefaultUnicode2AnsiMove(source:punicodechar;var dest:RawByteString;cp
|
|||||||
procedure DefaultAnsi2UnicodeMove(source:pchar;cp : TSystemCodePage;var dest:unicodestring;len:SizeInt);
|
procedure DefaultAnsi2UnicodeMove(source:pchar;cp : TSystemCodePage;var dest:unicodestring;len:SizeInt);
|
||||||
|
|
||||||
Type
|
Type
|
||||||
TStandardCodePageEnum = (
|
TCompareOption = (coLingIgnoreCase, coLingIgnoreDiacritic, coIgnoreCase,
|
||||||
|
coIgnoreKanaType, coIgnoreNonSpace, coIgnoreSymbols, coIgnoreWidth,
|
||||||
|
coLingCasing, coDigitAsNumbers, coStringSort);
|
||||||
|
TCompareOptions = set of TCompareOption;
|
||||||
|
TStandardCodePageEnum = (
|
||||||
scpAnsi, // system Ansi code page (GetACP on windows)
|
scpAnsi, // system Ansi code page (GetACP on windows)
|
||||||
scpConsoleInput, // system console input code page (GetConsoleCP on windows)
|
scpConsoleInput, // system console input code page (GetConsoleCP on windows)
|
||||||
scpConsoleOutput, // system console output code page (GetConsoleOutputCP on windows)
|
scpConsoleOutput, // system console output code page (GetConsoleOutputCP on windows)
|
||||||
@ -78,8 +82,9 @@ Type
|
|||||||
CompUCS2 : function(p1,p2:PUCS2Char) : shortint;
|
CompUCS2 : function(p1,p2:PUCS2Char) : shortint;
|
||||||
CompUCS4 : function(p1,p2:PUC42Char) : shortint;
|
CompUCS4 : function(p1,p2:PUC42Char) : shortint;
|
||||||
}
|
}
|
||||||
CompareWideStringProc : function(const s1, s2 : WideString) : PtrInt;
|
CompareWideStringProc : function(const s1, s2 : WideString; Options : TCompareOptions) : PtrInt;
|
||||||
CompareTextWideStringProc : function(const s1, s2 : WideString): PtrInt;
|
// CompareTextWideStringProc is CompareWideStringProc with coIgnoreCase in options.
|
||||||
|
// CompareTextWideStringProc : function(const s1, s2 : WideString): PtrInt;
|
||||||
{ return value: number of code points in the string. Whenever an invalid
|
{ return value: number of code points in the string. Whenever an invalid
|
||||||
code point is encountered, all characters part of this invalid code point
|
code point is encountered, all characters part of this invalid code point
|
||||||
are considered to form one "character" and the next character is
|
are considered to form one "character" and the next character is
|
||||||
@ -109,8 +114,9 @@ Type
|
|||||||
Ansi2UnicodeMoveProc : procedure(source:pchar;cp : TSystemCodePage;var dest:unicodestring;len:SizeInt);
|
Ansi2UnicodeMoveProc : procedure(source:pchar;cp : TSystemCodePage;var dest:unicodestring;len:SizeInt);
|
||||||
UpperUnicodeStringProc : function(const S: UnicodeString): UnicodeString;
|
UpperUnicodeStringProc : function(const S: UnicodeString): UnicodeString;
|
||||||
LowerUnicodeStringProc : function(const S: UnicodeString): UnicodeString;
|
LowerUnicodeStringProc : function(const S: UnicodeString): UnicodeString;
|
||||||
CompareUnicodeStringProc : function(const s1, s2 : UnicodeString) : PtrInt;
|
CompareUnicodeStringProc : function(const s1, s2 : UnicodeString; Options : TCompareOptions) : PtrInt;
|
||||||
CompareTextUnicodeStringProc : function(const s1, s2 : UnicodeString): PtrInt;
|
// CompareTextUnicodeStringProc is CompareUnicodeStringProc with coIgnoreCase in options.
|
||||||
|
/// CompareTextUnicodeStringProc : function(const s1, s2 : UnicodeString): PtrInt;
|
||||||
|
|
||||||
{ codepage retrieve function }
|
{ codepage retrieve function }
|
||||||
GetStandardCodePageProc: function(const stdcp: TStandardCodePageEnum): TSystemCodePage;
|
GetStandardCodePageProc: function(const stdcp: TStandardCodePageEnum): TSystemCodePage;
|
||||||
|
|||||||
@ -2289,7 +2289,7 @@ function StubUnicodeCase(const s : UnicodeString) : UnicodeString;
|
|||||||
unimplementedunicodestring;
|
unimplementedunicodestring;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function StubCompareUnicodeString(const s1, s2 : UnicodeString) : PtrInt;
|
function StubCompareUnicodeString(const s1, s2 : UnicodeString; Options : TCompareOptions) : PtrInt;
|
||||||
begin
|
begin
|
||||||
unimplementedunicodestring;
|
unimplementedunicodestring;
|
||||||
end;
|
end;
|
||||||
@ -2299,7 +2299,7 @@ function StubWideCase(const s: WideString): WideString;
|
|||||||
unimplementedunicodestring;
|
unimplementedunicodestring;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function StubCompareWideString(const s1, s2 : WideString) : PtrInt;
|
function StubCompareWideString(const s1, s2 : WideString; Options : TCompareOptions) : PtrInt;
|
||||||
begin
|
begin
|
||||||
unimplementedunicodestring;
|
unimplementedunicodestring;
|
||||||
end;
|
end;
|
||||||
@ -2322,9 +2322,8 @@ procedure initunicodestringmanager;
|
|||||||
widestringmanager.LowerUnicodeStringProc:=@StubUnicodeCase;
|
widestringmanager.LowerUnicodeStringProc:=@StubUnicodeCase;
|
||||||
{$endif HAS_WIDESTRINGMANAGER}
|
{$endif HAS_WIDESTRINGMANAGER}
|
||||||
widestringmanager.CompareWideStringProc:=@StubCompareWideString;
|
widestringmanager.CompareWideStringProc:=@StubCompareWideString;
|
||||||
widestringmanager.CompareTextWideStringProc:=@StubCompareWideString;
|
// widestringmanager.CompareTextWideStringProc:=@StubCompareWideString;
|
||||||
widestringmanager.CompareUnicodeStringProc:=@StubCompareUnicodeString;
|
widestringmanager.CompareUnicodeStringProc:=@StubCompareUnicodeString;
|
||||||
widestringmanager.CompareTextUnicodeStringProc:=@StubCompareUnicodeString;
|
|
||||||
widestringmanager.CharLengthPCharProc:=@DefaultCharLengthPChar;
|
widestringmanager.CharLengthPCharProc:=@DefaultCharLengthPChar;
|
||||||
widestringmanager.CodePointLengthProc:=@DefaultCodePointLength;
|
widestringmanager.CodePointLengthProc:=@DefaultCodePointLength;
|
||||||
widestringmanager.GetStandardCodePageProc:=@DefaultGetStandardCodePage;
|
widestringmanager.GetStandardCodePageProc:=@DefaultGetStandardCodePage;
|
||||||
|
|||||||
@ -24,6 +24,8 @@ interface
|
|||||||
{$modeswitch out}
|
{$modeswitch out}
|
||||||
{ force ansistrings }
|
{ force ansistrings }
|
||||||
{$H+}
|
{$H+}
|
||||||
|
{$modeswitch typehelpers}
|
||||||
|
{$modeswitch advancedrecords}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
MacOSTP;
|
MacOSTP;
|
||||||
|
|||||||
@ -23,6 +23,8 @@ interface
|
|||||||
{$MODESWITCH out}
|
{$MODESWITCH out}
|
||||||
{ force ansistrings }
|
{ force ansistrings }
|
||||||
{$H+}
|
{$H+}
|
||||||
|
{$modeswitch typehelpers}
|
||||||
|
{$modeswitch advancedrecords}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
{go32,}dos;
|
{go32,}dos;
|
||||||
|
|||||||
@ -21,6 +21,8 @@ interface
|
|||||||
{$MODESWITCH OUT}
|
{$MODESWITCH OUT}
|
||||||
{ force ansistrings }
|
{ force ansistrings }
|
||||||
{$H+}
|
{$H+}
|
||||||
|
{$modeswitch typehelpers}
|
||||||
|
{$modeswitch advancedrecords}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
ndk;
|
ndk;
|
||||||
|
|||||||
@ -28,6 +28,9 @@ interface
|
|||||||
{$MODESWITCH OUT}
|
{$MODESWITCH OUT}
|
||||||
{ force ansistrings }
|
{ force ansistrings }
|
||||||
{$H+}
|
{$H+}
|
||||||
|
{$modeswitch typehelpers}
|
||||||
|
{$modeswitch advancedrecords}
|
||||||
|
|
||||||
{$DEFINE HAS_OSERROR}
|
{$DEFINE HAS_OSERROR}
|
||||||
{$DEFINE HAS_SLEEP}
|
{$DEFINE HAS_SLEEP}
|
||||||
{ used OS file system APIs use ansistring }
|
{ used OS file system APIs use ansistring }
|
||||||
|
|||||||
@ -21,6 +21,8 @@ interface
|
|||||||
{$MODESWITCH OUT}
|
{$MODESWITCH OUT}
|
||||||
{ force ansistrings }
|
{ force ansistrings }
|
||||||
{$H+}
|
{$H+}
|
||||||
|
{$modeswitch typehelpers}
|
||||||
|
{$modeswitch advancedrecords}
|
||||||
|
|
||||||
uses DOS;
|
uses DOS;
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,8 @@ interface
|
|||||||
{$MODESWITCH OUT}
|
{$MODESWITCH OUT}
|
||||||
{ force ansistrings }
|
{ force ansistrings }
|
||||||
{$H+}
|
{$H+}
|
||||||
|
{$modeswitch typehelpers}
|
||||||
|
{$modeswitch advancedrecords}
|
||||||
|
|
||||||
uses Libc,DOS;
|
uses Libc,DOS;
|
||||||
|
|
||||||
|
|||||||
@ -406,10 +406,22 @@ begin
|
|||||||
Result := CompareUnicodeStringUCA(p1,p2,l1,l2);
|
Result := CompareUnicodeStringUCA(p1,p2,l1,l2);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CompareUnicodeString(const s1, s2 : UnicodeString) : PtrInt;
|
function CompareUnicodeString(const s1, s2 : UnicodeString;Options : TCompareOptions) : PtrInt;
|
||||||
|
Var
|
||||||
|
us1,us2 : UnicodeString;
|
||||||
begin
|
begin
|
||||||
if (current_Collation=nil) then
|
if (current_Collation=nil) then
|
||||||
exit(OldManager.CompareUnicodeStringProc(s1,s2));
|
exit(OldManager.CompareUnicodeStringProc(s1,s2,Options));
|
||||||
|
if (coIgnoreCase in Options) then
|
||||||
|
begin
|
||||||
|
us1:=UpperUnicodeString(s1);
|
||||||
|
us2:=UpperUnicodeString(s2);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
us1:=S1;
|
||||||
|
us2:=S2;
|
||||||
|
end;
|
||||||
Result:=CompareUnicodeString(
|
Result:=CompareUnicodeString(
|
||||||
PUnicodeChar(Pointer(s1)),
|
PUnicodeChar(Pointer(s1)),
|
||||||
PUnicodeChar(Pointer(s2)),
|
PUnicodeChar(Pointer(s2)),
|
||||||
@ -417,25 +429,39 @@ begin
|
|||||||
);
|
);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CompareWideString(const s1, s2 : WideString) : PtrInt;
|
function CompareWideString(const s1, s2 : WideString; Options : TCompareOptions) : PtrInt;
|
||||||
|
|
||||||
|
Var
|
||||||
|
us1,us2 : WideString;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if (current_Collation=nil) then
|
if (current_Collation=nil) then
|
||||||
exit(OldManager.CompareWideStringProc(s1,s2));
|
exit(OldManager.CompareWideStringProc(s1,s2,Options));
|
||||||
|
if (coIgnoreCase in Options) then
|
||||||
|
begin
|
||||||
|
us1:=UpperWideString(s1);
|
||||||
|
us2:=UpperWideString(s2);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
us1:=S1;
|
||||||
|
us2:=S2;
|
||||||
|
end;
|
||||||
Result:=CompareUnicodeString(
|
Result:=CompareUnicodeString(
|
||||||
PUnicodeChar(Pointer(s1)),
|
PUnicodeChar(Pointer(us1)),
|
||||||
PUnicodeChar(Pointer(s2)),
|
PUnicodeChar(Pointer(us2)),
|
||||||
Length(s1),Length(s2)
|
Length(us1),Length(us2)
|
||||||
);
|
);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CompareTextUnicodeString(const s1, s2 : UnicodeString) : PtrInt;
|
function CompareTextUnicodeString(const s1, s2 : UnicodeString) : PtrInt;
|
||||||
begin
|
begin
|
||||||
Result:=CompareUnicodeString(UpperUnicodeString(s1),UpperUnicodeString(s2));
|
Result:=CompareUnicodeString(s1,s2,[coIgnoreCase]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CompareTextWideString(const s1, s2 : WideString) : PtrInt;
|
function CompareTextWideString(const s1, s2 : WideString) : PtrInt;
|
||||||
begin
|
begin
|
||||||
Result:=CompareWideString(UpperWideString(s1),UpperWideString(s2));
|
Result:=CompareWideString(s1,s2,[coIgnoreCase]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure EnsureAnsiLen(var S: AnsiString; const len: SizeInt); inline;
|
procedure EnsureAnsiLen(var S: AnsiString; const len: SizeInt); inline;
|
||||||
@ -649,7 +675,7 @@ begin
|
|||||||
Ansi2UnicodeMove(S1,DefaultSystemCodePage,a,Len1);
|
Ansi2UnicodeMove(S1,DefaultSystemCodePage,a,Len1);
|
||||||
b := '';
|
b := '';
|
||||||
Ansi2UnicodeMove(S2,DefaultSystemCodePage,b,Len2);
|
Ansi2UnicodeMove(S2,DefaultSystemCodePage,b,Len2);
|
||||||
Result := CompareUnicodeString(a,b);
|
Result := CompareUnicodeString(a,b,[]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function StrLCompAnsiString(S1, S2: PAnsiChar; MaxLen: PtrUInt): PtrInt;
|
function StrLCompAnsiString(S1, S2: PAnsiChar; MaxLen: PtrUInt): PtrInt;
|
||||||
@ -746,7 +772,6 @@ begin
|
|||||||
LowerWideStringProc:=@LowerWideString;
|
LowerWideStringProc:=@LowerWideString;
|
||||||
|
|
||||||
CompareWideStringProc:=@CompareWideString;
|
CompareWideStringProc:=@CompareWideString;
|
||||||
CompareTextWideStringProc:=@CompareTextWideString;
|
|
||||||
{$else FPC_WIDESTRING_EQUAL_UNICODESTRING}
|
{$else FPC_WIDESTRING_EQUAL_UNICODESTRING}
|
||||||
Ansi2WideMoveProc:=@Ansi2UnicodeMove;
|
Ansi2WideMoveProc:=@Ansi2UnicodeMove;
|
||||||
|
|
||||||
@ -754,7 +779,6 @@ begin
|
|||||||
LowerWideStringProc:=@LowerUnicodeString;
|
LowerWideStringProc:=@LowerUnicodeString;
|
||||||
|
|
||||||
CompareWideStringProc:=@CompareUnicodeString;
|
CompareWideStringProc:=@CompareUnicodeString;
|
||||||
CompareTextWideStringProc:=@CompareTextUnicodeString;
|
|
||||||
{$endif FPC_WIDESTRING_EQUAL_UNICODESTRING}
|
{$endif FPC_WIDESTRING_EQUAL_UNICODESTRING}
|
||||||
|
|
||||||
CharLengthPCharProc:=@CharLengthPChar;
|
CharLengthPCharProc:=@CharLengthPChar;
|
||||||
@ -778,7 +802,6 @@ begin
|
|||||||
UpperUnicodeStringProc:=@UpperUnicodeString;
|
UpperUnicodeStringProc:=@UpperUnicodeString;
|
||||||
LowerUnicodeStringProc:=@LowerUnicodeString;
|
LowerUnicodeStringProc:=@LowerUnicodeString;
|
||||||
CompareUnicodeStringProc:=@CompareUnicodeString;
|
CompareUnicodeStringProc:=@CompareUnicodeString;
|
||||||
CompareTextUnicodeStringProc:=@CompareTextUnicodeString;
|
|
||||||
end;
|
end;
|
||||||
SetUnicodeStringManager(locWideStringManager);
|
SetUnicodeStringManager(locWideStringManager);
|
||||||
|
|
||||||
|
|||||||
1618
rtl/objpas/sysutils/syshelp.inc
Normal file
1618
rtl/objpas/sysutils/syshelp.inc
Normal file
File diff suppressed because it is too large
Load Diff
36
rtl/objpas/sysutils/syshelpb.inc
Normal file
36
rtl/objpas/sysutils/syshelpb.inc
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
|
||||||
|
Class Function TBOOLHELPER.Parse(const S: string): Boolean; inline; static;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=StrToBool(S);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Class Function TBOOLHELPER.Size: Integer; inline; static;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=SizeOf(TBOOLTYPE);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Class Function TBOOLHELPER.ToString(const AValue: Boolean; UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline; static;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=BoolToStr(AValue,UseBoolStrs=TUseBoolStrs.True);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Class Function TBOOLHELPER.TryToParse(const S: string; out AValue: Boolean): Boolean; inline; static;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=TryStrToBool(S,AValue);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function TBOOLHELPER.ToInteger: Integer; inline;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=Integer(Self);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function TBOOLHELPER.ToString(UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=BoolToStr(Self,UseBoolStrs=TUseBoolStrs.True);
|
||||||
|
end;
|
||||||
235
rtl/objpas/sysutils/syshelpf.inc
Normal file
235
rtl/objpas/sysutils/syshelpf.inc
Normal file
@ -0,0 +1,235 @@
|
|||||||
|
Class Function TFLOATHELPER.IsNan(const AValue: FLOATTYPE): Boolean; overload; inline; static;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=AValue=Nan;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Class Function TFLOATHELPER.IsInfinity(const AValue: FLOATTYPE): Boolean; overload; inline; static;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=(AValue=PositiveInfinity) or (AValue=NegativeInfinity);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Class Function TFLOATHELPER.IsNegativeInfinity(const AValue: FLOATTYPE): Boolean; overload; inline; static;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=AValue=NegativeInfinity;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Class Function TFLOATHELPER.IsPositiveInfinity(const AValue: FLOATTYPE): Boolean; overload; inline; static;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=(AValue=PositiveInfinity);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Class Function TFLOATHELPER.Parse(const AString: string): FLOATTYPE; overload; inline; static;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=StrToFloat(AString,DefaultFormatSettings);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Class Function TFLOATHELPER.Parse(const AString: string; const AFormatSettings: TFormatSettings): FLOATTYPE; overload; inline; static;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=StrToFloat(AString,AFormatSettings);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Class Function TFLOATHELPER.Size: Integer; inline; static;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=SizeOf(FLOATTYPE);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Class Function TFLOATHELPER.ToString(const AValue: FLOATTYPE): string; overload; inline; static;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=FloatToStr(AValue,DefaultFormatSettings);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Class Function TFLOATHELPER.ToString(const AValue: FLOATTYPE; const AFormatSettings: TFormatSettings): string; overload; inline; static;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=FloatToStr(AValue,AFormatSettings);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Class Function TFLOATHELPER.ToString(const AValue: FLOATTYPE; const AFormat: TFloatFormat; const APrecision, ADigits: Integer): string; overload; inline; static;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=FloatToStrF(AValue,AFormat,APrecision,ADigits,DefaultFormatSettings);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Class Function TFLOATHELPER.ToString(const AValue: FLOATTYPE; const AFormat: TFloatFormat; const APrecision, ADigits: Integer; const AFormatSettings: TFormatSettings): string;
|
||||||
|
overload; inline; static;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=FloatToStrF(AValue,AFormat,APrecision,ADigits,AFormatSettings);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Class Function TFLOATHELPER.TryParse(const AString: string; out AValue: FLOATTYPE): Boolean; overload; inline; static;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=TryStrToFloat(AString,AValue,DefaultFormatSettings);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Class Function TFLOATHELPER.TryParse(const AString: string; out AValue: FLOATTYPE; const AFormatSettings: TFormatSettings): Boolean; overload; inline;
|
||||||
|
static;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=TryStrToFloat(AString,AValue,AFormatSettings);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Function TFLOATHELPER.GetB(AIndex: Cardinal): Byte;
|
||||||
|
|
||||||
|
begin
|
||||||
|
if (AIndex>=SizeOf(FLOATTYPE)) then
|
||||||
|
system.Error(reRangeError);
|
||||||
|
Result:=PByte(@Self)[AIndex];
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function TFLOATHELPER.GetW(AIndex: Cardinal): Word;
|
||||||
|
|
||||||
|
begin
|
||||||
|
if (AIndex>=(SizeOf(FLOATTYPE) div SizeOf(Word))) then
|
||||||
|
system.Error(reRangeError);
|
||||||
|
Result:=PWord(@Self)[AIndex];
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function TFLOATHELPER.GetE: QWord; inline;
|
||||||
|
|
||||||
|
begin
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function TFLOATHELPER.GetF: QWord; inline;
|
||||||
|
|
||||||
|
begin
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function TFLOATHELPER.GetS: Boolean; inline;
|
||||||
|
|
||||||
|
begin
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFLOATHELPER.SetB(AIndex: Cardinal; const AValue: Byte);
|
||||||
|
|
||||||
|
begin
|
||||||
|
if (AIndex>=SizeOf(FLOATTYPE)) then
|
||||||
|
system.Error(reRangeError);
|
||||||
|
PByte(@Self)[AIndex]:=AValue;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFLOATHELPER.SetW(AIndex: Cardinal; const AValue: Word);
|
||||||
|
|
||||||
|
begin
|
||||||
|
if (AIndex>=(SizeOf(FLOATTYPE) div SizeOf(Word))) then
|
||||||
|
system.Error(reRangeError);
|
||||||
|
PWord(@Self)[AIndex]:=AValue;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFLOATHELPER.SetE(AValue: QWord);
|
||||||
|
|
||||||
|
begin
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFLOATHELPER.SetF(AValue: QWord);
|
||||||
|
|
||||||
|
begin
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFLOATHELPER.SetS(AValue: Boolean);
|
||||||
|
|
||||||
|
begin
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Procedure TFLOATHELPER.BuildUp(const ASignFlag: Boolean; const AMantissa: QWord; const AExponent: Integer);
|
||||||
|
|
||||||
|
begin
|
||||||
|
Self := 0.0;
|
||||||
|
SetS(ASignFlag);
|
||||||
|
SetE(AExponent + $3FF);
|
||||||
|
SetF(AMantissa and $000FFFFFFFFFFFFF);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function TFLOATHELPER.Exponent: Integer;
|
||||||
|
|
||||||
|
var
|
||||||
|
F,E : QWord;
|
||||||
|
begin
|
||||||
|
Result:=0; // Zero, inf, Nan
|
||||||
|
E:=GetE;
|
||||||
|
F:=GetF;
|
||||||
|
if (0<E) and (E<$77FF) then
|
||||||
|
Result:=E-$3FF
|
||||||
|
else if (E=0) and (F<>0) then
|
||||||
|
Result:=-1022
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function TFLOATHELPER.Fraction: Extended;
|
||||||
|
|
||||||
|
begin
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function TFLOATHELPER.IsInfinity: Boolean; overload; inline;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=(Self=PositiveInfinity) or (Self=NegativeInfinity);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function TFLOATHELPER.IsNan: Boolean; overload; inline;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=(Self=Nan);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function TFLOATHELPER.IsNegativeInfinity: Boolean; overload; inline;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=(Self=NegativeInfinity);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function TFLOATHELPER.IsPositiveInfinity: Boolean; overload; inline;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=(Self=PositiveInfinity);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function TFLOATHELPER.Mantissa: QWord;
|
||||||
|
|
||||||
|
begin
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function TFLOATHELPER.SpecialType: TFloatSpecial;
|
||||||
|
|
||||||
|
begin
|
||||||
|
if IsNan then
|
||||||
|
Result:=fsNan
|
||||||
|
else if IsNegativeInfinity then
|
||||||
|
Result:=fsNInf
|
||||||
|
else if IsPositiveInfinity then
|
||||||
|
Result:=fsInf
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function TFLOATHELPER.ToString(const AFormat: TFloatFormat; const APrecision, ADigits: Integer): string; overload; inline;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=FloatToStrF(Self,AFormat,APrecision,ADigits,DefaultFormatSettings);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function TFLOATHELPER.ToString(const AFormat: TFloatFormat; const APrecision, ADigits: Integer; const AFormatSettings: TFormatSettings): string; overload; inline;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=FloatToStrF(Self,AFormat,APrecision,ADigits,AFormatSettings);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function TFLOATHELPER.ToString(const AFormatSettings: TFormatSettings): string; overload; inline;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=FloatToStr(Self,AFormatSettings);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function TFLOATHELPER.ToString: string; overload; inline;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=FloatToStr(Self,DefaultFormatSettings);
|
||||||
|
end;
|
||||||
616
rtl/objpas/sysutils/syshelph.inc
Normal file
616
rtl/objpas/sysutils/syshelph.inc
Normal file
@ -0,0 +1,616 @@
|
|||||||
|
{%mainunit syshelpers.pp}
|
||||||
|
|
||||||
|
Type
|
||||||
|
generic TArray<T> = array of T;
|
||||||
|
TStringArray = Array of string;
|
||||||
|
TCharArray = Array of char;
|
||||||
|
{$SCOPEDENUMS ON}
|
||||||
|
TEndian = (Little,Big);
|
||||||
|
{$SCOPEDENUMS OFF}
|
||||||
|
|
||||||
|
Const
|
||||||
|
CPUEndian = {$IFDEF FPC_LITTLE_ENDIAN}TEndian.Little{$ELSE}TEndian.Big{$ENDIF};
|
||||||
|
|
||||||
|
Type
|
||||||
|
TGuidHelper = record helper for TGUID
|
||||||
|
Class function Create(const Data; BigEndian: Boolean): TGUID; overload; static;
|
||||||
|
class function Create(const Data: array of Byte; AStartIndex: Cardinal; BigEndian: Boolean): TGUID; overload; static;
|
||||||
|
Class Function Create(const Data; DataEndian: TEndian = CPUEndian): TGUID; overload; static; inline;
|
||||||
|
Class Function Create(const B: TBytes; DataEndian: TEndian = CPUEndian): TGUID; overload; static; inline;
|
||||||
|
Class Function Create(const B: TBytes; AStartIndex: Cardinal; DataEndian: TEndian = CPUEndian): TGUID; overload; static;
|
||||||
|
Class Function Create(const S: string): TGUID; overload; static;
|
||||||
|
Class Function Create(A: Integer; B: SmallInt; C: SmallInt; const D: TBytes): TGUID; overload; static;
|
||||||
|
Class Function Create(A: Integer; B: SmallInt; C: SmallInt; D, E, F, G, H, I, J, K: Byte): TGUID; overload; static;
|
||||||
|
Class Function Create(A: Cardinal; B: Word; C: Word; D, E, F, G, H, I, J, K: Byte): TGUID; overload; static;
|
||||||
|
Class Function NewGuid: TGUID; static;
|
||||||
|
Function ToByteArray(DataEndian: TEndian = CPUEndian): TBytes;
|
||||||
|
Function ToString(SkipBrackets: Boolean = False): string;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
TCompareOption = system.TCompareOption;
|
||||||
|
TCompareOptions = system.TCompareOptions;
|
||||||
|
|
||||||
|
TStringSplitOptions = (None, ExcludeEmpty);
|
||||||
|
|
||||||
|
{ TStringHelper }
|
||||||
|
|
||||||
|
TStringHelper = Type Helper for AnsiString
|
||||||
|
Private
|
||||||
|
Function GetChar(AIndex : Integer) : Char;
|
||||||
|
Function GetLength : Integer;
|
||||||
|
public
|
||||||
|
const Empty = '';
|
||||||
|
// Methods
|
||||||
|
Class Function Compare(const A: string; const B: string): Integer; overload; static; //inline;
|
||||||
|
Class Function Compare(const A: string; const B: string; IgnoreCase: Boolean): Integer; overload; static; //inline; //deprecated 'Use same with TCompareOptions';
|
||||||
|
Class Function Compare(const A: string; const B: string; Options: TCompareOptions): Integer; overload; static; // inline;
|
||||||
|
Class Function Compare(const A: string; IndexA: Integer; const B: string; IndexB: Integer; ALen: Integer): Integer; overload; static; // inline;
|
||||||
|
Class Function Compare(const A: string; IndexA: Integer; const B: string; IndexB: Integer; ALen: Integer; IgnoreCase: Boolean): Integer; overload; static; // inline; //deprecated 'Use same with TCompareOptions';
|
||||||
|
Class Function Compare(const A: string; IndexA: Integer; const B: string; IndexB: Integer; ALen: Integer; Options: TCompareOptions): Integer; overload; static;// inline;
|
||||||
|
Class Function CompareOrdinal(const A: string; const B: string): Integer; overload; static;
|
||||||
|
Class Function CompareOrdinal(const A: string; IndexA: Integer; const B: string; IndexB: Integer; ALen: Integer): Integer; overload; static;
|
||||||
|
Class Function CompareText(const A: string; const B: string): Integer; static; inline;
|
||||||
|
Class Function Copy(const Str: string): string; inline; static;
|
||||||
|
Class Function Create(AChar: Char; ACount: Integer): string; overload; inline; static;
|
||||||
|
Class Function Create(const AValue: array of Char): string; overload; static;
|
||||||
|
Class Function Create(const AValue: array of Char; StartIndex: Integer; ALen: Integer): string; overload; static;
|
||||||
|
Class Function EndsText(const ASubText, AText: string): Boolean; static;
|
||||||
|
Class Function Equals(const a: string; const b: string): Boolean; overload; static;
|
||||||
|
Class Function Format(const AFormat: string; const args: array of const): string; overload; static;
|
||||||
|
Class Function IsNullOrEmpty(const AValue: string): Boolean; static;
|
||||||
|
Class Function IsNullOrWhiteSpace(const AValue: string): Boolean; static;
|
||||||
|
Class Function Join(const Separator: string; const Values: array of const): string; overload; static;
|
||||||
|
Class Function Join(const Separator: string; const Values: array of string): string; overload; static;
|
||||||
|
Class Function Join(const Separator: string; const Values: array of string; StartIndex: Integer; ACount: Integer): string; overload; static;
|
||||||
|
Class Function LowerCase(const S: string): string; overload; static; inline;
|
||||||
|
Class Function Parse(const AValue: Boolean): string; overload; static; inline;
|
||||||
|
Class Function Parse(const AValue: Extended): string; overload; static;inline;
|
||||||
|
Class Function Parse(const AValue: Int64): string; overload; static; inline;
|
||||||
|
Class Function Parse(const AValue: Integer): string; overload; static; inline;
|
||||||
|
Class Function ToBoolean(const S: string): Boolean; overload; static; inline;
|
||||||
|
Class Function ToDouble(const S: string): Double; overload; static; inline;
|
||||||
|
Class Function ToExtended(const S: string): Extended; overload; static; inline;
|
||||||
|
Class Function ToInt64(const S: string): Int64; overload; static; inline;
|
||||||
|
Class Function ToInteger(const S: string): Integer; overload; static; inline;
|
||||||
|
Class Function ToSingle(const S: string): Single; overload; static; inline;
|
||||||
|
Class Function UpperCase(const S: string): string; overload; static; inline;
|
||||||
|
Function CompareTo(const B: string): Integer;
|
||||||
|
Function Contains(const AValue: string): Boolean;
|
||||||
|
procedure CopyTo(SourceIndex: Integer; var destination: array of Char; DestinationIndex: Integer; ACount: Integer);
|
||||||
|
Function CountChar(const C: Char): Integer;
|
||||||
|
Function DeQuotedString: string; overload;
|
||||||
|
Function DeQuotedString(const AQuoteChar: Char): string; overload;
|
||||||
|
Function EndsWith(const AValue: string): Boolean; overload; inline;
|
||||||
|
Function EndsWith(const AValue: string; IgnoreCase: Boolean): Boolean; overload;
|
||||||
|
Function Equals(const AValue: string): Boolean; overload;
|
||||||
|
Function Format(const args: array of const): string; overload;
|
||||||
|
Function GetHashCode: Integer;
|
||||||
|
Function IndexOf(AValue: Char): Integer; overload; inline;
|
||||||
|
Function IndexOf(const AValue: string): Integer; overload; inline;
|
||||||
|
Function IndexOf(AValue: Char; StartIndex: Integer): Integer; overload;
|
||||||
|
Function IndexOf(const AValue: string; StartIndex: Integer): Integer; overload;
|
||||||
|
Function IndexOf(AValue: Char; StartIndex: Integer; ACount: Integer): Integer; overload;
|
||||||
|
Function IndexOf(const AValue: string; StartIndex: Integer; ACount: Integer): Integer; overload;
|
||||||
|
Function IndexOfUnQuoted(const AValue: string; StartQuote, EndQuote: Char; StartIndex: Integer = 0): Integer; overload;
|
||||||
|
Function IndexOfAny(const AnyOf: array of Char): Integer; overload;
|
||||||
|
Function IndexOfAny(const AnyOf: array of Char; StartIndex: Integer): Integer; overload;
|
||||||
|
Function IndexOfAny(const AnyOf: array of Char; StartIndex: Integer; ACount: Integer): Integer; overload;
|
||||||
|
Function IndexOfAny(const AnyOf: array of String): Integer; overload;
|
||||||
|
Function IndexOfAny(const AnyOf: array of String; StartIndex: Integer): Integer; overload;
|
||||||
|
Function IndexOfAny(const AnyOf: array of String; StartIndex: Integer; ACount: Integer): Integer; overload;
|
||||||
|
Function IndexOfAny(const AnyOf: array of String; StartIndex: Integer; ACount: Integer; Out AMatch : Integer): Integer; overload;
|
||||||
|
Function IndexOfAnyUnquoted(const AnyOf: array of Char; StartQuote, EndQuote: Char): Integer; overload;
|
||||||
|
Function IndexOfAnyUnquoted(const AnyOf: array of Char; StartQuote, EndQuote: Char; StartIndex: Integer): Integer; overload;
|
||||||
|
Function IndexOfAnyUnquoted(const AnyOf: array of Char; StartQuote, EndQuote: Char; StartIndex: Integer; ACount: Integer): Integer; overload;
|
||||||
|
function IndexOfAnyUnquoted(const AnyOf: array of string; StartQuote, EndQuote: Char; StartIndex: Integer; Out Matched: Integer): Integer; overload;
|
||||||
|
Function Insert(StartIndex: Integer; const AValue: string): string;
|
||||||
|
Function IsDelimiter(const Delimiters: string; Index: Integer): Boolean;
|
||||||
|
Function IsEmpty: Boolean;
|
||||||
|
Function LastDelimiter(const Delims: string): Integer;
|
||||||
|
Function LastIndexOf(AValue: Char): Integer; overload;
|
||||||
|
Function LastIndexOf(const AValue: string): Integer; overload;
|
||||||
|
Function LastIndexOf(AValue: Char; AStartIndex: Integer): Integer; overload;
|
||||||
|
Function LastIndexOf(const AValue: string; AStartIndex: Integer): Integer; overload;
|
||||||
|
Function LastIndexOf(AValue: Char; AStartIndex: Integer; ACount: Integer): Integer; overload;
|
||||||
|
Function LastIndexOf(const AValue: string; AStartIndex: Integer; ACount: Integer): Integer; overload;
|
||||||
|
Function LastIndexOfAny(const AnyOf: array of Char): Integer; overload;
|
||||||
|
Function LastIndexOfAny(const AnyOf: array of Char; AStartIndex: Integer): Integer; overload;
|
||||||
|
Function LastIndexOfAny(const AnyOf: array of Char; AStartIndex: Integer; ACount: Integer): Integer; overload;
|
||||||
|
Function PadLeft(ATotalWidth: Integer): string; overload; inline;
|
||||||
|
Function PadLeft(ATotalWidth: Integer; PaddingChar: Char): string; overload; inline;
|
||||||
|
Function PadRight(ATotalWidth: Integer): string; overload; inline;
|
||||||
|
Function PadRight(ATotalWidth: Integer; PaddingChar: Char): string; overload; inline;
|
||||||
|
Function QuotedString: string; overload;
|
||||||
|
Function QuotedString(const AQuoteChar: Char): string; overload;
|
||||||
|
Function Remove(StartIndex: Integer): string; overload; inline;
|
||||||
|
Function Remove(StartIndex: Integer; ACount: Integer): string; overload; inline;
|
||||||
|
Function Replace(OldChar: Char; NewChar: Char): string; overload;
|
||||||
|
Function Replace(OldChar: Char; NewChar: Char; ReplaceFlags: TReplaceFlags): string; overload;
|
||||||
|
Function Replace(const OldValue: string; const NewValue: string): string; overload;
|
||||||
|
Function Replace(const OldValue: string; const NewValue: string; ReplaceFlags: TReplaceFlags): string; overload;
|
||||||
|
Function Split(const Separators: array of Char): TStringArray; overload;
|
||||||
|
Function Split(const Separators: array of Char; ACount: Integer): TStringArray; overload;
|
||||||
|
Function Split(const Separators: array of Char; Options: TStringSplitOptions): TStringArray; overload;
|
||||||
|
Function Split(const Separators: array of Char; ACount: Integer; Options: TStringSplitOptions): TStringArray; overload;
|
||||||
|
Function Split(const Separators: array of string): TStringArray; overload;
|
||||||
|
Function Split(const Separators: array of string; ACount: Integer): TStringArray; overload;
|
||||||
|
Function Split(const Separators: array of string; Options: TStringSplitOptions): TStringArray; overload;
|
||||||
|
Function Split(const Separators: array of string; ACount: Integer; Options: TStringSplitOptions): TStringArray; overload;
|
||||||
|
Function Split(const Separators: array of Char; AQuote: Char): TStringArray; overload;
|
||||||
|
Function Split(const Separators: array of Char; AQuoteStart, AQuoteEnd: Char): TStringArray; overload;
|
||||||
|
Function Split(const Separators: array of Char; AQuoteStart, AQuoteEnd: Char; Options: TStringSplitOptions): TStringArray; overload;
|
||||||
|
Function Split(const Separators: array of Char; AQuoteStart, AQuoteEnd: Char; ACount: Integer): TStringArray; overload;
|
||||||
|
Function Split(const Separators: array of Char; AQuoteStart, AQuoteEnd: Char; ACount: Integer; Options: TStringSplitOptions): TStringArray; overload;
|
||||||
|
Function Split(const Separators: array of string; AQuote: Char): TStringArray; overload;
|
||||||
|
Function Split(const Separators: array of string; AQuoteStart, AQuoteEnd: Char): TStringArray; overload;
|
||||||
|
Function Split(const Separators: array of string; AQuoteStart, AQuoteEnd: Char; Options: TStringSplitOptions): TStringArray; overload;
|
||||||
|
Function Split(const Separators: array of string; AQuoteStart, AQuoteEnd: Char; ACount: Integer): TStringArray; overload;
|
||||||
|
Function Split(const Separators: array of string; AQuoteStart, AQuoteEnd: Char; ACount: Integer; Options: TStringSplitOptions): TStringArray; overload;
|
||||||
|
Function StartsWith(const AValue: string): Boolean; overload; inline;
|
||||||
|
Function StartsWith(const AValue: string; IgnoreCase: Boolean): Boolean; overload;
|
||||||
|
Function Substring(AStartIndex: Integer): string; overload;
|
||||||
|
Function Substring(AStartIndex: Integer; ALen: Integer): string; overload;
|
||||||
|
Function ToBoolean: Boolean; overload; inline;
|
||||||
|
Function ToInteger: Integer; overload; inline;
|
||||||
|
Function ToInt64: Int64; overload; inline;
|
||||||
|
Function ToSingle: Single; overload; inline;
|
||||||
|
Function ToDouble: Double; overload; inline;
|
||||||
|
Function ToExtended: Extended; overload; inline;
|
||||||
|
Function ToCharArray: TCharArray; overload;
|
||||||
|
Function ToCharArray(AStartIndex: Integer; ALen: Integer): TCharArray; overload;
|
||||||
|
Function ToLower: string; overload; inline;
|
||||||
|
Function ToLowerInvariant: string;
|
||||||
|
Function ToUpper: string; overload; inline;
|
||||||
|
Function ToUpperInvariant: string; inline;
|
||||||
|
Function Trim: string; overload;
|
||||||
|
Function TrimLeft: string; overload;
|
||||||
|
Function TrimRight: string; overload;
|
||||||
|
Function Trim(const ATrimChars: array of Char): string; overload;
|
||||||
|
Function TrimLeft(const ATrimChars: array of Char): string; overload;
|
||||||
|
Function TrimRight(const ATrimChars: array of Char): string; overload;
|
||||||
|
Function TrimEnd(const ATrimChars: array of Char): string; deprecated 'Use TrimRight';
|
||||||
|
Function TrimStart(const ATrimChars: array of Char): string; deprecated 'Use TrimLeft';
|
||||||
|
property Chars[AIndex: Integer]: Char read GetChar;
|
||||||
|
property Length: Integer read GetLength;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{$IFDEF FPC_HAS_TYPE_SINGLE}
|
||||||
|
TSingleHelper = Type Helper for Single
|
||||||
|
Function GetB(AIndex: Cardinal): Byte;
|
||||||
|
Function GetW(AIndex: Cardinal): Word;
|
||||||
|
Function GetE: QWord; inline;
|
||||||
|
Function GetF: QWord; inline;
|
||||||
|
Function GetS: Boolean; inline;
|
||||||
|
procedure SetB(AIndex: Cardinal; const AValue: Byte);
|
||||||
|
procedure SetW(AIndex: Cardinal; const AValue: Word);
|
||||||
|
procedure SetE(AValue: QWord);
|
||||||
|
procedure SetF(AValue: QWord);
|
||||||
|
procedure SetS(AValue: Boolean);
|
||||||
|
public
|
||||||
|
{$push}
|
||||||
|
{$R-}
|
||||||
|
{$Q-}
|
||||||
|
const
|
||||||
|
Epsilon : Single = 1.4012984643248170709e-45;
|
||||||
|
MaxValue : Single = 340282346638528859811704183484516925440.0;
|
||||||
|
MinValue : Single = -340282346638528859811704183484516925440.0;
|
||||||
|
PositiveInfinity : Single = 1.0/0.0;
|
||||||
|
NegativeInfinity : Single = -1.0/0.0;
|
||||||
|
NaN : Single = 0.0/0.0;
|
||||||
|
{$POP}
|
||||||
|
Class Function IsNan(const AValue: Single): Boolean; overload; inline; static;
|
||||||
|
Class Function IsInfinity(const AValue: Single): Boolean; overload; inline; static;
|
||||||
|
Class Function IsNegativeInfinity(const AValue: Single): Boolean; overload; inline; static;
|
||||||
|
Class Function IsPositiveInfinity(const AValue: Single): Boolean; overload; inline; static;
|
||||||
|
Class Function Parse(const AString: string): Single; overload; inline; static;
|
||||||
|
Class Function Parse(const AString: string; const AFormatSettings: TFormatSettings): Single; overload; inline; static;
|
||||||
|
Class Function Size: Integer; inline; static;
|
||||||
|
Class Function ToString(const AValue: Single): string; overload; inline; static;
|
||||||
|
Class Function ToString(const AValue: Single; const AFormatSettings: TFormatSettings): string; overload; inline; static;
|
||||||
|
Class Function ToString(const AValue: Single; const AFormat: TFloatFormat; const APrecision, ADigits: Integer): string; overload; inline; static;
|
||||||
|
Class Function ToString(const AValue: Single; const AFormat: TFloatFormat; const APrecision, ADigits: Integer;
|
||||||
|
const AFormatSettings: TFormatSettings): string; overload; inline; static;
|
||||||
|
Class Function TryParse(const AString: string; out AValue: Single): Boolean; overload; inline; static;
|
||||||
|
Class Function TryParse(const AString: string; out AValue: Single; const AFormatSettings: TFormatSettings): Boolean; overload; inline; static;
|
||||||
|
|
||||||
|
Procedure BuildUp(const ASignFlag: Boolean; const AMantissa: QWord; const AExponent: Integer);
|
||||||
|
Function Exponent: Integer;
|
||||||
|
Function Fraction: Extended;
|
||||||
|
Function IsInfinity: Boolean; overload; inline;
|
||||||
|
Function IsNan: Boolean; overload; inline;
|
||||||
|
Function IsNegativeInfinity: Boolean; overload; inline;
|
||||||
|
Function IsPositiveInfinity: Boolean; overload; inline;
|
||||||
|
Function Mantissa: QWord;
|
||||||
|
Function SpecialType: TFloatSpecial;
|
||||||
|
Function ToString(const AFormat: TFloatFormat; const APrecision, ADigits: Integer): string; overload; inline;
|
||||||
|
Function ToString(const AFormat: TFloatFormat; const APrecision, ADigits: Integer; const AFormatSettings: TFormatSettings): string; overload; inline;
|
||||||
|
Function ToString(const AFormatSettings: TFormatSettings): string; overload; inline;
|
||||||
|
Function ToString: string; overload; inline;
|
||||||
|
|
||||||
|
property Bytes[AIndex: Cardinal]: Byte read GetB write SetB;
|
||||||
|
property Words[AIndex: Cardinal]: Word read GetW write SetW;
|
||||||
|
property Sign: Boolean read GetS write SetS;
|
||||||
|
property Exp: QWord read GetE write SetE;
|
||||||
|
property Frac: QWord read GetF write SetF;
|
||||||
|
end;
|
||||||
|
{$ENDIF FPC_HAS_TYPE_SINGLE}
|
||||||
|
|
||||||
|
{$IFDEF FPC_HAS_TYPE_DOUBLE}
|
||||||
|
TDoubleHelper = Type Helper for Double
|
||||||
|
private
|
||||||
|
Function GetB(AIndex: Cardinal): Byte;
|
||||||
|
Function GetW(AIndex: Cardinal): Word;
|
||||||
|
Function GetE: QWord; inline;
|
||||||
|
Function GetF: QWord; inline;
|
||||||
|
Function GetS: Boolean; inline;
|
||||||
|
procedure SetB(AIndex: Cardinal; const AValue: Byte);
|
||||||
|
procedure SetW(AIndex: Cardinal; const AValue: Word);
|
||||||
|
procedure SetE(AValue: QWord);
|
||||||
|
procedure SetF(AValue: QWord);
|
||||||
|
procedure SetS(AValue: Boolean);
|
||||||
|
public
|
||||||
|
const
|
||||||
|
{$push}
|
||||||
|
{$R-}
|
||||||
|
{$Q-}
|
||||||
|
Epsilon : Double = 4.9406564584124654418e-324;
|
||||||
|
MaxValue : Double = 1.7976931348623157081e+308;
|
||||||
|
MinValue : Double = -1.7976931348623157081e+308;
|
||||||
|
PositiveInfinity : Double = 1.0/0.0;
|
||||||
|
NegativeInfinity : Double = -1.0/0.0;
|
||||||
|
NaN : Double = 0.0/0.0;
|
||||||
|
{$POP}
|
||||||
|
Class Function IsInfinity(const AValue: Double): Boolean; overload; inline; static;
|
||||||
|
Class Function IsNan(const AValue: Double): Boolean; overload; inline; static;
|
||||||
|
Class Function IsNegativeInfinity(const AValue: Double): Boolean; overload; inline; static;
|
||||||
|
Class Function IsPositiveInfinity(const AValue: Double): Boolean; overload; inline; static;
|
||||||
|
Class Function Parse(const AString: string): Double; overload; inline; static;
|
||||||
|
Class Function Parse(const AString: string; const AFormatSettings: TFormatSettings): Double; overload; inline; static;
|
||||||
|
Class Function Size: Integer; inline; static;
|
||||||
|
Class Function ToString(const AValue: Double): string; overload; inline; static;
|
||||||
|
Class Function ToString(const AValue: Double; const AFormat: TFloatFormat; const APrecision, ADigits: Integer): string; overload; inline; static;
|
||||||
|
Class Function ToString(const AValue: Double; const AFormat: TFloatFormat; const APrecision, ADigits: Integer; const AFormatSettings: TFormatSettings): string; overload; inline; static;
|
||||||
|
Class Function ToString(const AValue: Double; const AFormatSettings: TFormatSettings): string; overload; inline; static;
|
||||||
|
Class Function TryParse(const AString: string; out AValue: Double): Boolean; overload; inline; static;
|
||||||
|
Class Function TryParse(const AString: string; out AValue: Double; const AFormatSettings: TFormatSettings): Boolean; overload; inline; static;
|
||||||
|
|
||||||
|
Procedure BuildUp(const ASignFlag: Boolean; const AMantissa: QWord; const AExponent: Integer);
|
||||||
|
Function Exponent: Integer;
|
||||||
|
Function Fraction: Extended;
|
||||||
|
Function IsInfinity: Boolean; overload; inline;
|
||||||
|
Function IsNan: Boolean; overload; inline;
|
||||||
|
Function IsNegativeInfinity: Boolean; overload; inline;
|
||||||
|
Function IsPositiveInfinity: Boolean; overload; inline;
|
||||||
|
Function Mantissa: QWord;
|
||||||
|
Function SpecialType: TFloatSpecial;
|
||||||
|
Function ToString(const AFormat: TFloatFormat; const APrecision, ADigits: Integer): string; overload; inline;
|
||||||
|
Function ToString(const AFormat: TFloatFormat; const APrecision, ADigits: Integer; const AFormatSettings: TFormatSettings): string; overload; inline;
|
||||||
|
Function ToString(const AFormatSettings: TFormatSettings): string; overload; inline;
|
||||||
|
Function ToString: string; overload; inline;
|
||||||
|
|
||||||
|
property Bytes[AIndex: Cardinal]: Byte read GetB write SetB; // 0..7
|
||||||
|
property Words[AIndex: Cardinal]: Word read GetW write SetW; // 0..3
|
||||||
|
property Sign: Boolean read GetS write SetS;
|
||||||
|
property Exp: QWord read GetE write SetE;
|
||||||
|
property Frac: QWord read GetF write SetF;
|
||||||
|
end;
|
||||||
|
{$ENDIF FPC_HAS_TYPE_DOUBLE}
|
||||||
|
|
||||||
|
{$ifdef FPC_HAS_TYPE_EXTENDED}
|
||||||
|
TExtendedHelper = Type Helper for Extended
|
||||||
|
private
|
||||||
|
Function GetB(AIndex: Cardinal): Byte;
|
||||||
|
Function GetW(AIndex: Cardinal): Word;
|
||||||
|
Function GetE: QWord; inline;
|
||||||
|
Function GetF: QWord; inline;
|
||||||
|
Function GetS: Boolean; inline;
|
||||||
|
procedure SetB(AIndex: Cardinal; const AValue: Byte);
|
||||||
|
procedure SetW(AIndex: Cardinal; const AValue: Word);
|
||||||
|
procedure SetE(AValue: QWord);
|
||||||
|
procedure SetF(AValue: QWord);
|
||||||
|
procedure SetS(AValue: Boolean);
|
||||||
|
public
|
||||||
|
{$push}
|
||||||
|
{$R-}
|
||||||
|
{$Q-}
|
||||||
|
const
|
||||||
|
Epsilon : Extended = 3.64519953188247460253e-4951;
|
||||||
|
MaxValue : Extended = 1.18973149535723176505e+4932;
|
||||||
|
MinValue : Extended = -1.18973149535723176505e+4932;
|
||||||
|
PositiveInfinity : Extended = 1.0/0.0;
|
||||||
|
NegativeInfinity : Extended = -1.0/0.0;
|
||||||
|
NaN : Extended = 0.0/0.0;
|
||||||
|
{$POP}
|
||||||
|
Class Function ToString(const AValue: Extended): string; overload; inline; static;
|
||||||
|
Class Function ToString(const AValue: Extended; const AFormatSettings: TFormatSettings): string; overload; inline; static;
|
||||||
|
Class Function ToString(const AValue: Extended; const AFormat: TFloatFormat; const APrecision, ADigits: Integer): string; overload; inline; static;
|
||||||
|
Class Function ToString(const AValue: Extended; const AFormat: TFloatFormat; const APrecision, ADigits: Integer; const AFormatSettings: TFormatSettings): string; overload; inline; static;
|
||||||
|
Class Function Parse(const AString: string): Extended; overload; inline; static;
|
||||||
|
Class Function Parse(const AString: string; const AFormatSettings: TFormatSettings): Extended; overload; inline; static;
|
||||||
|
Class Function TryParse(const AString: string; out AValue: Extended): Boolean; overload; inline; static;
|
||||||
|
Class Function TryParse(const AString: string; out AValue: Extended; const AFormatSettings: TFormatSettings): Boolean; overload; inline; static;
|
||||||
|
Class Function IsNan(const AValue: Extended): Boolean; overload; inline; static;
|
||||||
|
Class Function IsInfinity(const AValue: Extended): Boolean; overload; inline; static;
|
||||||
|
Class Function IsNegativeInfinity(const AValue: Extended): Boolean; overload; inline; static;
|
||||||
|
Class Function IsPositiveInfinity(const AValue: Extended): Boolean; overload; inline; static;
|
||||||
|
Class Function Size: Integer; inline; static;
|
||||||
|
|
||||||
|
procedure BuildUp(const ASignFlag: Boolean; const AMantissa: QWord; Const AExponent: Integer);
|
||||||
|
Function Exponent: Integer;
|
||||||
|
Function Fraction: Extended;
|
||||||
|
Function IsInfinity: Boolean; overload; inline;
|
||||||
|
Function IsNan: Boolean; overload; inline;
|
||||||
|
Function IsNegativeInfinity: Boolean; overload; inline;
|
||||||
|
Function IsPositiveInfinity: Boolean; overload; inline;
|
||||||
|
Function Mantissa: QWord;
|
||||||
|
Function SpecialType: TFloatSpecial;
|
||||||
|
Function ToString(const AFormat: TFloatFormat; const APrecision, ADigits: Integer): string; overload; inline;
|
||||||
|
Function ToString(const AFormat: TFloatFormat; const APrecision, ADigits: Integer; const AFormatSettings: TFormatSettings): string; overload; inline;
|
||||||
|
Function ToString(const AFormatSettings: TFormatSettings): string; overload; inline;
|
||||||
|
Function ToString: string; overload; inline;
|
||||||
|
|
||||||
|
property Bytes[AIndex: Cardinal]: Byte read GetB write SetB;
|
||||||
|
property Words[AIndex: Cardinal]: Word read GetW write SetW;
|
||||||
|
property Sign: Boolean read GetS write SetS;
|
||||||
|
property Exp: QWord read GetE write SetE;
|
||||||
|
property Frac: QWord read GetF write SetF;
|
||||||
|
end;
|
||||||
|
{$ENDIF FPC_HAS_TYPE_EXTENDED}
|
||||||
|
|
||||||
|
TByteHelper = Type Helper for Byte
|
||||||
|
public
|
||||||
|
const
|
||||||
|
MaxValue = 255;
|
||||||
|
MinValue = 0;
|
||||||
|
public
|
||||||
|
Class Function Parse(const AString: string): Byte; inline; static;
|
||||||
|
Class Function Size: Integer; inline; static;
|
||||||
|
Class Function ToString(const AValue: Byte): string; overload; inline; static;
|
||||||
|
Class Function TryParse(const AString: string; out AValue: Byte): Boolean; inline; static;
|
||||||
|
Public
|
||||||
|
Function ToBoolean: Boolean; inline;
|
||||||
|
Function ToDouble: Double; inline;
|
||||||
|
Function ToExtended: Extended; inline;
|
||||||
|
Function ToHexString(const AMinDigits: Integer): string; overload; inline;
|
||||||
|
Function ToHexString: string; overload; inline;
|
||||||
|
Function ToSingle: Single; inline;
|
||||||
|
Function ToString: string; overload; inline;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TShortIntHelper = Type Helper for ShortInt
|
||||||
|
public
|
||||||
|
const
|
||||||
|
MaxValue = 127;
|
||||||
|
MinValue = -128;
|
||||||
|
public
|
||||||
|
Class Function Parse(const AString: string): ShortInt; inline; static;
|
||||||
|
Class Function Size: Integer; inline; static;
|
||||||
|
Class Function ToString(const AValue: ShortInt): string; overload; inline; static;
|
||||||
|
Class Function TryParse(const AString: string; out AValue: ShortInt): Boolean; inline; static;
|
||||||
|
public
|
||||||
|
Function ToBoolean: Boolean; inline;
|
||||||
|
Function ToDouble: Double; inline;
|
||||||
|
Function ToExtended: Extended; inline;
|
||||||
|
Function ToHexString(const AMinDigits: Integer): string; overload; inline;
|
||||||
|
Function ToHexString: string; overload; inline;
|
||||||
|
Function ToSingle: Single; inline;
|
||||||
|
Function ToString: string; overload; inline;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TSmallIntHelper = Type Helper for SmallInt
|
||||||
|
public
|
||||||
|
const
|
||||||
|
MaxValue = 32767;
|
||||||
|
MinValue = -32768;
|
||||||
|
public
|
||||||
|
Class Function Parse(const AString: string): SmallInt; inline; static;
|
||||||
|
Class Function Size: Integer; inline; static;
|
||||||
|
Class Function ToString(const AValue: SmallInt): string; overload; inline; static;
|
||||||
|
Class Function TryParse(const AString: string; out AValue: SmallInt): Boolean; inline; static;
|
||||||
|
public
|
||||||
|
Function ToString: string; overload; inline;
|
||||||
|
Function ToBoolean: Boolean; inline;
|
||||||
|
Function ToHexString: string; overload; inline;
|
||||||
|
Function ToHexString(const AMinDigits: Integer): string; overload; inline;
|
||||||
|
Function ToSingle: Single; inline;
|
||||||
|
Function ToDouble: Double; inline;
|
||||||
|
Function ToExtended: Extended; inline;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TWordHelper = Type Helper for Word
|
||||||
|
public
|
||||||
|
const
|
||||||
|
MaxValue = 65535;
|
||||||
|
MinValue = 0;
|
||||||
|
Public
|
||||||
|
Class Function Parse(const AString: string): Word; inline; static;
|
||||||
|
Class Function Size: Integer; inline; static;
|
||||||
|
Class Function ToString(const AValue: Word): string; overload; inline; static;
|
||||||
|
Class Function TryParse(const AString: string; out AValue: Word): Boolean; inline; static;
|
||||||
|
Public
|
||||||
|
Function ToBoolean: Boolean; inline;
|
||||||
|
Function ToDouble: Double; inline;
|
||||||
|
Function ToExtended: Extended; inline;
|
||||||
|
Function ToHexString(const AMinDigits: Integer): string; overload; inline;
|
||||||
|
Function ToHexString: string; overload; inline;
|
||||||
|
Function ToSingle: Single; inline;
|
||||||
|
Function ToString: string; overload; inline;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TCardinalHelper = Type Helper for Cardinal { for LongWord Type too }
|
||||||
|
public
|
||||||
|
const
|
||||||
|
MaxValue = 4294967295;
|
||||||
|
MinValue = 0;
|
||||||
|
Public
|
||||||
|
Class Function Parse(const AString: string): Cardinal; inline; static;
|
||||||
|
Class Function Size: Integer; inline; static;
|
||||||
|
Class Function ToString(const AValue: Cardinal): string; overload; inline; static;
|
||||||
|
Class Function TryParse(const AString: string; out AValue: Cardinal): Boolean; inline; static;
|
||||||
|
Public
|
||||||
|
Function ToBoolean: Boolean; inline;
|
||||||
|
Function ToDouble: Double; inline;
|
||||||
|
Function ToExtended: Extended; inline;
|
||||||
|
Function ToHexString(const AMinDigits: Integer): string; overload; inline;
|
||||||
|
Function ToHexString: string; overload; inline;
|
||||||
|
Function ToSingle: Single; inline;
|
||||||
|
Function ToString: string; overload; inline;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TIntegerHelper = Type Helper for Integer { for LongInt Type too }
|
||||||
|
public
|
||||||
|
const
|
||||||
|
MaxValue = 2147483647;
|
||||||
|
MinValue = -2147483648;
|
||||||
|
Public
|
||||||
|
Class Function Size: Integer; inline; static;
|
||||||
|
Class Function ToString(const AValue: Integer): string; overload; inline; static;
|
||||||
|
Class Function Parse(const AString: string): Integer; inline; static;
|
||||||
|
Class Function TryParse(const AString: string; out AValue: Integer): Boolean; inline; static;
|
||||||
|
Public
|
||||||
|
Function ToBoolean: Boolean; inline;
|
||||||
|
Function ToDouble: Double; inline;
|
||||||
|
Function ToExtended: Extended; inline;
|
||||||
|
Function ToHexString(const AMinDigits: Integer): string; overload; inline;
|
||||||
|
Function ToHexString: string; overload; inline;
|
||||||
|
Function ToSingle: Single; inline;
|
||||||
|
Function ToString: string; overload; inline;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TInt64Helper = Type Helper for Int64
|
||||||
|
public
|
||||||
|
const
|
||||||
|
MaxValue = 9223372036854775807;
|
||||||
|
MinValue = -9223372036854775808;
|
||||||
|
Public
|
||||||
|
Class Function Parse(const AString: string): Int64; inline; static;
|
||||||
|
Class Function Size: Integer; inline; static;
|
||||||
|
Class Function ToString(const AValue: Int64): string; overload; inline; static;
|
||||||
|
Class Function TryParse(const AString: string; out AValue: Int64): Boolean; inline; static;
|
||||||
|
Public
|
||||||
|
Function ToBoolean: Boolean; inline;
|
||||||
|
Function ToDouble: Double; inline;
|
||||||
|
Function ToExtended: Extended; inline;
|
||||||
|
Function ToHexString(const AMinDigits: Integer): string; overload; inline;
|
||||||
|
Function ToHexString: string; overload; inline;
|
||||||
|
Function ToSingle: Single; inline;
|
||||||
|
Function ToString: string; overload; inline;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TQWordHelper = Type Helper for QWord
|
||||||
|
public
|
||||||
|
const
|
||||||
|
MaxValue = 18446744073709551615;
|
||||||
|
MinValue = 0;
|
||||||
|
Public
|
||||||
|
Class Function Parse(const AString: string): QWord; inline; static;
|
||||||
|
Class Function Size: Integer; inline; static;
|
||||||
|
Class Function ToString(const AValue: QWord): string; overload; inline; static;
|
||||||
|
Class Function TryParse(const AString: string; out AValue: QWord): Boolean; inline; static;
|
||||||
|
Public
|
||||||
|
Function ToBoolean: Boolean; inline;
|
||||||
|
Function ToDouble: Double; inline;
|
||||||
|
Function ToExtended: Extended; inline;
|
||||||
|
Function ToHexString(const AMinDigits: Integer): string; overload; inline;
|
||||||
|
Function ToHexString: string; overload; inline;
|
||||||
|
Function ToSingle: Single; inline;
|
||||||
|
Function ToString: string; overload; inline;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TNativeIntHelper = Type Helper for NativeInt
|
||||||
|
public
|
||||||
|
const
|
||||||
|
{$IFDEF CPU64BITS}
|
||||||
|
MaxValue = 9223372036854775807;
|
||||||
|
MinValue = -9223372036854775808;
|
||||||
|
{$ELSE !CPU64BITS}
|
||||||
|
MaxValue = 2147483647;
|
||||||
|
MinValue = -2147483648;
|
||||||
|
{$ENDIF CPU64BITS}
|
||||||
|
Public
|
||||||
|
Class Function Parse(const AString: string): NativeInt; inline; static;
|
||||||
|
Class Function Size: Integer; inline; static;
|
||||||
|
Class Function ToString(const AValue: NativeInt): string; overload; inline; static;
|
||||||
|
Class Function TryParse(const AString: string; out AValue: NativeInt): Boolean; inline; static;
|
||||||
|
Public
|
||||||
|
Function ToBoolean: Boolean; inline;
|
||||||
|
Function ToDouble: Double; inline;
|
||||||
|
Function ToExtended: Extended; inline;
|
||||||
|
Function ToHexString(const AMinDigits: Integer): string; overload; inline;
|
||||||
|
Function ToHexString: string; overload; inline;
|
||||||
|
Function ToSingle: Single; inline;
|
||||||
|
Function ToString: string; overload; inline;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TNativeUIntHelper = Type Helper for NativeUInt
|
||||||
|
public
|
||||||
|
const
|
||||||
|
{$IFDEF CPU64BITS}
|
||||||
|
MaxValue = 18446744073709551615;
|
||||||
|
{$ELSE !CPU64BITS}
|
||||||
|
MaxValue = 4294967295;
|
||||||
|
{$ENDIF CPU64BITS}
|
||||||
|
MinValue = 0;
|
||||||
|
Public
|
||||||
|
Class Function Parse(const AString: string): NativeUInt; inline; static;
|
||||||
|
Class Function Size: Integer; inline; static;
|
||||||
|
Class Function ToString(const AValue: NativeUInt): string; overload; inline; static;
|
||||||
|
Class Function TryParse(const AString: string; out AValue: NativeUInt): Boolean; inline; static;
|
||||||
|
Public
|
||||||
|
Function ToBoolean: Boolean; inline;
|
||||||
|
Function ToDouble: Double; inline;
|
||||||
|
Function ToExtended: Extended; inline;
|
||||||
|
Function ToHexString(const AMinDigits: Integer): string; overload; inline;
|
||||||
|
Function ToHexString: string; overload; inline;
|
||||||
|
Function ToSingle: Single; inline;
|
||||||
|
Function ToString: string; overload; inline;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{$SCOPEDENUMS ON}
|
||||||
|
TUseBoolStrs = (False, True);
|
||||||
|
{$SCOPEDENUMS OFF}
|
||||||
|
|
||||||
|
TBooleanHelper = Type Helper for Boolean
|
||||||
|
public
|
||||||
|
Class Function Parse(const S: string): Boolean; inline; static;
|
||||||
|
Class Function Size: Integer; inline; static;
|
||||||
|
Class Function ToString(const AValue: Boolean; UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline; static;
|
||||||
|
Class Function TryToParse(const S: string; out AValue: Boolean): Boolean; inline; static;
|
||||||
|
Public
|
||||||
|
Function ToInteger: Integer; inline;
|
||||||
|
Function ToString(UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TByteBoolHelper = Type Helper for ByteBool
|
||||||
|
public
|
||||||
|
Class Function Parse(const S: string): Boolean; inline; static;
|
||||||
|
Class Function Size: Integer; inline; static;
|
||||||
|
Class Function ToString(const AValue: Boolean; UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline; static;
|
||||||
|
Class Function TryToParse(const S: string; out AValue: Boolean): Boolean; inline; static;
|
||||||
|
Public
|
||||||
|
Function ToInteger: Integer; inline;
|
||||||
|
Function ToString(UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TWordBoolHelper = Type Helper for WordBool
|
||||||
|
public
|
||||||
|
Class Function Parse(const S: string): Boolean; inline; static;
|
||||||
|
Class Function Size: Integer; inline; static;
|
||||||
|
Class Function ToString(const AValue: Boolean; UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline; static;
|
||||||
|
Class Function TryToParse(const S: string; out AValue: Boolean): Boolean; inline; static;
|
||||||
|
Public
|
||||||
|
Function ToInteger: Integer; inline;
|
||||||
|
Function ToString(UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TLongBoolHelper = Type Helper for LongBool
|
||||||
|
public
|
||||||
|
Class Function Parse(const S: string): Boolean; inline; static;
|
||||||
|
Class Function Size: Integer; inline; static;
|
||||||
|
Class Function ToString(const AValue: Boolean; UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline; static;
|
||||||
|
Class Function TryToParse(const S: string; out AValue: Boolean): Boolean; inline; static;
|
||||||
|
public
|
||||||
|
Function ToInteger: Integer; inline;
|
||||||
|
Function ToString(UseBoolStrs: TUseBoolStrs = TUseBoolStrs.False): string; overload; inline;
|
||||||
|
end;
|
||||||
71
rtl/objpas/sysutils/syshelpo.inc
Normal file
71
rtl/objpas/sysutils/syshelpo.inc
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
|
||||||
|
Class Function TORDINALHELPER.Parse(const AString: string): TORDINALTYPE; inline; static;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=StrToInt(AString);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Class Function TORDINALHELPER.Size: Integer; inline; static;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=SizeOf(TORDINALTYPE);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Class Function TORDINALHELPER.ToString(const AValue: TORDINALTYPE): string; overload; inline; static;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=IntToStr(AValue);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Class Function TORDINALHELPER.TryParse(const AString: string; out AValue: TORDINALTYPE): Boolean; inline; static;
|
||||||
|
|
||||||
|
Var
|
||||||
|
C : Integer;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Val(AString,AValue,C);
|
||||||
|
Result:=(C=0);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function TORDINALHELPER.ToBoolean: Boolean; inline;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=(Self<>0);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function TORDINALHELPER.ToDouble: Double; inline;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=Self;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function TORDINALHELPER.ToExtended: Extended; inline;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=Self;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function TORDINALHELPER.ToHexString(const AMinDigits: Integer): string;
|
||||||
|
overload; inline;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=HexStr(Self,AMinDigits);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function TORDINALHELPER.ToHexString: string; overload; inline;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=HexStr(Self,SizeOf(TORDINALTYPE)*2);
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function TORDINALHELPER.ToSingle: Single; inline;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=Self;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Function TORDINALHELPER.ToString: string; overload; inline;
|
||||||
|
|
||||||
|
begin
|
||||||
|
Result:=IntToStr(Self);
|
||||||
|
end;
|
||||||
@ -108,25 +108,25 @@ function UnicodeLowerCase(const s : UnicodeString) : UnicodeString;{$ifdef SYSUT
|
|||||||
|
|
||||||
function UnicodeCompareStr(const s1, s2 : UnicodeString) : PtrInt;{$ifdef SYSUTILSINLINE}inline;{$endif}
|
function UnicodeCompareStr(const s1, s2 : UnicodeString) : PtrInt;{$ifdef SYSUTILSINLINE}inline;{$endif}
|
||||||
begin
|
begin
|
||||||
result:=widestringmanager.CompareUnicodeStringProc(s1,s2);
|
result:=widestringmanager.CompareUnicodeStringProc(s1,s2,[]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function UnicodeSameStr(const s1, s2 : UnicodeString) : Boolean;{$ifdef SYSUTILSINLINE}inline;{$endif}
|
function UnicodeSameStr(const s1, s2 : UnicodeString) : Boolean;{$ifdef SYSUTILSINLINE}inline;{$endif}
|
||||||
begin
|
begin
|
||||||
result:=widestringmanager.CompareUnicodeStringProc(s1,s2)=0;
|
result:=widestringmanager.CompareUnicodeStringProc(s1,s2,[])=0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function UnicodeCompareText(const s1, s2 : UnicodeString) : PtrInt;{$ifdef SYSUTILSINLINE}inline;{$endif}
|
function UnicodeCompareText(const s1, s2 : UnicodeString) : PtrInt;{$ifdef SYSUTILSINLINE}inline;{$endif}
|
||||||
begin
|
begin
|
||||||
result:=widestringmanager.CompareTextUnicodeStringProc(s1,s2);
|
result:=widestringmanager.CompareUnicodeStringProc(s1,s2,[coIgnoreCase]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function UnicodeSameText(const s1, s2 : UnicodeString) : Boolean;{$ifdef SYSUTILSINLINE}inline;{$endif}
|
function UnicodeSameText(const s1, s2 : UnicodeString) : Boolean;{$ifdef SYSUTILSINLINE}inline;{$endif}
|
||||||
begin
|
begin
|
||||||
result:=widestringmanager.CompareTextUnicodeStringProc(s1,s2)=0;
|
result:=widestringmanager.CompareUnicodeStringProc(s1,s2,[coIgnoreCase])=0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -308,6 +308,9 @@ Type
|
|||||||
{ read thread handling }
|
{ read thread handling }
|
||||||
{$i systhrdh.inc}
|
{$i systhrdh.inc}
|
||||||
|
|
||||||
|
{ Type Helpers}
|
||||||
|
{$i syshelph.inc}
|
||||||
|
|
||||||
procedure FreeAndNil(var obj);
|
procedure FreeAndNil(var obj);
|
||||||
|
|
||||||
{ interface handling }
|
{ interface handling }
|
||||||
|
|||||||
@ -39,7 +39,9 @@
|
|||||||
|
|
||||||
{ variant error codes }
|
{ variant error codes }
|
||||||
{$i varerror.inc}
|
{$i varerror.inc}
|
||||||
|
|
||||||
|
{ Type helpers}
|
||||||
|
{$i syshelp.inc}
|
||||||
|
|
||||||
{$ifndef OS_FILEISREADONLY}
|
{$ifndef OS_FILEISREADONLY}
|
||||||
Function FileIsReadOnly(const FileName: RawByteString): Boolean;
|
Function FileIsReadOnly(const FileName: RawByteString): Boolean;
|
||||||
|
|||||||
@ -64,25 +64,25 @@ function WideLowerCase(const s : WideString) : WideString;{$ifdef SYSUTILSINLINE
|
|||||||
|
|
||||||
function WideCompareStr(const s1, s2 : WideString) : PtrInt;{$ifdef SYSUTILSINLINE}inline;{$endif}
|
function WideCompareStr(const s1, s2 : WideString) : PtrInt;{$ifdef SYSUTILSINLINE}inline;{$endif}
|
||||||
begin
|
begin
|
||||||
result:=widestringmanager.CompareWideStringProc(s1,s2);
|
result:=widestringmanager.CompareWideStringProc(s1,s2,[]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function WideSameStr(const s1, s2 : WideString) : Boolean;{$ifdef SYSUTILSINLINE}inline;{$endif}
|
function WideSameStr(const s1, s2 : WideString) : Boolean;{$ifdef SYSUTILSINLINE}inline;{$endif}
|
||||||
begin
|
begin
|
||||||
result:=widestringmanager.CompareWideStringProc(s1,s2)=0;
|
result:=widestringmanager.CompareWideStringProc(s1,s2,[])=0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function WideCompareText(const s1, s2 : WideString) : PtrInt;{$ifdef SYSUTILSINLINE}inline;{$endif}
|
function WideCompareText(const s1, s2 : WideString) : PtrInt;{$ifdef SYSUTILSINLINE}inline;{$endif}
|
||||||
begin
|
begin
|
||||||
result:=widestringmanager.CompareTextWideStringProc(s1,s2);
|
result:=widestringmanager.CompareWideStringProc(s1,s2,[coIgnoreCase]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function WideSameText(const s1, s2 : WideString) : Boolean;{$ifdef SYSUTILSINLINE}inline;{$endif}
|
function WideSameText(const s1, s2 : WideString) : Boolean;{$ifdef SYSUTILSINLINE}inline;{$endif}
|
||||||
begin
|
begin
|
||||||
result:=widestringmanager.CompareTextWideStringProc(s1,s2)=0;
|
result:=widestringmanager.CompareWideStringProc(s1,s2,[coIgnoreCase])=0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1253,13 +1253,19 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function OS2CompareUnicodeString (const S1, S2: UnicodeString): PtrInt;
|
function OS2CompareUnicodeString (const S1, S2: UnicodeString; Options : TCompareOptions): PtrInt;
|
||||||
var
|
var
|
||||||
HS1, HS2: UnicodeString;
|
HS1, HS2: UnicodeString;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
{ UniStrColl interprets null chars as end-of-string -> filter out }
|
{ UniStrColl interprets null chars as end-of-string -> filter out }
|
||||||
HS1 := NoNullsUnicodeString (S1);
|
HS1 := NoNullsUnicodeString (S1);
|
||||||
HS2 := NoNullsUnicodeString (S2);
|
HS2 := NoNullsUnicodeString (S2);
|
||||||
|
if coIgnoreCase in Options then
|
||||||
|
begin
|
||||||
|
HS1:=OS2UpperUnicodeString(HS1);
|
||||||
|
HS2:=OS2UpperUnicodeString(HS2);
|
||||||
|
end;
|
||||||
Result := Sys_UniStrColl (DefLocObj, PWideChar (HS1), PWideChar (HS2));
|
Result := Sys_UniStrColl (DefLocObj, PWideChar (HS1), PWideChar (HS2));
|
||||||
if Result < -1 then
|
if Result < -1 then
|
||||||
Result := -1
|
Result := -1
|
||||||
@ -1695,15 +1701,12 @@ begin
|
|||||||
WideStringManager.UpperWideStringProc := @OS2UpperUnicodeString;
|
WideStringManager.UpperWideStringProc := @OS2UpperUnicodeString;
|
||||||
WideStringManager.LowerWideStringProc := @OS2LowerUnicodeString;
|
WideStringManager.LowerWideStringProc := @OS2LowerUnicodeString;
|
||||||
WideStringManager.CompareWideStringProc := @OS2CompareUnicodeString;
|
WideStringManager.CompareWideStringProc := @OS2CompareUnicodeString;
|
||||||
WideStringManager.CompareTextWideStringProc := @OS2CompareTextUnicodeString;
|
|
||||||
{ Unicode }
|
{ Unicode }
|
||||||
WideStringManager.Unicode2AnsiMoveProc := @OS2Unicode2AnsiMove;
|
WideStringManager.Unicode2AnsiMoveProc := @OS2Unicode2AnsiMove;
|
||||||
WideStringManager.Ansi2UnicodeMoveProc := @OS2Ansi2UnicodeMove;
|
WideStringManager.Ansi2UnicodeMoveProc := @OS2Ansi2UnicodeMove;
|
||||||
WideStringManager.UpperUnicodeStringProc := @OS2UpperUnicodeString;
|
WideStringManager.UpperUnicodeStringProc := @OS2UpperUnicodeString;
|
||||||
WideStringManager.LowerUnicodeStringProc := @OS2LowerUnicodeString;
|
WideStringManager.LowerUnicodeStringProc := @OS2LowerUnicodeString;
|
||||||
WideStringManager.CompareUnicodeStringProc := @OS2CompareUnicodeString;
|
WideStringManager.CompareUnicodeStringProc := @OS2CompareUnicodeString;
|
||||||
WideStringManager.CompareTextUnicodeStringProc :=
|
|
||||||
@OS2CompareTextUnicodeString;
|
|
||||||
{ Codepage }
|
{ Codepage }
|
||||||
WideStringManager.GetStandardCodePageProc := @OS2GetStandardCodePage;
|
WideStringManager.GetStandardCodePageProc := @OS2GetStandardCodePage;
|
||||||
(*
|
(*
|
||||||
|
|||||||
@ -21,6 +21,8 @@ interface
|
|||||||
{$MODESWITCH OUT}
|
{$MODESWITCH OUT}
|
||||||
{ force ansistrings }
|
{ force ansistrings }
|
||||||
{$H+}
|
{$H+}
|
||||||
|
{$modeswitch typehelpers}
|
||||||
|
{$modeswitch advancedrecords}
|
||||||
|
|
||||||
{$DEFINE HAS_SLEEP}
|
{$DEFINE HAS_SLEEP}
|
||||||
{$DEFINE HAS_OSERROR}
|
{$DEFINE HAS_OSERROR}
|
||||||
|
|||||||
@ -766,36 +766,59 @@ function WideStringToUCS4StringNoNulls(const s : WideString) : UCS4String;
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function CompareWideString(const s1, s2 : WideString) : PtrInt;
|
function CompareWideString(const s1, s2 : WideString; Options : TCompareOptions) : PtrInt;
|
||||||
{$if not(defined (aix) and defined(cpupowerpc32))}
|
{$if not(defined (aix) and defined(cpupowerpc32))}
|
||||||
var
|
var
|
||||||
hs1,hs2 : UCS4String;
|
hs1,hs2 : UCS4String;
|
||||||
|
us1,us2 : WideString;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
{ wcscoll interprets null chars as end-of-string -> filter out }
|
{ wcscoll interprets null chars as end-of-string -> filter out }
|
||||||
hs1:=WideStringToUCS4StringNoNulls(s1);
|
if coIgnoreCase in Options then
|
||||||
hs2:=WideStringToUCS4StringNoNulls(s2);
|
begin
|
||||||
|
us1:=UpperWideString(s1);
|
||||||
|
us2:=UpperWideString(s2);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
us1:=s1;
|
||||||
|
us2:=s2;
|
||||||
|
end;
|
||||||
|
hs1:=WideStringToUCS4StringNoNulls(us1);
|
||||||
|
hs2:=WideStringToUCS4StringNoNulls(us2);
|
||||||
result:=wcscoll(pwchar_t(hs1),pwchar_t(hs2));
|
result:=wcscoll(pwchar_t(hs1),pwchar_t(hs2));
|
||||||
end;
|
end;
|
||||||
{$else}
|
{$else}
|
||||||
{ AIX/PPC32 has a 16 bit wchar_t }
|
{ AIX/PPC32 has a 16 bit wchar_t }
|
||||||
var
|
var
|
||||||
i, len: longint;
|
i, len: longint;
|
||||||
|
us1,us2 : WideString;
|
||||||
hs1, hs2: array of widechar;
|
hs1, hs2: array of widechar;
|
||||||
begin
|
begin
|
||||||
len:=length(s1);
|
if coIgnoreCase in Options then
|
||||||
|
begin
|
||||||
|
us1:=UpperWideString(s1);
|
||||||
|
us2:=UpperWideString(s2);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
us1:=s1;
|
||||||
|
us2:=s2;
|
||||||
|
end;
|
||||||
|
len:=length(us1);
|
||||||
setlength(hs1,len+1);
|
setlength(hs1,len+1);
|
||||||
for i:=1 to len do
|
for i:=1 to len do
|
||||||
if s1[i]<>#0 then
|
if us1[i]<>#0 then
|
||||||
hs1[i-1]:=s1[i]
|
hs1[i-1]:=us1[i]
|
||||||
else
|
else
|
||||||
hs1[i-1]:=#32;
|
hs1[i-1]:=#32;
|
||||||
hs1[len]:=#0;
|
hs1[len]:=#0;
|
||||||
|
|
||||||
len:=length(s2);
|
len:=length(us2);
|
||||||
setlength(hs2,len+1);
|
setlength(hs2,len+1);
|
||||||
for i:=1 to len do
|
for i:=1 to len do
|
||||||
if s2[i]<>#0 then
|
if us2[i]<>#0 then
|
||||||
hs2[i-1]:=s2[i]
|
hs2[i-1]:=us2[i]
|
||||||
else
|
else
|
||||||
hs2[i-1]:=#32;
|
hs2[i-1]:=#32;
|
||||||
hs2[len]:=#0;
|
hs2[len]:=#0;
|
||||||
@ -804,11 +827,6 @@ function CompareWideString(const s1, s2 : WideString) : PtrInt;
|
|||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
|
|
||||||
function CompareTextWideString(const s1, s2 : WideString): PtrInt;
|
|
||||||
begin
|
|
||||||
result:=CompareWideString(UpperWideString(s1),UpperWideString(s2));
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{ return value: number of code points in the string. Whenever an invalid
|
{ return value: number of code points in the string. Whenever an invalid
|
||||||
code point is encountered, all characters part of this invalid code point
|
code point is encountered, all characters part of this invalid code point
|
||||||
@ -1080,7 +1098,7 @@ begin
|
|||||||
LowerWideStringProc:=@LowerWideString;
|
LowerWideStringProc:=@LowerWideString;
|
||||||
|
|
||||||
CompareWideStringProc:=@CompareWideString;
|
CompareWideStringProc:=@CompareWideString;
|
||||||
CompareTextWideStringProc:=@CompareTextWideString;
|
// CompareTextWideStringProc:=@CompareTextWideString;
|
||||||
|
|
||||||
CharLengthPCharProc:=@CharLengthPChar;
|
CharLengthPCharProc:=@CharLengthPChar;
|
||||||
CodePointLengthProc:=@CodePointLength;
|
CodePointLengthProc:=@CodePointLength;
|
||||||
@ -1103,7 +1121,6 @@ begin
|
|||||||
UpperUnicodeStringProc:=@UpperWideString;
|
UpperUnicodeStringProc:=@UpperWideString;
|
||||||
LowerUnicodeStringProc:=@LowerWideString;
|
LowerUnicodeStringProc:=@LowerWideString;
|
||||||
CompareUnicodeStringProc:=@CompareWideString;
|
CompareUnicodeStringProc:=@CompareWideString;
|
||||||
CompareTextUnicodeStringProc:=@CompareTextWideString;
|
|
||||||
{ CodePage }
|
{ CodePage }
|
||||||
GetStandardCodePageProc:=@GetStandardCodePage;
|
GetStandardCodePageProc:=@GetStandardCodePage;
|
||||||
end;
|
end;
|
||||||
|
|||||||
@ -20,6 +20,8 @@ interface
|
|||||||
{$MODESWITCH OUT}
|
{$MODESWITCH OUT}
|
||||||
{ force ansistrings }
|
{ force ansistrings }
|
||||||
{$H+}
|
{$H+}
|
||||||
|
{$modeswitch typehelpers}
|
||||||
|
{$modeswitch advancedrecords}
|
||||||
|
|
||||||
{$if (defined(BSD) or defined(SUNOS)) and defined(FPC_USE_LIBC)}
|
{$if (defined(BSD) or defined(SUNOS)) and defined(FPC_USE_LIBC)}
|
||||||
{$define USE_VFORK}
|
{$define USE_VFORK}
|
||||||
|
|||||||
@ -23,6 +23,8 @@ interface
|
|||||||
{$modeswitch out}
|
{$modeswitch out}
|
||||||
{ force ansistrings }
|
{ force ansistrings }
|
||||||
{$H+}
|
{$H+}
|
||||||
|
{$modeswitch typehelpers}
|
||||||
|
{$modeswitch advancedrecords}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
watcom,dos;
|
watcom,dos;
|
||||||
|
|||||||
@ -28,6 +28,9 @@ interface
|
|||||||
{$MODESWITCH OUT}
|
{$MODESWITCH OUT}
|
||||||
{ force ansistrings }
|
{ force ansistrings }
|
||||||
{$H+}
|
{$H+}
|
||||||
|
{$modeswitch typehelpers}
|
||||||
|
{$modeswitch advancedrecords}
|
||||||
|
|
||||||
{$DEFINE HAS_SLEEP}
|
{$DEFINE HAS_SLEEP}
|
||||||
{ used OS file system APIs use ansistring }
|
{ used OS file system APIs use ansistring }
|
||||||
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
{$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
|
||||||
|
|||||||
@ -21,6 +21,8 @@ interface
|
|||||||
{$MODESWITCH OUT}
|
{$MODESWITCH OUT}
|
||||||
{ force ansistrings }
|
{ force ansistrings }
|
||||||
{$H+}
|
{$H+}
|
||||||
|
{$modeswitch typehelpers}
|
||||||
|
{$modeswitch advancedrecords}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
windows;
|
windows;
|
||||||
@ -1249,10 +1251,25 @@ function DoCompareStringW(P1, P2: PWideChar; L1, L2: PtrUInt; Flags: DWORD): Ptr
|
|||||||
RaiseLastOSError;
|
RaiseLastOSError;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function Win32CompareWideString(const s1, s2 : WideString) : PtrInt;
|
const
|
||||||
begin
|
WinAPICompareFlags : array [TCompareOption] of LongWord
|
||||||
Result:=DoCompareStringW(PWideChar(s1), PWideChar(s2), Length(s1), Length(s2), 0);
|
= (LINGUISTIC_IGNORECASE, LINGUISTIC_IGNOREDIACRITIC, NORM_IGNORECASE,
|
||||||
end;
|
NORM_IGNOREKANATYPE, NORM_IGNORENONSPACE, NORM_IGNORESYMBOLS, NORM_IGNOREWIDTH,
|
||||||
|
NORM_LINGUISTIC_CASING, SORT_DIGITSASNUMBERS, SORT_STRINGSORT);
|
||||||
|
|
||||||
|
function Win32CompareWideString(const s1, s2 : WideString; Options : TCompareOptions) : PtrInt;
|
||||||
|
|
||||||
|
Var
|
||||||
|
O : LongWord;
|
||||||
|
CO : TCompareOption;
|
||||||
|
|
||||||
|
begin
|
||||||
|
O:=0;
|
||||||
|
for CO in TCompareOption do
|
||||||
|
if CO in Options then
|
||||||
|
O:=O or WinAPICompareFlags[CO];
|
||||||
|
Result:=DoCompareStringW(PWideChar(s1), PWideChar(s2), Length(s1), Length(s2), O);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function Win32CompareTextWideString(const s1, s2 : WideString) : PtrInt;
|
function Win32CompareTextWideString(const s1, s2 : WideString) : PtrInt;
|
||||||
@ -1338,10 +1355,19 @@ function Win32AnsiStrUpper(Str: PChar): PChar;
|
|||||||
result:=str;
|
result:=str;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function Win32CompareUnicodeString(const s1, s2 : UnicodeString) : PtrInt;
|
function Win32CompareUnicodeString(const s1, s2 : UnicodeString; Options : TCompareOptions) : PtrInt;
|
||||||
begin
|
|
||||||
Result:=DoCompareStringW(PWideChar(s1), PWideChar(s2), Length(s1), Length(s2), 0);
|
Var
|
||||||
end;
|
O : LongWord;
|
||||||
|
CO : TCompareOption;
|
||||||
|
|
||||||
|
begin
|
||||||
|
O:=0;
|
||||||
|
for CO in TCompareOption do
|
||||||
|
if CO in Options then
|
||||||
|
O:=O or WinAPICompareFlags[CO];
|
||||||
|
Result:=DoCompareStringW(PWideChar(s1), PWideChar(s2), Length(s1), Length(s2), O);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function Win32CompareTextUnicodeString(const s1, s2 : UnicodeString) : PtrInt;
|
function Win32CompareTextUnicodeString(const s1, s2 : UnicodeString) : PtrInt;
|
||||||
@ -1365,7 +1391,6 @@ procedure InitWin32Widestrings;
|
|||||||
> 0 if that's the length in bytes of the code point }
|
> 0 if that's the length in bytes of the code point }
|
||||||
//!!!! CodePointLengthProc : function(const Str: PChar; MaxLookAead: PtrInt): Ptrint;
|
//!!!! CodePointLengthProc : function(const Str: PChar; MaxLookAead: PtrInt): Ptrint;
|
||||||
widestringmanager.CompareWideStringProc:=@Win32CompareWideString;
|
widestringmanager.CompareWideStringProc:=@Win32CompareWideString;
|
||||||
widestringmanager.CompareTextWideStringProc:=@Win32CompareTextWideString;
|
|
||||||
widestringmanager.UpperAnsiStringProc:=@Win32AnsiUpperCase;
|
widestringmanager.UpperAnsiStringProc:=@Win32AnsiUpperCase;
|
||||||
widestringmanager.LowerAnsiStringProc:=@Win32AnsiLowerCase;
|
widestringmanager.LowerAnsiStringProc:=@Win32AnsiLowerCase;
|
||||||
widestringmanager.CompareStrAnsiStringProc:=@Win32AnsiCompareStr;
|
widestringmanager.CompareStrAnsiStringProc:=@Win32AnsiCompareStr;
|
||||||
@ -1377,7 +1402,6 @@ procedure InitWin32Widestrings;
|
|||||||
widestringmanager.StrLowerAnsiStringProc:=@Win32AnsiStrLower;
|
widestringmanager.StrLowerAnsiStringProc:=@Win32AnsiStrLower;
|
||||||
widestringmanager.StrUpperAnsiStringProc:=@Win32AnsiStrUpper;
|
widestringmanager.StrUpperAnsiStringProc:=@Win32AnsiStrUpper;
|
||||||
widestringmanager.CompareUnicodeStringProc:=@Win32CompareUnicodeString;
|
widestringmanager.CompareUnicodeStringProc:=@Win32CompareUnicodeString;
|
||||||
widestringmanager.CompareTextUnicodeStringProc:=@Win32CompareTextUnicodeString;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Platform-specific exception support }
|
{ Platform-specific exception support }
|
||||||
|
|||||||
@ -332,6 +332,7 @@
|
|||||||
NORM_IGNOREKANATYPE = $00010000;
|
NORM_IGNOREKANATYPE = $00010000;
|
||||||
NORM_IGNOREWIDTH = $00020000;
|
NORM_IGNOREWIDTH = $00020000;
|
||||||
NORM_LINGUISTIC_CASING = $08000000;
|
NORM_LINGUISTIC_CASING = $08000000;
|
||||||
|
SORT_DIGITSASNUMBERS = $00000008;
|
||||||
SORT_STRINGSORT = 4096;
|
SORT_STRINGSORT = 4096;
|
||||||
LCMAP_BYTEREV = 2048;
|
LCMAP_BYTEREV = 2048;
|
||||||
LCMAP_FULLWIDTH = 8388608;
|
LCMAP_FULLWIDTH = 8388608;
|
||||||
|
|||||||
@ -21,6 +21,8 @@ interface
|
|||||||
{$MODESWITCH OUT}
|
{$MODESWITCH OUT}
|
||||||
{ force ansistrings }
|
{ force ansistrings }
|
||||||
{$H+}
|
{$H+}
|
||||||
|
{$modeswitch typehelpers}
|
||||||
|
{$modeswitch advancedrecords}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
dos,
|
dos,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user