Einzelnen Beitrag anzeigen

Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.017 Beiträge
 
Delphi 12 Athens
 
#9

Re: himXML (gesprochen himixML)

  Alt 1. Apr 2009, 14:10
hab mal schnell ein Serialize angefangen und joar ... werd' es wohl drinlassen und später weitermachen
Delphi-Quellcode:
Procedure TXMLNode.Serialize(C: TObject; SortProps: Boolean = False);
  Var i, i2, i3, i4: Integer;
    F: Extended;
    List: PPropList;
    Node: TXMLNode;

  Begin
    i2 := GetPropList(C.ClassInfo, List);
    If i2 > 0 Then
      Try
        If SortProps Then SortPropList(List, i2);
        For i := 0 to i2 - 1 do
          Case List[i].PropType^.Kind of
            tkUnknown: ;
            tkInteger: Begin
              Node := AddNode(List[i].Name);
              i3 := GetOrdProp(C, List[i].Name);
              If List[i].PropType^.Name = 'TColorThen Begin
                i4 := 0;
                While i4 <= High(XMLColorStrings) do
                  If i3 = XMLColorStrings[i3].Value Then Begin
                    Node.Data := XMLColorStrings[i3].Name;
                    Break;
                  End;
                If i4 > High(XMLColorStrings) Then Continue;
              End;
              Node.Data := IntToStr(i3);
            End;
            tkInt64: AddNode(List[i].Name).Data := IntToStr(GetInt64Prop(C, List[i].Name));
            tkEnumeration: AddNode(List[i].Name).Data := GetEnumProp(C, List[i].Name);
            tkSet: AddNode(List[i].Name).Data := GetSetProp(C, List[i].Name, True);
            tkFloat: Begin
              Node := AddNode(List[i].Name);
              F := GetFloatProp(C, List[i].Name);
              If List[i].PropType^.Name = 'TDateTime'  Then Node.Data := DateToStr(F)
              Else If List[i].PropType^.Name = 'TDateThen Node.Data := TimeToStr(F)
              Else If List[i].PropType^.Name = 'TTimeThen Node.Data := DateTimeToStr(F)
              Else Node.Data := FloatToStr(F);
            End;
            tkChar, tkWChar: Begin
              Node := AddNode(List[i].Name);
              i3 := Word(GetOrdProp(C, List[i].Name));
              If (i3 > $32) and (i3 < $128) Then Node.Data := WideChar(i3)
              Else Node.Data := '#' + IntToStr(GetOrdProp(C, List[i].Name));
            End;
            tkLString {$IFNDEF UNICODE}, tkString{$ENDIF}:
              AddNode(List[i].Name).Data := GetAnsiStrProp(C, List[i].Name);
            tkWString: AddNode(List[i].Name).Data := GetWideStrProp(C, List[i].Name);
            tkUString {$IFDEF UNICODE}, tkString{$ENDIF}:
              AddNode(List[i].Name).Data := GetUnicodeStrProp(C, List[i].Name);
            //tkClass: ;
            //tkMethod: ;
            //tkVariant: ;
            //tkRecord: ;
            //tkInterface: ;
            //tkArray: ;
            //tkDynArray: ;
            Else Raise EXMLException.Create('invalid PropType');
          End;
      Finally
        FreeMem(List);
      End;
  End;
- tkVariant wird noch gemacht
- zu tkRecord, tkArray und tkDynArray muß ich noch sehn ob/wie
- bei tkClass wird mindestens noch TStringList bearbeitet
- ...
- ... nja und mal sehn was sich noch machen läßt
- nja und was nicht geht/gemacht wurde, könntest du dann über Callback-Prozedur nachrüsten.
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests
  Mit Zitat antworten Zitat