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

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? ulkjson.pas

?? json delphi component
?? PAS
?? 第 1 頁(yè) / 共 4 頁(yè)
字號(hào):
{
  LkJSON v1.02

  14 september 2007

  Copyright (C) 2006,2007 Leonid Koninin
  leon_kon@users.sourceforge.net

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

  changes:

  v1.02 14/09/2007 * fix mistypes in diffrent places; thanx for reports
                     to Aleksandr Fedorov and Tobias Wrede
  v1.01 18/05/2007 * fix small bug in new text generation routine, check
                     library for leaks by fastmm4; thanx for idea and comments
                     for Glynn Owen
  v1.00 12/05/2007 * some fixes in new code (mistypes, mistypes...)
                   * also many fixes by ideas of Henri Gourvest - big thanx
                     for him again; he send me code for thread-safe initializing
                     of hash table, some FPC-compatible issues (not tested by
                     myself) and better code for localization in latest
                     delphi versions; very, very big thanx!
                   * rewritten procedure of json text generating, with wich
                     work of it speeds up 4-5 times (on test) its good for
                     a large objects
                   * started a large work for making source code self-doc
                     (not autodoc!)
  v0.99 10/05/2007 + add functions to list and object:
                      function getInt(idx: Integer): Integer;
                      function getString(idx: Integer): String;
                      function getWideString(idx: Integer):WideString;
                      function getDouble(idx: Integer): Double;
                      function getBoolean(idx: Integer): Boolean;
                   + add overloaded functions to object:
                      function getDouble(nm: String): Double; overload;
                      function getInt(nm: String): Integer; overload;
                      function getString(nm: String): String; overload;
                      function getWideString(nm: String): WideString; overload;
                      function getBoolean(nm: String): Boolean; overload;
                   * changed storing mech of TlkJSONcustomlist descendants from
                     dynamic array to TList; this gives us great speedup with
                     lesser changes; thanx for idea to Henri Gourvest
                   * also reworked hashtable to work with TList, so it also
                     increase speed of work
  v0.98 09/05/2007 * fix small bug in work with WideStrings(UTF8), thanx to
                     IVO GELOV to description and sources
  v0.97 10/04/2007 + add capabilities to work with KOL delphi projects; for
                     this will define KOL variable in begin of text; of course,
                     in this case object TlkJSONstreamed is not compiled.
  v0.96 03/30/2007 + add TlkJSONFuncEnum and method ForEach in all
                     TlkJSONcustomlist descendants
                   + add property UseHash(r/o) to TlkJSONobject, and parameter
                     UseHash:Boolean to object constructors; set ti to false
                     allow to disable using of hash-table, what can increase
                     speed of work in case of objects with low number of
                     methods(fields); [by default it is true]
                   + added conditional compile directive DOTNET for use in .Net
                     based delphi versions; remove dot in declaration below
                     (thanx for idea and sample code to Tim Radford)
                   + added property HashOf to TlkHashTable to allow use of
                     users hash functions; on enter is widestring, on exit is
                     cardinal (32 bit unsigned). Original HashOf renamed to
                     DefaultHashOf
                   * hash table object of TlkJSONobject wrapped by property called
                     HashTable
                   * fixed some minor bugs
  v0.95 03/29/2007 + add object TlkJSONstreamed what descendant of TlkJSON and
                     able to load/save JSON objects from/to streams/files.
                   * fixed small bug in generating of unicode strings representation
  v0.94 03/27/2007 + add properties NameOf and FieldByIndex to TlkJSONobject
                   * fix small error in parsing unicode chars
                   * small changes in hashing code (try to speed up)
  v0.93 03/05/2007 + add overloaded functions to list and object
                   + add enum type TlkJSONtypes
                   + add functions: SelfType:TlkJSONtypes and
                     SelfTypeName: String to every TlkJSONbase child
                   * fix mistype 'IndefOfName' to 'IndexOfName'
                   * fix mistype 'IndefOfObject' to 'IndexOfObject'
  v0.92 03/02/2007 + add some fix to TlkJSON.ParseText to fix bug with parsing
                     objects - object methods not always added properly
                     to hash array (thanx to Chris Matheson)
  ...
}

unit uLkJSON;
{$ifdef fpc}
  {$mode objfpc}{$H+}
  {.$DEFINE HAVE_FORMATSETTING}
{$else}
  {$if RTLVersion > 14.00}
    {$DEFINE HAVE_FORMATSETTING}
  {$ifend}
{$endif}

interface

{.$DEFINE KOL}
{.$define DOTNET}
{$define THREADSAFE}
{$define NEW_STYLE_GENERATE}

uses windows,
  SysUtils,
{$IFNDEF KOL}
  classes,
{$ELSE}
  kol,
{$ENDIF}
  variants;

type
  TlkJSONtypes = (jsBase, jsNumber, jsString, jsBoolean, jsNull,
    jsList, jsObject);

{$IFDEF DOTNET}

  TlkJSONdotnetclass = class
  public
    constructor Create;
    destructor Destroy; override;
    procedure AfterConstruction; virtual;
    procedure BeforeDestruction; virtual;
  end;

{$ENDIF DOTNET}

  TlkJSONbase = class{$IFDEF DOTNET}(TlkJSONdotnetclass){$ENDIF}
  protected
    function GetValue: variant; virtual;
    procedure SetValue(const AValue: variant); virtual;
    function GetChild(idx: Integer): TlkJSONbase; virtual;
    procedure SetChild(idx: Integer; const AValue: TlkJSONbase);
      virtual;
    function GetCount: Integer; virtual;
  public
    property Count: Integer read GetCount;
    property Child[idx: Integer]: TlkJSONbase read GetChild write SetChild;
    property Value: variant read GetValue write SetValue;
    class function SelfType: TlkJSONtypes; virtual;
    class function SelfTypeName: string; virtual;
  end;

  TlkJSONnumber = class(TlkJSONbase)
  protected
    FValue: extended;
    function GetValue: Variant; override;
    procedure SetValue(const AValue: Variant); override;
  public
    procedure AfterConstruction; override;
    class function Generate(AValue: extended = 0): TlkJSONnumber;
    class function SelfType: TlkJSONtypes; override;
    class function SelfTypeName: string; override;
  end;

  TlkJSONstring = class(TlkJSONbase)
  protected
    FValue: WideString;
    function GetValue: Variant; override;
    procedure SetValue(const AValue: Variant); override;
  public
    procedure AfterConstruction; override;
    class function Generate(const wsValue: WideString = ''): TlkJSONstring;
    class function SelfType: TlkJSONtypes; override;
    class function SelfTypeName: string; override;
  end;

  TlkJSONboolean = class(TlkJSONbase)
  protected
    FValue: Boolean;
    function GetValue: Variant; override;
    procedure SetValue(const AValue: Variant); override;
  public
    procedure AfterConstruction; override;
    class function Generate(AValue: Boolean = true): TlkJSONboolean;
    class function SelfType: TlkJSONtypes; override;
    class function SelfTypeName: string; override;
  end;

  TlkJSONnull = class(TlkJSONbase)
  protected
    function GetValue: Variant; override;
    function Generate: TlkJSONnull;
  public
    class function SelfType: TlkJSONtypes; override;
    class function SelfTypeName: string; override;
  end;

  TlkJSONFuncEnum = procedure(ElName: string; Elem: TlkJSONbase;
    data: pointer; var Continue: Boolean) of object;

  TlkJSONcustomlist = class(TlkJSONbase)
  protected
//    FValue: array of TlkJSONbase;
    fList:TList;
    function GetCount: Integer; override;
    function GetChild(idx: Integer): TlkJSONbase; override;
    procedure SetChild(idx: Integer; const AValue: TlkJSONbase);
      override;
    function ForEachElement(idx: Integer; var nm: string):
      TlkJSONbase; virtual;

    function _Add(obj: TlkJSONbase): Integer; virtual;
    procedure _Delete(idx: Integer); virtual;
    function _IndexOf(obj: TlkJSONbase): Integer; virtual;
  public
    procedure ForEach(cb: TlkJSONFuncEnum; data: pointer);
    procedure AfterConstruction; override;
    procedure BeforeDestruction; override;

    function getInt(idx: Integer): Integer; virtual;
    function getString(idx: Integer): String; virtual;
    function getWideString(idx: Integer):WideString; virtual;
    function getDouble(idx: Integer): Double; virtual;
    function getBoolean(idx: Integer): Boolean; virtual;
  end;

  TlkJSONlist = class(TlkJSONcustomlist)
  public
    function Add(obj: TlkJSONbase): Integer; overload;

    function Add(bool: Boolean): Integer; overload;
    function Add(nmb: double): Integer; overload;
    function Add(s: string): Integer; overload;
    function Add(const ws: WideString): Integer; overload;
    function Add(inmb: Integer): Integer; overload;

    procedure Delete(idx: Integer);
    function IndexOf(obj: TlkJSONbase): Integer;
    class function Generate: TlkJSONlist;
    class function SelfType: TlkJSONtypes; override;
    class function SelfTypeName: string; override;

  end;

  TlkJSONobjectmethod = class(TlkJSONbase)
  protected
    FValue: TlkJSONbase;
    FName: WideString;
    procedure SetName(const AValue: WideString);
  public
    procedure AfterConstruction; override;
    procedure BeforeDestruction; override;
    property Name: WideString read FName write SetName;
    class function Generate(const aname: WideString; aobj: TlkJSONbase):
      TlkJSONobjectmethod;
  end;

  PlkHashItem = ^TlkHashItem;
  TlkHashItem = packed record
    hash: cardinal;
    index: Integer;
  end;

  TlkHashFunction = function(const ws: WideString): cardinal of object;

  TlkHashTable = class
  private
    FHashFunction: TlkHashFunction;
    procedure SetHashFunction(const AValue: TlkHashFunction);
  protected
//    a_h: array[0..255] of array of TlkHashItem;
    a_x: array[0..255] of TList;
    procedure hswap(j, k, l: Integer);
    function InTable(const ws: WideString; var i, j, k: cardinal): Boolean;
  public
    function counters: string;

    function DefaultHashOf(const ws: WideString): cardinal;
    function SimpleHashOf(const ws: WideString): cardinal;

    property HashOf: TlkHashFunction read FHashFunction write
      SetHashFunction;

    function IndexOf(const ws: WideString): Integer;

    procedure AddPair(const ws: WideString; idx: Integer);
    procedure Delete(const ws: WideString);

    constructor Create;
    destructor Destroy; override;
  end;

  TlkJSONobject = class(TlkJSONcustomlist)
  protected
    ht: TlkHashTable;
    FUseHash: Boolean;
    function GetFieldByIndex(idx: Integer): TlkJSONbase;
    function GetNameOf(idx: Integer): WideString;
    procedure SetFieldByIndex(idx: Integer; const AValue:
      TlkJSONbase);
    function GetHashTable: TlkHashTable;
    function ForEachElement(idx: Integer; var nm: string):
      TlkJSONbase;
      override;
  public
    property UseHash: Boolean read FUseHash;
    property HashTable: TlkHashTable read GetHashTable;
    function GetField(nm: string): TlkJSONbase;
    procedure SetField(nm: string; const AValue: TlkJSONbase);

    function Add(const aname: WideString; aobj: TlkJSONbase): Integer;
      overload;

    function Add(const aname: WideString; bool: Boolean): Integer;
      overload;
    function Add(const aname: WideString; nmb: double): Integer; overload;
    function Add(const aname: WideString; s: string): Integer; overload;
    function Add(const aname: WideString; const ws: WideString): Integer;
      overload;
    function Add(const aname: WideString; inmb: Integer): Integer;
      overload;

    procedure Delete(idx: Integer);
    function IndexOfName(const aname: WideString): Integer;
    function IndexOfObject(aobj: TlkJSONbase): Integer;
    property Field[nm: string]: TlkJSONbase read GetField write SetField; default;

    constructor Create(bUseHash: Boolean = true);
    destructor Destroy; override;

    class function Generate(AUseHash: Boolean = true): TlkJSONobject;
    class function SelfType: TlkJSONtypes; override;
    class function SelfTypeName: string; override;

    property FieldByIndex[idx: Integer]: TlkJSONbase read GetFieldByIndex write SetFieldByIndex;
    property NameOf[idx: Integer]: WideString read GetNameOf;

    function getDouble(idx: Integer): Double; overload; override;
    function getInt(idx: Integer): Integer; overload; override;
    function getString(idx: Integer): String; overload; override;
    function getWideString(idx: Integer): WideString; overload; override;
    function getBoolean(idx: Integer): Boolean; overload; override;

    function getDouble(nm: String): Double; overload;
    function getInt(nm: String): Integer; overload;
    function getString(nm: String): String; overload;
    function getWideString(nm: String): WideString; overload;
    function getBoolean(nm: String): Boolean; overload;
  end;

  TlkJSON = class
  public
    class function ParseText(const txt: string): TlkJSONbase;
    class function GenerateText(obj: TlkJSONbase): string;
  end;

{$IFNDEF KOL}
  TlkJSONstreamed = class(TlkJSON)
    class function LoadFromStream(src: TStream): TlkJSONbase;
    class procedure SaveToStream(obj: TlkJSONbase; dst: TStream);
    class function LoadFromFile(srcname: string): TlkJSONbase;
    class procedure SaveToFile(obj: TlkJSONbase; dstname: string);
  end;
{$ENDIF}

implementation

uses math;

type
  ElkIntException = class(Exception)
  public
    idx: Integer;
    constructor Create(idx: Integer; msg: string);
  end;

// author of this routine is IVO GELOV
function code2utf(iNumber: Integer): UTF8String;
begin
  if iNumber < 128 then Result := chr(iNumber)
  else if iNumber < 2048 then
    Result := chr((iNumber shr 6) + 192) + chr((iNumber and 63) + 128)
  else if iNumber < 65536 then
    Result := chr((iNumber shr 12) + 224) + chr(((iNumber shr 6) and 63) + 128)
    + chr((iNumber and 63) + 128)
  else if iNumber < 2097152 then
    Result := chr((iNumber shr 18) + 240) + chr(((iNumber shr 12) and 63) + 128)
    + chr(((iNumber shr 6) and 63) + 128) + chr((iNumber and 63) + 128);
end;

{ TlkJSONbase }

function TlkJSONbase.GetChild(idx: Integer): TlkJSONbase;
begin
  result := nil;
end;

function TlkJSONbase.GetCount: Integer;
begin
  result := 0;
end;

function TlkJSONbase.GetValue: variant;
begin
  result := variants.Null;
end;

class function TlkJSONbase.SelfType: TlkJSONtypes;
begin
  result := jsBase;
end;

class function TlkJSONbase.SelfTypeName: string;
begin
  result := 'jsBase';
end;

procedure TlkJSONbase.SetChild(idx: Integer; const AValue:
  TlkJSONbase);
begin

end;

procedure TlkJSONbase.SetValue(const AValue: variant);
begin

end;

{ TlkJSONnumber }

procedure TlkJSONnumber.AfterConstruction;
begin
  inherited;
  FValue := 0;
end;

class function TlkJSONnumber.Generate(AValue: extended): TlkJSONnumber;
begin
  result := TlkJSONnumber.Create;
  result.FValue := AValue;
end;

function TlkJSONnumber.GetValue: Variant;
begin
  result := FValue;
end;

class function TlkJSONnumber.SelfType: TlkJSONtypes;
begin
  result := jsNumber;
end;

class function TlkJSONnumber.SelfTypeName: string;
begin
  result := 'jsNumber';
end;

procedure TlkJSONnumber.SetValue(const AValue: Variant);
begin
  FValue := VarAsType(AValue, varDouble);
end;

{ TlkJSONstring }

procedure TlkJSONstring.AfterConstruction;
begin
  inherited;
  FValue := '';
end;

class function TlkJSONstring.Generate(const wsValue: WideString): TlkJSONstring;
begin
  result := TlkJSONstring.Create;
  result.FValue := wsValue;
end;

function TlkJSONstring.GetValue: Variant;
begin
  result := FValue;
end;

class function TlkJSONstring.SelfType: TlkJSONtypes;
begin
  result := jsString;
end;

class function TlkJSONstring.SelfTypeName: string;
begin
  result := 'jsString';
end;

procedure TlkJSONstring.SetValue(const AValue: Variant);
begin
  FValue := VarToWideStr(AValue);
end;

{ TlkJSONboolean }

procedure TlkJSONboolean.AfterConstruction;
begin
  FValue := false;
end;

class function TlkJSONboolean.Generate(AValue: Boolean): TlkJSONboolean;
begin
  result := TlkJSONboolean.Create;
  result.Value := AValue;
end;

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩你懂得| 国产高清在线精品| 欧美群妇大交群中文字幕| 亚洲精品成人精品456| 99在线精品一区二区三区| 亚洲日本丝袜连裤袜办公室| 91视视频在线观看入口直接观看www| 国产精品久久毛片a| 91免费版在线看| 亚洲成人综合视频| 欧美成人vps| jizzjizzjizz欧美| 亚洲aaa精品| 欧美精品一区二区三区视频| 成熟亚洲日本毛茸茸凸凹| 亚洲欧美日韩国产另类专区| 欧美精品日韩精品| 国产原创一区二区三区| 最新热久久免费视频| 欧美色国产精品| 国内精品嫩模私拍在线| 中文字幕av不卡| 欧美日韩免费观看一区三区| 久久国产精品99久久人人澡| 亚洲国产高清aⅴ视频| 欧美最新大片在线看| 青青草成人在线观看| 中文字幕第一区二区| 91黄色免费看| 国产乱码精品一区二区三| 一区二区三区四区不卡视频| 精品国产伦一区二区三区免费| av成人免费在线观看| 日韩电影免费在线看| 国产精品色哟哟网站| 欧美日韩高清一区二区| 成人免费的视频| 狂野欧美性猛交blacked| 国产精品动漫网站| 日韩精品在线一区二区| 日本乱人伦aⅴ精品| 国产呦萝稀缺另类资源| 亚洲国产精品久久久男人的天堂 | 日韩伦理电影网| 777a∨成人精品桃花网| 播五月开心婷婷综合| 麻豆久久久久久久| 国产精品久久久久久久久免费丝袜 | 成人性生交大片免费看中文 | 精品成人a区在线观看| 9色porny自拍视频一区二区| 狠狠色2019综合网| 水蜜桃久久夜色精品一区的特点 | 欧美日韩午夜在线| 欧美一区二区三区视频在线观看| 丰满亚洲少妇av| 久久99蜜桃精品| 午夜精品福利视频网站| 亚洲特黄一级片| 亚洲精品一区二区三区四区高清| 精品1区2区3区| 色婷婷国产精品综合在线观看| 国产精品伊人色| 精品中文av资源站在线观看| 偷拍亚洲欧洲综合| 有坂深雪av一区二区精品| 国产欧美一区二区精品忘忧草| 欧美一区二区视频在线观看| 欧美性高清videossexo| 91网址在线看| 91丨国产丨九色丨pron| www.日韩在线| 成人精品免费看| 成人午夜看片网址| 国产91精品入口| 大胆亚洲人体视频| 不卡的av电影在线观看| 成人久久18免费网站麻豆| 成人午夜激情影院| 本田岬高潮一区二区三区| 成人精品视频一区二区三区| www.日本不卡| 色婷婷av一区二区三区之一色屋| 欧洲一区在线观看| 在线观看av一区| 欧美剧情片在线观看| 91精品国产91久久久久久一区二区| 欧美日韩你懂的| 欧美一级免费大片| 欧美不卡视频一区| 久久久精品一品道一区| 国产精品免费久久久久| 国产精品日韩精品欧美在线| 综合电影一区二区三区| 一区二区三区精品在线| 亚洲综合色丁香婷婷六月图片| 亚洲第一av色| 另类小说图片综合网| 国产高清不卡一区二区| 91视频在线观看免费| 欧美精品久久久久久久多人混战| 欧美高清视频一二三区 | 欧美日韩国产中文| 欧美一级电影网站| 亚洲国产精品99久久久久久久久| 国产精品久久久久毛片软件| 一区二区三区免费| 久久狠狠亚洲综合| jizzjizzjizz欧美| 欧美日韩国产在线观看| 久久久亚洲综合| 亚洲最快最全在线视频| 久久精品国产一区二区| 成人午夜激情视频| 8v天堂国产在线一区二区| 国产午夜三级一区二区三| 亚洲国产婷婷综合在线精品| 韩国欧美国产1区| 在线视频国内一区二区| 欧美tickling挠脚心丨vk| 一区免费观看视频| 日韩影视精彩在线| av资源站一区| 欧美mv和日韩mv国产网站| 中文字幕在线不卡| 九色综合狠狠综合久久| 91久久免费观看| 精品国产sm最大网站| 一个色妞综合视频在线观看| 国产一区二区三区黄视频 | 亚洲电影一区二区三区| 国产精品一二三四区| 欧美日韩一级大片网址| 欧美国产综合一区二区| 麻豆精品精品国产自在97香蕉| 99久久精品国产一区| 欧美精品一区二区高清在线观看| 一区二区三区在线影院| 国产91精品精华液一区二区三区 | 香蕉成人伊视频在线观看| 懂色av一区二区三区免费看| 欧美一区二区三区日韩视频| 亚洲女人小视频在线观看| 韩国视频一区二区| 欧美一区二区精美| 亚洲自拍欧美精品| 播五月开心婷婷综合| 久久综合999| 久久激情五月婷婷| 欧美一级在线观看| 亚洲成人你懂的| 色综合久久综合中文综合网| 国产精品三级在线观看| 日本亚洲欧美天堂免费| 欧美三级日韩三级| 亚洲黄色av一区| 91在线播放网址| 国产精品久久国产精麻豆99网站| 狠狠色综合日日| 日韩精品影音先锋| 美国十次综合导航| 欧美一区二区精品在线| 青青青伊人色综合久久| 欧美美女网站色| 视频一区国产视频| 欧美日本一区二区在线观看| 一区二区三区四区国产精品| 日本高清无吗v一区| 亚洲精品你懂的| 在线亚洲+欧美+日本专区| 一区二区三区精品| 欧美揉bbbbb揉bbbbb| 亚洲国产一区二区视频| 精品视频999| 蜜桃在线一区二区三区| 欧美xingq一区二区| 国模无码大尺度一区二区三区| 26uuuu精品一区二区| 国产成人综合亚洲91猫咪| 久久网这里都是精品| 成人黄色电影在线| 1000部国产精品成人观看| 日本福利一区二区| 日本美女一区二区| 精品国产三级a在线观看| 国产一区二区三区久久悠悠色av| 国产日韩精品一区二区三区在线| 成人一区二区三区中文字幕| 亚洲视频在线一区| 欧美日韩国产123区| 久久99精品久久只有精品| 久久久精品影视| 一本色道久久综合亚洲91| 香蕉影视欧美成人| 2023国产精品| eeuss鲁一区二区三区| 亚洲大片在线观看| 久久综合五月天婷婷伊人| 99精品久久免费看蜜臀剧情介绍| 亚洲综合男人的天堂|