Changeset 26 for trunk/UXmlClasses.pas
- Timestamp:
- Sep 10, 2022, 8:03:08 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 7 7 heaptrclog.trc 8 8 MyData.exe 9 MyData.dbg 10
-
- Property svn:ignore
-
trunk/UXmlClasses.pas
r19 r26 1 1 unit UXmlClasses; 2 3 {$mode delphi}{$H+}4 2 5 3 interface 6 4 7 uses Classes, SysUtils, StrUtils, SpecializedList,8 SpecializedDictionary;5 uses 6 Classes, SysUtils, StrUtils, Generics.Collections, UGenerics; 9 7 10 8 type … … 14 12 public 15 13 property AsString: string read GetAsString; 14 end; 15 16 TXmlTag = class; 17 TXmlString = class; 18 19 { TXmlElements } 20 21 TXmlElements = class(TObjectList<TXmlElement>) 22 function AddTag(Name: string): TXmlTag; 23 function AddString(Text: string): TXmlString; 16 24 end; 17 25 … … 31 39 Name: string; 32 40 Attributes: TDictionaryStringString; 33 SubElements: T ListObject; // TListObject<TXmlElement>;41 SubElements: TXmlElements; 34 42 constructor Create; 35 43 destructor Destroy; override; … … 51 59 end; 52 60 61 53 62 implementation 63 64 { TXmlElements } 65 66 function TXmlElements.AddTag(Name: string): TXmlTag; 67 begin 68 Result := TXmlTag.Create; 69 Result.Name := Name; 70 Add(Result); 71 end; 72 73 function TXmlElements.AddString(Text: string): TXmlString; 74 begin 75 Result := TXmlString.Create; 76 Result.Text := Text; 77 Add(Result); 78 end; 54 79 55 80 { THtmlElement } … … 59 84 ShringEmpty := True; 60 85 Attributes := TDictionaryStringString.Create; 61 SubElements := T ListObject.Create;86 SubElements := TXmlElements.Create; 62 87 EndTagSymbol := '/'; 63 88 end; … … 65 90 destructor TXmlTag.Destroy; 66 91 begin 67 Attributes.Free;68 SubElements.Free;92 FreeAndNil(Attributes); 93 FreeAndNil(SubElements); 69 94 inherited; 70 95 end; … … 75 100 I: Integer; 76 101 Content: string; 102 Attribute: TPair<string, string>; 77 103 begin 78 104 Content := ''; … … 81 107 82 108 AttributesText := ''; 83 for I := 0 to Attributes.Count - 1do84 AttributesText := AttributesText + ' ' + Attribute s.Keys[I] + '="' + Attributes[I].Value + '"';109 for Attribute in Attributes do 110 AttributesText := AttributesText + ' ' + Attribute.Key + '="' + Attribute.Value + '"'; 85 111 86 112 if Name <> '' then begin … … 124 150 destructor TXmlDocument.Destroy; 125 151 begin 126 Content.Free;127 MainTag.Free;152 FreeAndNil(Content); 153 FreeAndNil(MainTag); 128 154 inherited; 129 155 end;
Note:
See TracChangeset
for help on using the changeset viewer.