1
0
mirror of synced 2024-12-22 17:23:07 +01:00

Delphi XE2 compatibility

This commit is contained in:
Mark van Renswoude 2013-12-05 10:49:28 +00:00
parent 195c3e6dde
commit 0d07b45cd4
7 changed files with 128 additions and 7 deletions

View File

@ -58,6 +58,7 @@ contains
X2UtElevation in '..\..\X2UtElevation.pas', X2UtElevation in '..\..\X2UtElevation.pas',
X2UtPersistXML in '..\..\X2UtPersistXML.pas', X2UtPersistXML in '..\..\X2UtPersistXML.pas',
X2UtPersistXMLBinding in '..\..\X2UtPersistXMLBinding.pas', X2UtPersistXMLBinding in '..\..\X2UtPersistXMLBinding.pas',
XMLDataBindingUtils in '..\..\XMLDataBindingUtils.pas'; XMLDataBindingUtils in '..\..\XMLDataBindingUtils.pas',
X2UtDelphiCompatibility in '..\..\X2UtDelphiCompatibility.pas';
end. end.

View File

@ -173,6 +173,7 @@
<DCCReference Include="..\..\X2UtPersistXML.pas"/> <DCCReference Include="..\..\X2UtPersistXML.pas"/>
<DCCReference Include="..\..\X2UtPersistXMLBinding.pas"/> <DCCReference Include="..\..\X2UtPersistXMLBinding.pas"/>
<DCCReference Include="..\..\XMLDataBindingUtils.pas"/> <DCCReference Include="..\..\XMLDataBindingUtils.pas"/>
<DCCReference Include="..\..\X2UtDelphiCompatibility.pas"/>
<BuildConfiguration Include="Debug"> <BuildConfiguration Include="Debug">
<Key>Cfg_2</Key> <Key>Cfg_2</Key>
<CfgParent>Base</CfgParent> <CfgParent>Base</CfgParent>

View File

@ -1,6 +1,11 @@
// This makes it easier to check which compiler version is // This makes it easier to check which compiler version is
// being used... // being used...
{$DEFINE DUNKNOWN} {$DEFINE DUNKNOWN}
{$UNDEF DXE2}
{$UNDEF DXE}
{$UNDEF D2010}
{$UNDEF D2009}
{$UNDEF D2007}
{$UNDEF D2006} {$UNDEF D2006}
{$UNDEF D2005} {$UNDEF D2005}
{$UNDEF D8} {$UNDEF D8}
@ -12,7 +17,83 @@
{$UNDEF D2} {$UNDEF D2}
{$UNDEF D1} {$UNDEF D1}
{$IFDEF VER230}
{$DEFINE DXE2}
{$DEFINE DXE2PLUS}
{$DEFINE DXEPLUS}
{$DEFINE D2010PLUS}
{$DEFINE D2009PLUS}
{$DEFINE D2007PLUS}
{$DEFINE D2006PLUS}
{$DEFINE D2005PLUS}
{$DEFINE D8PLUS}
{$DEFINE D7PLUS}
{$DEFINE D6PLUS}
{$DEFINE D5PLUS}
{$DEFINE D4PLUS}
{$DEFINE D3PLUS}
{$DEFINE D2PLUS}
{$DEFINE D1PLUS}
{$UNDEF DUNKNOWN}
{$ENDIF}
{$IFDEF VER220}
{$DEFINE DXE}
{$DEFINE DXEPLUS}
{$DEFINE D2010PLUS}
{$DEFINE D2009PLUS}
{$DEFINE D2007PLUS}
{$DEFINE D2006PLUS}
{$DEFINE D2005PLUS}
{$DEFINE D8PLUS}
{$DEFINE D7PLUS}
{$DEFINE D6PLUS}
{$DEFINE D5PLUS}
{$DEFINE D4PLUS}
{$DEFINE D3PLUS}
{$DEFINE D2PLUS}
{$DEFINE D1PLUS}
{$UNDEF DUNKNOWN}
{$ENDIF}
{$IFDEF VER210}
{$DEFINE D2010}
{$DEFINE D2010PLUS}
{$DEFINE D2009PLUS}
{$DEFINE D2007PLUS}
{$DEFINE D2006PLUS}
{$DEFINE D2005PLUS}
{$DEFINE D8PLUS}
{$DEFINE D7PLUS}
{$DEFINE D6PLUS}
{$DEFINE D5PLUS}
{$DEFINE D4PLUS}
{$DEFINE D3PLUS}
{$DEFINE D2PLUS}
{$DEFINE D1PLUS}
{$UNDEF DUNKNOWN}
{$ENDIF}
{$IFDEF VER200}
{$DEFINE D2009}
{$DEFINE D2009PLUS}
{$DEFINE D2007PLUS}
{$DEFINE D2006PLUS}
{$DEFINE D2005PLUS}
{$DEFINE D8PLUS}
{$DEFINE D7PLUS}
{$DEFINE D6PLUS}
{$DEFINE D5PLUS}
{$DEFINE D4PLUS}
{$DEFINE D3PLUS}
{$DEFINE D2PLUS}
{$DEFINE D1PLUS}
{$UNDEF DUNKNOWN}
{$ENDIF}
{$IFDEF VER180} {$IFDEF VER180}
{$DEFINE D2007}
{$DEFINE D2007PLUS}
{$DEFINE D2006} {$DEFINE D2006}
{$DEFINE D2006PLUS} {$DEFINE D2006PLUS}
{$DEFINE D2005PLUS} {$DEFINE D2005PLUS}

View File

@ -0,0 +1,34 @@
unit X2UtDelphiCompatibility;
interface
uses
SysUtils;
function CharInSet(C: Char; const CharSet: TSysCharSet): Boolean;
function GetDefaultFormatSettings: TFormatSettings;
implementation
function CharInSet(C: Char; const CharSet: TSysCharSet): Boolean;
begin
{$IF CompilerVersion < 20}
Result := C in CharSet;
{$ELSE}
Result := SysUtils.CharInSet(C, CharSet);
{$IFEND}
end;
function GetDefaultFormatSettings: TFormatSettings;
begin
{$IF CompilerVersion < 20}
GetLocaleFormatSettings(LOCALE_SYSTEM_DEFAULT, Result);
{$ELSE}
Result := TFormatSettings.Create;
{$IFEND}
end;
end.

View File

@ -89,7 +89,7 @@ begin
break; break;
end; end;
if not (position^ in ValidNameChars) then if not CharInSet(position^, ValidNameChars) then
break; break;
Inc(position); Inc(position);

View File

@ -198,7 +198,9 @@ type
implementation implementation
uses uses
Windows; Windows,
X2UtDelphiCompatibility;
const const
@ -628,7 +630,7 @@ begin
for iParam := 1 to ParamCountEx(ACmdLine) do begin for iParam := 1 to ParamCountEx(ACmdLine) do begin
sParam := ParamStrEx(ACmdLine, iParam); sParam := ParamStrEx(ACmdLine, iParam);
if (AChars = []) or (sParam[1] in AChars) then if (AChars = []) or CharInSet(sParam[1], AChars) then
if AIgnoreCase then begin if AIgnoreCase then begin
if (AnsiCompareText(Copy(sParam, 2, Maxint), ASwitch) = 0) then begin if (AnsiCompareText(Copy(sParam, 2, Maxint), ASwitch) = 0) then begin
Result := True; Result := True;

View File

@ -91,7 +91,9 @@ uses
DateUtils, DateUtils,
Math, Math,
Types, Types,
Windows; Windows,
X2UtDelphiCompatibility;
type type
@ -110,7 +112,7 @@ var
timeOffset: Integer; timeOffset: Integer;
begin begin
GetLocaleFormatSettings(LOCALE_SYSTEM_DEFAULT, formatSettings); formatSettings := GetDefaultFormatSettings;
Result := FormatDateTime(XMLDateTimeFormats[AFormat], ADate, formatSettings); Result := FormatDateTime(XMLDateTimeFormats[AFormat], ADate, formatSettings);
if AFormat in [xdtDateTime, xdtTime] then if AFormat in [xdtDateTime, xdtTime] then
@ -237,7 +239,7 @@ begin
begin begin
{ Zulu time } { Zulu time }
hasTimezone := True; hasTimezone := True;
end else if time[1] in [XMLTimezoneSigns[False], XMLTimezoneSigns[True]] then end else if CharInSet(time[1], [XMLTimezoneSigns[False], XMLTimezoneSigns[True]]) then
begin begin
{ Parse timezone ([+|-]xx:xx) } { Parse timezone ([+|-]xx:xx) }
if TryStrToInt(Copy(time, 2, 2), hour) and if TryStrToInt(Copy(time, 2, 2), hour) and