1
0
mirror of synced 2024-12-22 01:03: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',
X2UtPersistXML in '..\..\X2UtPersistXML.pas',
X2UtPersistXMLBinding in '..\..\X2UtPersistXMLBinding.pas',
XMLDataBindingUtils in '..\..\XMLDataBindingUtils.pas';
XMLDataBindingUtils in '..\..\XMLDataBindingUtils.pas',
X2UtDelphiCompatibility in '..\..\X2UtDelphiCompatibility.pas';
end.

View File

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

View File

@ -1,6 +1,11 @@
// This makes it easier to check which compiler version is
// being used...
{$DEFINE DUNKNOWN}
{$UNDEF DXE2}
{$UNDEF DXE}
{$UNDEF D2010}
{$UNDEF D2009}
{$UNDEF D2007}
{$UNDEF D2006}
{$UNDEF D2005}
{$UNDEF D8}
@ -12,7 +17,83 @@
{$UNDEF D2}
{$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}
{$DEFINE D2007}
{$DEFINE D2007PLUS}
{$DEFINE D2006}
{$DEFINE D2006PLUS}
{$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;
end;
if not (position^ in ValidNameChars) then
if not CharInSet(position^, ValidNameChars) then
break;
Inc(position);

View File

@ -198,7 +198,9 @@ type
implementation
uses
Windows;
Windows,
X2UtDelphiCompatibility;
const
@ -628,7 +630,7 @@ begin
for iParam := 1 to ParamCountEx(ACmdLine) do begin
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 (AnsiCompareText(Copy(sParam, 2, Maxint), ASwitch) = 0) then begin
Result := True;

View File

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