1
0
mirror of synced 2024-12-22 09:03:08 +01:00

Added: SaveToFile methods for Base64 encoded elements

This commit is contained in:
Mark van Renswoude 2012-04-18 14:13:41 +00:00
parent d429226755
commit ca8492e5bd
4 changed files with 45 additions and 1 deletions

View File

@ -57,6 +57,7 @@ const
function Base64Encode(AValue: String): String;
function Base64Decode(AValue: String): String;
procedure Base64DecodeToStream(AValue: String; AStream: TStream);
procedure Base64DecodeToFile(AValue: String; const AFileName: String);
const
XMLSchemaInstanceURI = 'http://www.w3.org/2001/XMLSchema-instance';
@ -340,6 +341,26 @@ begin
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;
begin
Result := ANode.HasAttribute(XMLIsNilAttribute, XMLSchemaInstanceURI) and

View File

@ -1158,7 +1158,10 @@ begin
sourceCode.Add(PropertyIntfMethodGetText);
if writeStream then
begin
sourceCode.Add(PropertyIntfMethodStream);
sourceCode.Add(PropertyIntfMethodFile);
end;
sourceCode.Add(PropertyIntfMethodGet);
end;
@ -1231,7 +1234,10 @@ begin
sourceCode.Add(PropertyImplMethodGetText[GetDelphiElementType(AProperty)]);
if writeStream then
begin
sourceCode.Add(PropertyImplMethodStream[GetDelphiElementType(AProperty)]);
sourceCode.Add(PropertyImplMethodFile[GetDelphiElementType(AProperty)]);
end;
sourceCode.Add('function TXML%<Name>:s.Get%<PropertyName>:s: %<DataType>:s;');

View File

@ -106,6 +106,7 @@ const
PropertyIntfMethodSetText = ' procedure Set%<PropertyName>:sText(const Value: WideString);';
PropertyIntfMethodSet = ' procedure Set%<PropertyName>:s(const Value: %<DataType>:s);';
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;';
PropertyInterfaceNilReadOnly = ' property %<PropertyName>:sIsNil: Boolean read Get%<PropertyName>:sIsNil;';
@ -235,6 +236,22 @@ const
'' + 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 =
(

View File

@ -24,7 +24,7 @@
<Borland.Personality>Delphi.Personality</Borland.Personality>
<Borland.ProjectType />
<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>
<Import Project="$(MSBuildBinPath)\Borland.Delphi.Targets" />
<ItemGroup>