ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/branches/udr/client/IBUtils.pas
(Generate patch)

Comparing:
ibx/branches/udr/IBUtils.pas (file contents), Revision 370 by tony, Wed Jan 5 14:59:15 2022 UTC vs.
ibx/branches/udr/client/IBUtils.pas (file contents), Revision 371 by tony, Wed Jan 5 15:21:22 2022 UTC

# Line 726 | Line 726 | type
726   TJnlEntry = record
727     JnlEntryType: TJnlEntryType;
728     Timestamp: TDateTime;
729 <   SessionID: integer;
730 <   TransactionID: integer;
731 <   OldTransactionID: integer;
729 >   AttachmentID: cardinal;
730 >   SessionID: cardinal;
731 >   TransactionID: cardinal;
732 >   OldTransactionID: cardinal;
733     TransactionName: AnsiString;
734     TPB: ITPB;
735     DefaultCompletion: TTransactionCompletion;
# Line 741 | Line 742 | type
742  
743     TJournalProcessor = class(TSQLTokeniser)
744      private
745 <      type TLineState = (lsInit, lsJnlFound, lsGotTimestamp, lsGotJnlType,  lsGotSessionID,
745 >      type TLineState = (lsInit, lsJnlFound, lsGotTimestamp, lsGotJnlType,
746 >                          lsGotAttachmentID, lsGotSessionID,
747                            lsGotTransactionID,  lsGotOldTransactionID, lsGotText1Length,
748                            lsGotText1, lsGotText2Length, lsGotText2);
749      private
# Line 793 | Line 795 | function FBFormatDateTime(fmt: AnsiStrin
795   function FormatTimeZoneOffset(EffectiveTimeOffsetMins: integer): AnsiString;
796   function DecodeTimeZoneOffset(TZOffset: AnsiString; var dstOffset: integer): boolean;
797   function StripLeadingZeros(Value: AnsiString): AnsiString;
796 function TryStrToNumeric(S: Ansistring; out Value: int64; out scale: integer): boolean;
797 function NumericToDouble(aValue: Int64; aScale: integer): double;
798   function StringToHex(octetString: string; MaxLineLength: integer=0): string; overload;
799   procedure StringToHex(octetString: string; TextOut: TStrings; MaxLineLength: integer=0); overload;
800  
# Line 2015 | Line 2015 | begin
2015      end;
2016   end;
2017  
2018 function TryStrToNumeric(S: Ansistring; out Value: int64; out scale: integer): boolean;
2019 var i: integer;
2020    ds: integer;
2021    exponent: integer;
2022 begin
2023  Result := false;
2024  ds := 0;
2025  exponent := 0;
2026  S := Trim(S);
2027  Value := 0;
2028  scale := 0;
2029  if Length(S) = 0 then
2030    Exit;
2031  {$IF declared(DefaultFormatSettings)}
2032  with DefaultFormatSettings do
2033  {$ELSE}
2034  {$IF declared(FormatSettings)}
2035  with FormatSettings do
2036  {$IFEND}
2037  {$IFEND}
2038  begin
2039    for i := length(S) downto 1 do
2040    begin
2041      if S[i] = AnsiChar(DecimalSeparator) then
2042      begin
2043          if ds <> 0 then Exit; {only one allowed}
2044          ds := i;
2045          dec(exponent);
2046          system.Delete(S,i,1);
2047      end
2048      else
2049      if S[i] in ['+','-'] then
2050      begin
2051       if (i > 1) and not (S[i-1] in ['e','E']) then
2052          Exit; {malformed}
2053      end
2054      else
2055      if S[i] in ['e','E'] then {scientific notation}
2056      begin
2057        if ds <> 0 then Exit; {not permitted in exponent}
2058        if exponent <> 0 then Exit; {only one allowed}
2059        exponent := i;
2060      end
2061      else
2062      if not (S[i] in ['0'..'9']) then
2063      {Note: ThousandSeparator not allowed by Delphi specs}
2064          Exit; {bad character}
2065    end;
2066
2067    if exponent > 0 then
2068    begin
2069      Result := TryStrToInt(system.copy(S,exponent+1,maxint),Scale);
2070      if Result then
2071      begin
2072        {adjust scale for decimal point}
2073        if ds <> 0 then
2074          Scale := Scale - (exponent - ds);
2075        Result := TryStrToInt64(system.copy(S,1,exponent-1),Value);
2076      end;
2077    end
2078    else
2079    begin
2080      if ds <> 0 then
2081        scale := ds - Length(S) - 1;
2082      Result := TryStrToInt64(S,Value);
2083    end;
2084  end;
2085 end;
2086
2087 function NumericToDouble(aValue: Int64; aScale: integer): double;
2088 begin
2089  Result := aValue * IntPower(10,aScale)
2090 end;
2091
2092
2018   function StringToHex(octetString: string; MaxLineLength: integer): string; overload;
2019  
2020    function ToHex(aValue: byte): string;
# Line 2870 | Line 2795 | begin
2795      end;
2796  
2797     sqltComma:
2798 <     if not (LineState in [lsGotTimestamp,lsGotSessionID,lsGotTransactionID,lsGotText1,lsGotText2]) then
2798 >     if not (LineState in [lsGotTimestamp,lsGotAttachmentID,lsGotSessionID,lsGotTransactionID,lsGotText1,lsGotText2]) then
2799         LineState := lsInit;
2800  
2801     sqltNumberString:
2802       case LineState of
2803       lsGotTimestamp:
2804         begin
2805 +         AttachmentID := StrToInt(TokenText);
2806 +         LineState := lsGotAttachmentID;
2807 +       end;
2808 +
2809 +     lsGotAttachmentID:
2810 +       begin
2811           SessionID := StrToInt(TokenText);
2812           LineState := lsGotSessionID;
2813         end;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines