Changeset 4 for trunk/UDatabaseXML.pas
- Timestamp:
- Jan 18, 2015, 11:29:26 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UDatabaseXML.pas
r3 r4 37 37 implementation 38 38 39 uses 40 UDataTypes; 41 39 42 resourcestring 40 43 SWrongFileFormat = 'Wrong file format'; … … 52 55 var 53 56 Node2: TDOMNode; 54 NewValue: TValue; 55 I: Integer; 56 begin 57 Row.Values.Count := 0; 57 I: Integer; 58 begin 59 Row.Values.Count := Row.Parent.Fields.Count; 60 for I := 0 to Row.Values.Count - 1 do 61 Row.Values[I] := TValueClass(TField(Row.Parent.Fields[I]).GetValueClass).Create; 62 58 63 Node2 := Node.FirstChild; 59 64 I := 0; 60 while Assigned(Node2) and (Node2.NodeName = 'Value') do begin 61 if TField(Row.Parent.Fields[I]).FieldType = ftString then begin 62 NewValue := TValueString.Create; 63 TValueString(NewValue).Value := Node2.TextContent; 64 end else 65 if TField(Row.Parent.Fields[I]).FieldType = ftDateTime then begin 66 NewValue := TValueDateTime.Create; 67 if Node2.TextContent <> '' then 68 TValueDateTime(NewValue).Value := XMLTimeToDateTime(Node2.TextContent); 69 end else NewValue := TValue.Create; 70 Row.Values.Add(NewValue); 65 while Assigned(Node2) and (Node2.NodeName = 'Value') and (I < Row.Values.Count) do begin 66 case TField(Row.Parent.Fields[I]).FieldType of 67 ftString: TValueString(Row.Values[I]).Value := Node2.TextContent; 68 ftInteger: TValueInteger(Row.Values[I]).Value := StrToInt(Node2.TextContent); 69 ftDateTime: if Node2.TextContent <> '' then 70 TValueDateTime(Row.Values[I]).Value := XMLTimeToDateTime(Node2.TextContent); 71 ftBoolean: TValueBoolean(Row.Values[I]).Value := StrToBool(Node2.TextContent); 72 end; 71 73 Node2 := Node2.NextSibling; 72 74 Inc(I); … … 82 84 NewNode := Node.OwnerDocument.CreateElement('Value'); 83 85 Node.AppendChild(NewNode); 84 if TField(Row.Parent.Fields[I]).FieldType = ftString then 85 NewNode.TextContent := TValueString(Row.Values[I]).Value; 86 if TField(Row.Parent.Fields[I]).FieldType = ftDateTime then 87 NewNode.TextContent := DateTimeToXMLTime(TValueDateTime(Row.Values[I]).Value); 86 case TField(Row.Parent.Fields[I]).FieldType of 87 ftString: NewNode.TextContent := TValueString(Row.Values[I]).Value; 88 ftInteger: NewNode.TextContent := IntToStr(TValueInteger(Row.Values[I]).Value); 89 ftDateTime: NewNode.TextContent := DateTimeToXMLTime(TValueDateTime(Row.Values[I]).Value); 90 ftBoolean: NewNode.TextContent := BoolToStr(TValueBoolean(Row.Values[I]).Value); 91 ftFloat: NewNode.TextContent := FloatToStr(TValueFloat(Row.Values[I]).Value); 92 end; 88 93 end; 89 94 end; … … 165 170 begin 166 171 Table.Name := ReadString(Node, 'Name', ''); 172 Table.Caption := ReadString(Node, 'Caption', ''); 167 173 168 174 NewNode := Node.FindNode('Fields'); … … 180 186 begin 181 187 WriteString(Node, 'Name', Table.Name); 188 WriteString(Node, 'Caption', Table.Caption); 182 189 183 190 NewNode := Node.OwnerDocument.CreateElement('Fields');
Note:
See TracChangeset
for help on using the changeset viewer.