1
0
mirror of synced 2024-11-14 11:09:16 +00:00

Added: support for SaveToStream for Base64 encoded types

Fixed: global simple type mappings referenced by non-global elements
This commit is contained in:
Mark van Renswoude 2012-04-13 13:33:23 +00:00
parent 8a5fa4af6d
commit 25bdcc74c5
4 changed files with 49 additions and 4 deletions

View File

@ -1068,6 +1068,8 @@ var
value: String;
propertyItemName: String;
fieldName: String;
writeStream: Boolean;
typeMapping: TTypeMapping;
begin
Result := False;
@ -1084,6 +1086,15 @@ begin
writeOptional := not Assigned(AProperty.Collection) and
AProperty.IsOptional;
writeStream := False;
if (AMember = dxmPropertyGet) and (AProperty.PropertyType = ptSimple) then
begin
if GetDataTypeMapping(TXMLDataBindingSimpleProperty(AProperty).DataType, typeMapping) then
writeStream := (typeMapping.Conversion = tcBase64);
end;
dataTypeName := '';
propertyItem := nil;
@ -1146,6 +1157,9 @@ begin
if writeTextProp then
sourceCode.Add(PropertyIntfMethodGetText);
if writeStream then
sourceCode.Add(PropertyIntfMethodStream);
sourceCode.Add(PropertyIntfMethodGet);
end;
@ -1216,6 +1230,9 @@ begin
else
sourceCode.Add(PropertyImplMethodGetText[GetDelphiElementType(AProperty)]);
if writeStream then
sourceCode.Add(PropertyImplMethodStream[GetDelphiElementType(AProperty)]);
sourceCode.Add('function TXML%<Name>:s.Get%<PropertyName>:s: %<DataType>:s;');
case AProperty.PropertyType of

View File

@ -105,6 +105,7 @@ const
PropertyIntfMethodSetNil = ' procedure Set%<PropertyName>:sIsNil(const Value: Boolean);';
PropertyIntfMethodSetText = ' procedure Set%<PropertyName>:sText(const Value: WideString);';
PropertyIntfMethodSet = ' procedure Set%<PropertyName>:s(const Value: %<DataType>:s);';
PropertyIntfMethodStream = ' procedure Save%<PropertyName>:sToStream(AStream: TStream);';
PropertyInterfaceOptional = ' property Has%<PropertyName>:s: Boolean read GetHas%<PropertyName>:s;';
PropertyInterfaceNilReadOnly = ' property %<PropertyName>:sIsNil: Boolean read Get%<PropertyName>:sIsNil;';
@ -213,10 +214,27 @@ const
PropertyImplMethodSetTextAttr = 'procedure TXML%<Name>:s.Set%<PropertyName>:sText(const Value: WideString);' + CrLf +
'begin' + CrLf +
' AttributeNodes[''%<PropertySourceName>:s''].NodeValue := Value;' + CrLf +
' AttributeNodes[''%<PropertySourceName>:s''].NodeValue := Value;' + CrLf +
'end;' + CrLf +
'' + CrLf;
PropertyImplMethodStream: array[TDelphiElementType] of string =
(
{ dntElement }
'procedure TXML%<Name>:s.Save%<PropertyName>:sToStream(AStream: TStream);' + CrLf +
'begin' + CrLf +
' Base64DecodeToStream(Trim(ChildNodes[''%<PropertySourceName>:s''].Text), AStream);' + CrLf +
'end;' + CrLf +
'' + CrLf,
{ dntElementNS }
'procedure TXML%<Name>:s.Save%<PropertyName>:sToStream(AStream: TStream);' + CrLf +
'begin' + CrLf +
' Base64DecodeToStream(Trim(ChildNodes.FindNode(''%<PropertySourceName>:s'', ''%<Namespace>:s'').Text), AStream);' + CrLf +
'end;' + CrLf +
'' + CrLf
);
SectionComments: array[TDelphiXMLSection] of String =
(

View File

@ -657,7 +657,8 @@ var
schemaDef: IXMLSchemaDef;
simpleTypeIndex: Integer;
simpleType: IXMLSimpleTypeDef;
enumerationObject: TXMLDataBindingEnumeration;
enumerationObject: TXMLDataBindingEnumeration;
baseType: IXMLTypeDef;
begin
schemaDef := ASchema.SchemaDef;
@ -670,6 +671,15 @@ begin
begin
enumerationObject := TXMLDataBindingEnumeration.Create(Self, simpleType, simpleType.Enumerations, simpleType.Name, False);
ASchema.AddItem(enumerationObject);
end else if simpleType.DerivationMethod = sdmRestriction then
begin
baseType := simpleType.BaseType;
while Assigned(baseType.BaseType) do
baseType := baseType.BaseType;
if not baseType.IsComplex then
ASchema.AddItem(TXMLDataBindingSimpleTypeAliasItem.Create(Self, baseType, simpleType.Name));
end;
end;
end;
@ -837,7 +847,7 @@ begin
for attributeIndex := 0 to Pred(AElement.AttributeDefs.Count) do
ProcessAttribute(ASchema, AElement.AttributeDefs[attributeIndex], interfaceObject);
end else if AElement.IsGlobal then
end else {if AElement.IsGlobal then}
begin
{ Non-anonymous non-complex type. Assume somewhere in there is a
built-in type.

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:\test\XMLDataBinding\Tests\Data\01. Basic simple and complex types.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:\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>
</ProjectExtensions>
<Import Project="$(MSBuildBinPath)\Borland.Delphi.Targets" />
<ItemGroup>