Einzelnen Beitrag anzeigen

Benutzerbild von himitsu
himitsu
Online

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

Re: himXML (gesprochen himix ML)

  Alt 6. Okt 2009, 14:14
Ups, kennst du das Problem, wenn man 'ne Indexzählung umstellt und sich dann verzählt?
Das Ergebnis war, daß die TDateTime-Werte nimmer von ihrer XML-Darstellung in ein passendes Format umgewandelt wurden
Delphi-Quellcode:
// diese Funktionen in der himXML.pas einfach ändern
    Class Function TXHelper.isXMLDateTime(Const S: TWideString): Boolean;
      Var P, i, i2, i3: Integer;
        D: TDateTime;

      Begin
        P := 0;
        If (Length(S) >= P + 10) and (S[P + 5] = '-') and (S[P + 8] = '-')
            and TryStrToInt(Copy(S, P + 1, 4), i) and TryStrToInt(Copy(S, P + 6, 2), i2)
            and TryStrToInt(Copy(S, P + 9, 2), i3) and TryEncodeDate(i, i2, i3, D) Then
          Inc(P, 10);
        If (Length(S) >= P + 9) and (S[P + 1] = 'T') and (((S[P + 4] = '-') and (S[P + 7] = '-'))
            or ((S[P + 4] = ':') and (S[P + 7] = ':')))
            and TryStrToInt(Copy(S, P + 2, 2), i) and TryStrToInt(Copy(S, P + 5, 2), i2)
            and TryStrToInt(Copy(S, P + 8, 2), i3) and TryEncodeTime(i, i2, i3, 0, D) Then
          Inc(P, 9);
        If (Length(S) >= P + 4) and (S[P + 1] = '.') and TryStrToInt(Copy(S, P + 2, 3), i) Then
          Inc(P, 4);
        If (Length(S) >= P + 1) and (S[P + 1] = 'Z') Then
          Inc(P);
        Result := Length(S) = P;
      End;

    Class Function TXHelper.XMLToDateTime(Const S: TWideString): TDateTime;
      Var P, i, i2, i3: Integer;
        D: TDateTime;

      Begin
        Result := 0;
        P := 0;
        If (Length(S) >= P + 10) and (S[P + 5] = '-') and (S[P + 8] = '-')
            and TryStrToInt(Copy(S, P + 1, 4), i) and TryStrToInt(Copy(S, P + 6, 2), i2)
            and TryStrToInt(Copy(S, P + 9, 2), i3) and TryEncodeDate(i, i2, i3, D) Then Begin
          Inc(P, 10);
          Result := D;
        End;
        If (Length(S) >= P + 9) and (S[P + 1] = 'T') and (((S[P + 4] = '-') and (S[P + 7] = '-'))
            or ((S[P + 4] = ':') and (S[P + 7] = ':')))
            and TryStrToInt(Copy(S, P + 2, 2), i) and TryStrToInt(Copy(S, P + 5, 2), i2)
            and TryStrToInt(Copy(S, P + 8, 2), i3) and TryEncodeTime(i, i2, i3, 0, D) Then Begin
          Inc(P, 9);
          Result := Result + D;
        End;
        If (Length(S) >= P + 4) and (S[P + 1] = '.') and TryStrToInt(Copy(S, P + 2, 3), i) Then Begin
          Inc(P, 4);
          Result := Result + (i / (24*60*60*1000));
        End;
        If (Length(S) >= P + 1) and (S[P + 1] = 'Z') Then
          Inc(P);
        If Length(S) <> P Then
          Raise EXMLException.Create(Self, 'XMLToDateTime', @SCorupptedDateTime, Copy(S, P + 1, 20));
      End;



Was das Andere betrifft ... das ist erstmal ein Fehler im FileStream, welcher meckert, daß da eine Datei nicht geöffnet werden konnte.
Problem dabei ist, daß die TWideFileStream-Klasse nur eine "Kopie" von TFileStream ist und ich da bis auf das Unicode nichts geändert hab ... erstmal möchte ich an diesem Stream natürlich nichts ändern und es würde auch nichts bringen, wenn ich da versuche etwas zu ändern.

Aber so wie es aussieht, ist diese Datei wohl schon geöffnet und ja ... keine Ahnung was Windows da genau will.
[google]"Der Vorgang ist bei einer Datei mit einem geöffneten Bereich, der einem Benutzer zugeordnet ist, nicht anwendbar"[/google]
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests
  Mit Zitat antworten Zitat