亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? tntformatstrutils.pas

?? TNT Components Source
?? PAS
字號:

{*****************************************************************************}
{                                                                             }
{    Tnt Delphi Unicode Controls                                              }
{      http://www.tntware.com/delphicontrols/unicode/                         }
{        Version: 2.3.0                                                       }
{                                                                             }
{    Copyright (c) 2002-2007, Troy Wolbrink (troy.wolbrink@tntware.com)       }
{                                                                             }
{*****************************************************************************}

unit TntFormatStrUtils;

{$INCLUDE TntCompilers.inc}

interface

// this unit provides functions to work with format strings

uses
  TntSysUtils;

function GetCanonicalFormatStr(const _FormatString: WideString): WideString;
{$IFNDEF COMPILER_9_UP}
function ReplaceFloatingArgumentsInFormatString(const _FormatString: WideString;
  const Args: array of const
    {$IFDEF COMPILER_7_UP}; FormatSettings: PFormatSettings{$ENDIF}): WideString;
{$ENDIF}
procedure CompareFormatStrings(FormatStr1, FormatStr2: WideString);
function FormatStringsAreCompatible(FormatStr1, FormatStr2: WideString): Boolean;

type
  EFormatSpecError = class(ETntGeneralError);

implementation

uses
  SysUtils, Math, TntClasses;

resourcestring
  SInvalidFormatSpecifier = 'Invalid Format Specifier: %s';
  SMismatchedArgumentTypes = 'Argument types for index %d do not match. (%s <> %s)';
  SMismatchedArgumentCounts = 'Number of format specifiers do not match.';

type
  TFormatSpecifierType = (fstInteger, fstFloating, fstPointer, fstString);

function GetFormatSpecifierType(const FormatSpecifier: WideString): TFormatSpecifierType;
var
  LastChar: WideChar;
begin
  LastChar := TntWideLastChar(FormatSpecifier);
  case LastChar of
    'd', 'D', 'u', 'U', 'x', 'X':
      result := fstInteger;
    'e', 'E', 'f', 'F', 'g', 'G', 'n', 'N', 'm', 'M':
      result := fstFloating;
    'p', 'P':
      result := fstPointer;
    's', 'S':
      result := fstString
    else
      raise ETntInternalError.CreateFmt('Internal Error: Unexpected format type (%s)', [LastChar]);
  end;
end;

type
  TFormatStrParser = class(TObject)
  private
    ParsedString: TBufferedWideString;
    PFormatString: PWideChar;
    LastIndex: Integer;
    ExplicitCount: Integer;
    ImplicitCount: Integer;
    procedure RaiseInvalidFormatSpecifier;
    function ParseChar(c: WideChar): Boolean;
    procedure ForceParseChar(c: WideChar);
    function ParseDigit: Boolean;
    function ParseInteger: Boolean;
    procedure ForceParseType;
    function PeekDigit: Boolean;
    function PeekIndexSpecifier(out Index: Integer): Boolean;
  public
    constructor Create(const _FormatString: WideString);
    destructor Destroy; override;
    function ParseFormatSpecifier: Boolean;
  end;

constructor TFormatStrParser.Create(const _FormatString: WideString);
begin
  inherited Create;
  PFormatString := PWideChar(_FormatString);
  ExplicitCount := 0;
  ImplicitCount := 0;
  LastIndex := -1;
  ParsedString := TBufferedWideString.Create;
end;

destructor TFormatStrParser.Destroy;
begin
  FreeAndNil(ParsedString);
  inherited;
end;

procedure TFormatStrParser.RaiseInvalidFormatSpecifier;
begin
  raise EFormatSpecError.CreateFmt(SInvalidFormatSpecifier, [ParsedString.Value + PFormatString]);
end;

function TFormatStrParser.ParseChar(c: WideChar): Boolean;
begin
  result := False;
  if PFormatString^ = c then begin
    result := True;
    ParsedString.AddChar(c);
    Inc(PFormatString);
  end;
end;

procedure TFormatStrParser.ForceParseChar(c: WideChar);
begin
  if not ParseChar(c) then
    RaiseInvalidFormatSpecifier;
end;

function TFormatStrParser.PeekDigit: Boolean;
begin
  result := False;
  if  (PFormatString^ <> #0)
  and (PFormatString^ >= '0')
  and (PFormatString^ <= '9') then
    result := True;
end;

function TFormatStrParser.ParseDigit: Boolean;
begin
  result := False;
  if PeekDigit then begin
    result := True;
    ForceParseChar(PFormatString^);
  end;
end;

function TFormatStrParser.ParseInteger: Boolean;
const
  MAX_INT_DIGITS = 6;
var
  digitcount: integer;
begin
  digitcount := 0;
  While ParseDigit do begin
    inc(digitcount);
  end;
  result := (digitcount > 0);
  if digitcount > MAX_INT_DIGITS then
    RaiseInvalidFormatSpecifier;
end;

procedure TFormatStrParser.ForceParseType;
begin
  if PFormatString^ = #0 then
    RaiseInvalidFormatSpecifier;

  case PFormatString^ of
    'd', 'u', 'x', 'e', 'f', 'g', 'n', 'm', 'p', 's',
    'D', 'U', 'X', 'E', 'F', 'G', 'N', 'M', 'P', 'S':
  begin
    // do nothing
  end
  else
    RaiseInvalidFormatSpecifier;
  end;
  ForceParseChar(PFormatString^);
end;

function TFormatStrParser.PeekIndexSpecifier(out Index: Integer): Boolean;
var
  SaveParsedString: WideString;
  SaveFormatString: PWideChar;
begin
  SaveParsedString := ParsedString.Value;
  SaveFormatString := PFormatString;
  try
    ParsedString.Clear;
    Result := False;
    Index := -1;
    if ParseInteger then begin
      Index := StrToInt(ParsedString.Value);
      if ParseChar(':') then
        Result := True;
    end;
  finally
    ParsedString.Clear;
    ParsedString.AddString(SaveParsedString);
    PFormatString := SaveFormatString;
  end;
end;

function TFormatStrParser.ParseFormatSpecifier: Boolean;
var
  ExplicitIndex: Integer;
begin
  Result := False;
  // Parse entire format specifier
  ForceParseChar('%');
  if (PFormatString^ <> #0)
  and (not ParseChar(' '))
  and (not ParseChar('%')) then begin
    if PeekIndexSpecifier(ExplicitIndex) then begin
      Inc(ExplicitCount);
      LastIndex := Max(LastIndex, ExplicitIndex);
    end else begin
      Inc(ImplicitCount);
      Inc(LastIndex);
      ParsedString.AddString(IntToStr(LastIndex));
      ParsedString.AddChar(':');
    end;
    if ParseChar('*') then
    begin
      Inc(ImplicitCount);
      Inc(LastIndex);
      ParseChar(':');
    end else if ParseInteger then
      ParseChar(':');
    ParseChar('-');
    if ParseChar('*') then begin
      Inc(ImplicitCount);
      Inc(LastIndex);
    end else
      ParseInteger;
    if ParseChar('.') then begin
      if not ParseChar('*') then
        ParseInteger;
    end;
    ForceParseType;
    Result := True;
  end;
end;

//-----------------------------------

function GetCanonicalFormatStr(const _FormatString: WideString): WideString;
var
  PosSpec: Integer;
begin
  with TFormatStrParser.Create(_FormatString) do
  try
    // loop until no more '%'
    PosSpec := Pos('%', PFormatString);
    While PosSpec <> 0 do begin
      try
        // delete everything up until '%'
        ParsedString.AddBuffer(PFormatString, PosSpec - 1);
        Inc(PFormatString, PosSpec - 1);
        // parse format specifier
        ParseFormatSpecifier;
      finally
        PosSpec := Pos('%', PFormatString);
      end;
    end;
    if ((ExplicitCount = 0) and (ImplicitCount = 1)) {simple expression}
    or ((ExplicitCount > 0) and (ImplicitCount = 0)) {nothing converted} then
      result := _FormatString {original}
    else
      result := ParsedString.Value + PFormatString;
  finally
    Free;
  end;
end;

{$IFNDEF COMPILER_9_UP}
function ReplaceFloatingArgumentsInFormatString(const _FormatString: WideString;
  const Args: array of const
    {$IFDEF COMPILER_7_UP}; FormatSettings: PFormatSettings{$ENDIF}): WideString;
{ This function replaces floating point format specifiers with their actual formatted values.
  It also adds index specifiers so that the other format specifiers don't lose their place.
  The reason for this is that WideFormat doesn't correctly format floating point specifiers.
  See QC#4254. }
var
  Parser: TFormatStrParser;
  PosSpec: Integer;
  Output: TBufferedWideString;
begin
  Output := TBufferedWideString.Create;
  try
    Parser := TFormatStrParser.Create(_FormatString);
    with Parser do
    try
      // loop until no more '%'
      PosSpec := Pos('%', PFormatString);
      While PosSpec <> 0 do begin
        try
          // delete everything up until '%'
          Output.AddBuffer(PFormatString, PosSpec - 1);
          Inc(PFormatString, PosSpec - 1);
          // parse format specifier
          ParsedString.Clear;
          if (not ParseFormatSpecifier)
          or (GetFormatSpecifierType(ParsedString.Value) <> fstFloating) then
            Output.AddBuffer(ParsedString.BuffPtr, MaxInt)
          {$IFDEF COMPILER_7_UP}
          else if Assigned(FormatSettings) then
            Output.AddString(Format{TNT-ALLOW Format}(ParsedString.Value, Args, FormatSettings^))
          {$ENDIF}
          else
            Output.AddString(Format{TNT-ALLOW Format}(ParsedString.Value, Args));
        finally
          PosSpec := Pos('%', PFormatString);
        end;
      end;
      Output.AddString(PFormatString);
    finally
      Free;
    end;
    Result := Output.Value;
  finally
    Output.Free;
  end;
end;
{$ENDIF}

procedure GetFormatArgs(const _FormatString: WideString; FormatArgs: TTntStrings);
var
  PosSpec: Integer;
begin
  with TFormatStrParser.Create(_FormatString) do
  try
    FormatArgs.Clear;
    // loop until no more '%'
    PosSpec := Pos('%', PFormatString);
    While PosSpec <> 0 do begin
      try
        // delete everything up until '%'
        Inc(PFormatString, PosSpec - 1);
        // add format specifier to list
        ParsedString.Clear;
        if ParseFormatSpecifier then
          FormatArgs.Add(ParsedString.Value);
      finally
        PosSpec := Pos('%', PFormatString);
      end;
    end;
  finally
    Free;
  end;
end;

function GetExplicitIndex(const FormatSpecifier: WideString): Integer;
var
  IndexStr: WideString;
  PosColon: Integer;
begin
  result := -1;
  PosColon := Pos(':', FormatSpecifier);
  if PosColon <> 0 then begin
    IndexStr := Copy(FormatSpecifier, 2, PosColon - 2);
    result := StrToInt(IndexStr);
  end;
end;

function GetMaxIndex(FormatArgs: TTntStrings): Integer;
var
  i: integer;
  RunningIndex: Integer;
  ExplicitIndex: Integer;
begin
  result := -1;
  RunningIndex := -1;
  for i := 0 to FormatArgs.Count - 1 do begin
    ExplicitIndex := GetExplicitIndex(FormatArgs[i]);
    if ExplicitIndex <> -1 then
      RunningIndex := ExplicitIndex
    else
      inc(RunningIndex);
    result := Max(result, RunningIndex);
  end;
end;

procedure UpdateTypeList(FormatArgs, TypeList: TTntStrings);
var
  i: integer;
  f: WideString;
  SpecType: TFormatSpecifierType;
  ExplicitIndex: Integer;
  MaxIndex: Integer;
  RunningIndex: Integer;
begin
  // set count of TypeList to accomodate maximum index
  MaxIndex := GetMaxIndex(FormatArgs);
  TypeList.Clear;
  for i := 0 to MaxIndex do
    TypeList.Add('');

  // for each arg...
  RunningIndex := -1;
  for i := 0 to FormatArgs.Count - 1 do begin
    f := FormatArgs[i];
    ExplicitIndex := GetExplicitIndex(f);
    SpecType := GetFormatSpecifierType(f);

    // determine running arg index
    if ExplicitIndex <> -1 then
      RunningIndex := ExplicitIndex
    else
      inc(RunningIndex);

    if TypeList[RunningIndex] <> '' then begin
      // already exists in list, check for compatibility
      if TypeList.Objects[RunningIndex] <> TObject(SpecType) then
        raise EFormatSpecError.CreateFmt(SMismatchedArgumentTypes,
          [RunningIndex, TypeList[RunningIndex], f]);
    end else begin
      // not in list so update it
      TypeList[RunningIndex] := f;
      TypeList.Objects[RunningIndex] := TObject(SpecType);
    end;
  end;
end;

procedure CompareFormatStrings(FormatStr1, FormatStr2: WideString);
var
  ArgList1: TTntStringList;
  ArgList2: TTntStringList;
  TypeList1: TTntStringList;
  TypeList2: TTntStringList;
  i: integer;
begin
  ArgList1 := nil;
  ArgList2 := nil;
  TypeList1 := nil;
  TypeList2 := nil;
  try
    ArgList1 := TTntStringList.Create;
    ArgList2 := TTntStringList.Create;
    TypeList1 := TTntStringList.Create;
    TypeList2 := TTntStringList.Create;

    GetFormatArgs(FormatStr1, ArgList1);
    UpdateTypeList(ArgList1, TypeList1);

    GetFormatArgs(FormatStr2, ArgList2);
    UpdateTypeList(ArgList2, TypeList2);

    if TypeList1.Count <> TypeList2.Count then
      raise EFormatSpecError.Create(SMismatchedArgumentCounts + CRLF + CRLF + '> ' + FormatStr1 + CRLF + '> ' + FormatStr2);

    for i := 0 to TypeList1.Count - 1 do begin
      if TypeList1.Objects[i] <> TypeList2.Objects[i] then begin
        raise EFormatSpecError.CreateFmt(SMismatchedArgumentTypes,
          [i, TypeList1[i], TypeList2[i]]);
      end;
    end;

  finally
    ArgList1.Free;
    ArgList2.Free;
    TypeList1.Free;
    TypeList2.Free;
  end;
end;

function FormatStringsAreCompatible(FormatStr1, FormatStr2: WideString): Boolean;
var
  ArgList1: TTntStringList;
  ArgList2: TTntStringList;
  TypeList1: TTntStringList;
  TypeList2: TTntStringList;
  i: integer;
begin
  ArgList1 := nil;
  ArgList2 := nil;
  TypeList1 := nil;
  TypeList2 := nil;
  try
    ArgList1 := TTntStringList.Create;
    ArgList2 := TTntStringList.Create;
    TypeList1 := TTntStringList.Create;
    TypeList2 := TTntStringList.Create;

    GetFormatArgs(FormatStr1, ArgList1);
    UpdateTypeList(ArgList1, TypeList1);

    GetFormatArgs(FormatStr2, ArgList2);
    UpdateTypeList(ArgList2, TypeList2);

    Result := (TypeList1.Count = TypeList2.Count);
    if Result then begin
      for i := 0 to TypeList1.Count - 1 do begin
        if TypeList1.Objects[i] <> TypeList2.Objects[i] then begin
          Result := False;
          break;
        end;
      end;
    end;
  finally
    ArgList1.Free;
    ArgList2.Free;
    TypeList1.Free;
    TypeList2.Free;
  end;
end;

end.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文字幕欧美日韩一区| 久久精品视频免费| 国产风韵犹存在线视精品| 亚洲一区二区三区四区中文字幕| 日韩欧美一区二区在线视频| 色综合网站在线| 高清在线不卡av| 免费精品99久久国产综合精品| 亚洲欧美偷拍三级| 国产日韩一级二级三级| 欧美不卡视频一区| 欧美二区三区的天堂| 欧美性视频一区二区三区| 风间由美性色一区二区三区| 久久国产剧场电影| 视频在线观看一区二区三区| 亚洲激情图片小说视频| 国产精品乱人伦| 国产欧美一区在线| 精品久久久久香蕉网| 91麻豆精品91久久久久久清纯| 95精品视频在线| 99麻豆久久久国产精品免费优播| 国产永久精品大片wwwapp| 九色|91porny| 久久国产生活片100| 日本aⅴ精品一区二区三区| 婷婷国产v国产偷v亚洲高清| 亚洲一二三级电影| 亚洲一区二区中文在线| 一区二区三区久久久| 亚洲啪啪综合av一区二区三区| 国产精品卡一卡二| 日韩欧美一二三| 日韩美女久久久| 久久久噜噜噜久久人人看 | 在线观看不卡视频| 波多野结衣中文字幕一区 | 亚洲午夜免费电影| 亚洲国产综合91精品麻豆| 亚洲二区视频在线| 午夜视频在线观看一区二区| 日本亚洲天堂网| 精品中文av资源站在线观看| 国产一区二区精品久久| 国产成人免费在线视频| 91影视在线播放| 91成人免费在线| 欧美日韩国产免费一区二区 | 国产精品水嫩水嫩| 国产精品久久夜| 一区二区三区加勒比av| 亚洲国产日韩一区二区| 日日摸夜夜添夜夜添亚洲女人| 日本不卡视频一二三区| 极品少妇xxxx精品少妇| 国产91精品入口| 一本色道久久加勒比精品| 精品视频一区三区九区| 7799精品视频| 国产亚洲欧美日韩日本| 国产精品麻豆视频| 亚洲线精品一区二区三区八戒| 天天av天天翘天天综合网 | 国内外成人在线视频| 成人在线视频一区| 色婷婷av一区二区三区软件| 欧美一级视频精品观看| 国产午夜亚洲精品理论片色戒 | 亚洲欧美色图小说| 日韩精品电影一区亚洲| 国产乱码精品一区二区三区忘忧草 | 9191久久久久久久久久久| 2023国产一二三区日本精品2022| 国产精品国产三级国产普通话99 | 首页亚洲欧美制服丝腿| 高清不卡在线观看| 欧美性大战久久久久久久| wwwwww.欧美系列| 亚洲免费视频中文字幕| 紧缚奴在线一区二区三区| 91麻豆成人久久精品二区三区| 欧美精品18+| 亚洲欧洲国产专区| 久久黄色级2电影| 色丁香久综合在线久综合在线观看| 日韩午夜在线播放| 夜夜嗨av一区二区三区网页| 国产九色sp调教91| 91精品免费在线| 自拍视频在线观看一区二区| 日本麻豆一区二区三区视频| 色综合久久久网| 精品久久久久久久久久久久久久久| 亚洲美女少妇撒尿| 国产不卡在线视频| 日韩欧美精品在线| 亚洲午夜在线视频| 99国产欧美另类久久久精品| 久久综合九色综合97婷婷女人 | 在线观看一区二区视频| 久久精品夜夜夜夜久久| 日韩国产欧美三级| 色悠悠亚洲一区二区| 国产无一区二区| 日韩高清欧美激情| 欧美系列一区二区| 亚洲色图视频网站| 成人免费看视频| 久久综合久久综合亚洲| 蜜臀91精品一区二区三区| 欧美性xxxxxxxx| 亚洲天堂免费看| voyeur盗摄精品| 欧美国产精品中文字幕| 国产一区二区三区在线看麻豆| 538在线一区二区精品国产| 亚洲欧美激情小说另类| 97久久精品人人爽人人爽蜜臀| 久久久国产午夜精品| 精品午夜久久福利影院| 3atv在线一区二区三区| 日韩二区三区在线观看| 欧美精品tushy高清| 亚洲电影一级片| 欧美精品三级在线观看| 亚洲电影在线播放| 欧美区视频在线观看| 亚洲1区2区3区视频| 欧美日韩成人综合在线一区二区| 一区二区三区国产| 欧美日韩精品福利| 午夜激情一区二区| 欧美一级夜夜爽| 久久精品国产一区二区三 | www.成人在线| 亚洲女人****多毛耸耸8| 色www精品视频在线观看| 亚洲九九爱视频| 在线免费亚洲电影| 亚洲国产精品久久人人爱蜜臀| 欧美日韩亚洲综合| 蜜桃一区二区三区四区| 久久久亚洲精品一区二区三区| 国产一区二区三区香蕉| 国产精品无遮挡| 日本精品视频一区二区三区| 夜色激情一区二区| 6080午夜不卡| 狠狠久久亚洲欧美| 国产精品毛片大码女人| 色先锋久久av资源部| 亚洲午夜精品在线| 日韩欧美久久久| 丁香激情综合五月| 一区二区三区日韩在线观看| 欧美巨大另类极品videosbest | 久久电影网站中文字幕| 国产视频亚洲色图| 99精品国产99久久久久久白柏| 一区二区三区四区高清精品免费观看| 欧美在线视频不卡| 另类专区欧美蜜桃臀第一页| 国产女主播视频一区二区| 色一情一乱一乱一91av| 欧美aa在线视频| 中文一区二区在线观看| 91激情在线视频| 久久99精品国产.久久久久| 国产精品理伦片| 欧美乱妇20p| 国产精品66部| 亚洲国产成人va在线观看天堂 | 一区二区三区四区视频精品免费| 欧美一区二区三区白人| 国产91精品在线观看| 一区二区三区在线视频观看| 日韩一区二区免费视频| 成人高清伦理免费影院在线观看| 亚洲国产精品视频| 国产欧美日韩三区| 欧美日韩在线电影| 国产91精品久久久久久久网曝门| 亚洲线精品一区二区三区八戒| 精品国产一区二区三区不卡| 色婷婷精品大视频在线蜜桃视频| 麻豆一区二区在线| 自拍偷在线精品自拍偷无码专区| 欧美日韩精品电影| zzijzzij亚洲日本少妇熟睡| 日韩精品1区2区3区| 国产精品不卡一区二区三区| 91精品国产色综合久久不卡蜜臀| 国产91色综合久久免费分享| 日本aⅴ精品一区二区三区| 亚洲丝袜自拍清纯另类| 精品国产一区久久| 在线播放/欧美激情| 在线亚洲一区二区| 国产精一区二区三区|