Added: SaveToFile methods for Base64 encoded elements
This commit is contained in:
parent
d429226755
commit
ca8492e5bd
@ -57,6 +57,7 @@ const
|
|||||||
function Base64Encode(AValue: String): String;
|
function Base64Encode(AValue: String): String;
|
||||||
function Base64Decode(AValue: String): String;
|
function Base64Decode(AValue: String): String;
|
||||||
procedure Base64DecodeToStream(AValue: String; AStream: TStream);
|
procedure Base64DecodeToStream(AValue: String; AStream: TStream);
|
||||||
|
procedure Base64DecodeToFile(AValue: String; const AFileName: String);
|
||||||
|
|
||||||
const
|
const
|
||||||
XMLSchemaInstanceURI = 'http://www.w3.org/2001/XMLSchema-instance';
|
XMLSchemaInstanceURI = 'http://www.w3.org/2001/XMLSchema-instance';
|
||||||
@ -340,6 +341,26 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure Base64DecodeToFile(AValue: String; const AFileName: String);
|
||||||
|
var
|
||||||
|
input: TStringStream;
|
||||||
|
output: TFileStream;
|
||||||
|
|
||||||
|
begin
|
||||||
|
input := TStringStream.Create(AValue);
|
||||||
|
try
|
||||||
|
output := TFileStream.Create(AFileName, fmCreate or fmShareDenyWrite);
|
||||||
|
try
|
||||||
|
MimeDecodeStream(input, output);
|
||||||
|
finally
|
||||||
|
FreeAndNil(output);
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
FreeAndNil(input);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function GetNodeIsNil(ANode: IXMLNode): Boolean;
|
function GetNodeIsNil(ANode: IXMLNode): Boolean;
|
||||||
begin
|
begin
|
||||||
Result := ANode.HasAttribute(XMLIsNilAttribute, XMLSchemaInstanceURI) and
|
Result := ANode.HasAttribute(XMLIsNilAttribute, XMLSchemaInstanceURI) and
|
||||||
|
@ -1158,7 +1158,10 @@ begin
|
|||||||
sourceCode.Add(PropertyIntfMethodGetText);
|
sourceCode.Add(PropertyIntfMethodGetText);
|
||||||
|
|
||||||
if writeStream then
|
if writeStream then
|
||||||
|
begin
|
||||||
sourceCode.Add(PropertyIntfMethodStream);
|
sourceCode.Add(PropertyIntfMethodStream);
|
||||||
|
sourceCode.Add(PropertyIntfMethodFile);
|
||||||
|
end;
|
||||||
|
|
||||||
sourceCode.Add(PropertyIntfMethodGet);
|
sourceCode.Add(PropertyIntfMethodGet);
|
||||||
end;
|
end;
|
||||||
@ -1231,7 +1234,10 @@ begin
|
|||||||
sourceCode.Add(PropertyImplMethodGetText[GetDelphiElementType(AProperty)]);
|
sourceCode.Add(PropertyImplMethodGetText[GetDelphiElementType(AProperty)]);
|
||||||
|
|
||||||
if writeStream then
|
if writeStream then
|
||||||
|
begin
|
||||||
sourceCode.Add(PropertyImplMethodStream[GetDelphiElementType(AProperty)]);
|
sourceCode.Add(PropertyImplMethodStream[GetDelphiElementType(AProperty)]);
|
||||||
|
sourceCode.Add(PropertyImplMethodFile[GetDelphiElementType(AProperty)]);
|
||||||
|
end;
|
||||||
|
|
||||||
sourceCode.Add('function TXML%<Name>:s.Get%<PropertyName>:s: %<DataType>:s;');
|
sourceCode.Add('function TXML%<Name>:s.Get%<PropertyName>:s: %<DataType>:s;');
|
||||||
|
|
||||||
|
@ -106,6 +106,7 @@ const
|
|||||||
PropertyIntfMethodSetText = ' procedure Set%<PropertyName>:sText(const Value: WideString);';
|
PropertyIntfMethodSetText = ' procedure Set%<PropertyName>:sText(const Value: WideString);';
|
||||||
PropertyIntfMethodSet = ' procedure Set%<PropertyName>:s(const Value: %<DataType>:s);';
|
PropertyIntfMethodSet = ' procedure Set%<PropertyName>:s(const Value: %<DataType>:s);';
|
||||||
PropertyIntfMethodStream = ' procedure Save%<PropertyName>:sToStream(AStream: TStream);';
|
PropertyIntfMethodStream = ' procedure Save%<PropertyName>:sToStream(AStream: TStream);';
|
||||||
|
PropertyIntfMethodFile = ' procedure Save%<PropertyName>:sToFile(const AFileName: string);';
|
||||||
|
|
||||||
PropertyInterfaceOptional = ' property Has%<PropertyName>:s: Boolean read GetHas%<PropertyName>:s;';
|
PropertyInterfaceOptional = ' property Has%<PropertyName>:s: Boolean read GetHas%<PropertyName>:s;';
|
||||||
PropertyInterfaceNilReadOnly = ' property %<PropertyName>:sIsNil: Boolean read Get%<PropertyName>:sIsNil;';
|
PropertyInterfaceNilReadOnly = ' property %<PropertyName>:sIsNil: Boolean read Get%<PropertyName>:sIsNil;';
|
||||||
@ -235,6 +236,22 @@ const
|
|||||||
'' + CrLf
|
'' + CrLf
|
||||||
);
|
);
|
||||||
|
|
||||||
|
PropertyImplMethodFile: array[TDelphiElementType] of string =
|
||||||
|
(
|
||||||
|
{ dntElement }
|
||||||
|
'procedure TXML%<Name>:s.Save%<PropertyName>:sToFile(const AFileName: string);' + CrLf +
|
||||||
|
'begin' + CrLf +
|
||||||
|
' Base64DecodeToFile(Trim(ChildNodes[''%<PropertySourceName>:s''].Text), AFileName);' + CrLf +
|
||||||
|
'end;' + CrLf +
|
||||||
|
'' + CrLf,
|
||||||
|
|
||||||
|
{ dntElementNS }
|
||||||
|
'procedure TXML%<Name>:s.Save%<PropertyName>:sToFile(const AFileName: string);' + CrLf +
|
||||||
|
'begin' + CrLf +
|
||||||
|
' Base64DecodeToFile(Trim(ChildNodes.FindNode(''%<PropertySourceName>:s'', ''%<Namespace>:s'').Text), AFileName);' + CrLf +
|
||||||
|
'end;' + CrLf +
|
||||||
|
'' + CrLf
|
||||||
|
);
|
||||||
|
|
||||||
SectionComments: array[TDelphiXMLSection] of String =
|
SectionComments: array[TDelphiXMLSection] of String =
|
||||||
(
|
(
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
<Borland.Personality>Delphi.Personality</Borland.Personality>
|
<Borland.Personality>Delphi.Personality</Borland.Personality>
|
||||||
<Borland.ProjectType />
|
<Borland.ProjectType />
|
||||||
<BorlandProject>
|
<BorlandProject>
|
||||||
<BorlandProject><Delphi.Personality><Parameters><Parameters Name="UseLauncher">False</Parameters><Parameters Name="LoadAllSymbols">True</Parameters><Parameters Name="LoadUnspecifiedSymbols">False</Parameters><Parameters Name="RunParams">P:\hyundai\DealerAccessoryMsg_v0101.xsd</Parameters></Parameters><VersionInfo><VersionInfo Name="IncludeVerInfo">False</VersionInfo><VersionInfo Name="AutoIncBuild">False</VersionInfo><VersionInfo Name="MajorVer">1</VersionInfo><VersionInfo Name="MinorVer">0</VersionInfo><VersionInfo Name="Release">0</VersionInfo><VersionInfo Name="Build">0</VersionInfo><VersionInfo Name="Debug">False</VersionInfo><VersionInfo Name="PreRelease">False</VersionInfo><VersionInfo Name="Special">False</VersionInfo><VersionInfo Name="Private">False</VersionInfo><VersionInfo Name="DLL">False</VersionInfo><VersionInfo Name="Locale">1043</VersionInfo><VersionInfo Name="CodePage">1252</VersionInfo></VersionInfo><VersionInfoKeys><VersionInfoKeys Name="CompanyName"></VersionInfoKeys><VersionInfoKeys Name="FileDescription"></VersionInfoKeys><VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name="InternalName"></VersionInfoKeys><VersionInfoKeys Name="LegalCopyright"></VersionInfoKeys><VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys><VersionInfoKeys Name="OriginalFilename"></VersionInfoKeys><VersionInfoKeys Name="ProductName"></VersionInfoKeys><VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name="Comments"></VersionInfoKeys></VersionInfoKeys><Source><Source Name="MainSource">X2XMLDataBinding.dpr</Source></Source></Delphi.Personality></BorlandProject></BorlandProject>
|
<BorlandProject><Delphi.Personality><Parameters><Parameters Name="UseLauncher">False</Parameters><Parameters Name="LoadAllSymbols">True</Parameters><Parameters Name="LoadUnspecifiedSymbols">False</Parameters><Parameters Name="RunParams">"P:\updateserver\xsd\DealerCarTrimMsg_v0101.xsd"</Parameters></Parameters><VersionInfo><VersionInfo Name="IncludeVerInfo">False</VersionInfo><VersionInfo Name="AutoIncBuild">False</VersionInfo><VersionInfo Name="MajorVer">1</VersionInfo><VersionInfo Name="MinorVer">0</VersionInfo><VersionInfo Name="Release">0</VersionInfo><VersionInfo Name="Build">0</VersionInfo><VersionInfo Name="Debug">False</VersionInfo><VersionInfo Name="PreRelease">False</VersionInfo><VersionInfo Name="Special">False</VersionInfo><VersionInfo Name="Private">False</VersionInfo><VersionInfo Name="DLL">False</VersionInfo><VersionInfo Name="Locale">1043</VersionInfo><VersionInfo Name="CodePage">1252</VersionInfo></VersionInfo><VersionInfoKeys><VersionInfoKeys Name="CompanyName"></VersionInfoKeys><VersionInfoKeys Name="FileDescription"></VersionInfoKeys><VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name="InternalName"></VersionInfoKeys><VersionInfoKeys Name="LegalCopyright"></VersionInfoKeys><VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys><VersionInfoKeys Name="OriginalFilename"></VersionInfoKeys><VersionInfoKeys Name="ProductName"></VersionInfoKeys><VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name="Comments"></VersionInfoKeys></VersionInfoKeys><Source><Source Name="MainSource">X2XMLDataBinding.dpr</Source></Source></Delphi.Personality></BorlandProject></BorlandProject>
|
||||||
</ProjectExtensions>
|
</ProjectExtensions>
|
||||||
<Import Project="$(MSBuildBinPath)\Borland.Delphi.Targets" />
|
<Import Project="$(MSBuildBinPath)\Borland.Delphi.Targets" />
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user