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

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

?? ulkjson.pas

?? json delphi component
?? PAS
?? 第 1 頁 / 共 4 頁
字號:
{
  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;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩精品91亚洲二区在线观看| 久久99久久久久| 亚洲成av人片一区二区三区| 麻豆freexxxx性91精品| 99久久99久久免费精品蜜臀| 欧美一级片免费看| 中文一区二区在线观看| 日本在线不卡视频| 一本一道久久a久久精品| 欧美电影免费提供在线观看| 亚洲制服丝袜在线| 成人99免费视频| 精品久久国产字幕高潮| 亚洲曰韩产成在线| 美女mm1313爽爽久久久蜜臀| 伊人一区二区三区| 国产亚洲一区二区在线观看| 午夜影院在线观看欧美| 成人福利视频网站| 精品国产凹凸成av人网站| 一区二区三区精品久久久| 成人免费视频视频在线观看免费 | 亚洲色图一区二区三区| 激情图片小说一区| 日韩一级高清毛片| 日韩高清在线一区| 欧美人妇做爰xxxⅹ性高电影| 亚洲精品欧美激情| 色婷婷亚洲婷婷| 亚洲免费观看高清完整版在线观看熊| 国产激情精品久久久第一区二区| 欧美电影免费观看高清完整版| 人人狠狠综合久久亚洲| 国产视频一区二区三区在线观看| 日韩不卡一二三区| 欧美刺激午夜性久久久久久久| 日韩不卡手机在线v区| 欧美一区二区播放| 麻豆精品一区二区| 久久先锋影音av鲁色资源| 激情综合五月婷婷| 久久蜜桃一区二区| 岛国一区二区三区| 亚洲欧美日韩国产综合| 在线免费观看视频一区| 亚洲裸体在线观看| 欧美在线观看视频在线| 三级欧美韩日大片在线看| 欧美一区二区三区免费大片| 裸体在线国模精品偷拍| 久久久久久久久久久电影| 国产99久久久国产精品潘金| 中文子幕无线码一区tr| 色综合欧美在线视频区| 日韩中文字幕亚洲一区二区va在线| 欧美一区二区精美| 国产精品99久久久久久久vr| 中文字幕日韩欧美一区二区三区| 一本大道久久a久久精二百| 久久久久久电影| 综合激情网...| 日韩av一区二区三区四区| 国内精品久久久久影院一蜜桃| 久久蜜桃av一区精品变态类天堂| 成人午夜碰碰视频| 亚洲一区二区三区四区中文字幕| 欧美伦理视频网站| 国产一区不卡精品| 综合自拍亚洲综合图不卡区| 精品视频一区三区九区| 蜜桃视频免费观看一区| 国产精品国产三级国产普通话99 | 欧美国产在线观看| 天天色天天爱天天射综合| 国产精品99久久不卡二区| 日韩一区二区中文字幕| 蜜桃免费网站一区二区三区| 国产精品美女久久久久久| 色悠悠亚洲一区二区| 免费在线看成人av| 亚洲日本一区二区三区| 精品久久久三级丝袜| 97久久精品人人做人人爽50路| 男人操女人的视频在线观看欧美| 国产精品理论片在线观看| 欧美日韩免费高清一区色橹橹| 国产乱人伦偷精品视频免下载| 亚洲一区二区三区自拍| 中文字幕不卡三区| 精品精品国产高清a毛片牛牛| 一本色道久久综合亚洲aⅴ蜜桃| 久久精品久久综合| 亚洲国产一区在线观看| 最近中文字幕一区二区三区| 久久久精品2019中文字幕之3| 欧美精品18+| 91极品视觉盛宴| av在线播放一区二区三区| 国产麻豆午夜三级精品| 久久国产福利国产秒拍| 亚洲va韩国va欧美va精品| 国产精品久久久久久福利一牛影视 | 久久精品免费看| 亚洲制服丝袜av| 中文字幕制服丝袜一区二区三区| 久久影视一区二区| 欧美精品日日鲁夜夜添| 色婷婷综合激情| 91视视频在线直接观看在线看网页在线看 | 波多野洁衣一区| 激情深爱一区二区| 极品少妇一区二区| 国产一区二区三区| 国产精品一级片| 国产成人在线色| 国产成人av一区二区三区在线观看| 久久爱www久久做| 久久精品国产亚洲高清剧情介绍 | 亚洲视频免费看| 一区二区中文视频| 亚洲私人影院在线观看| 最新不卡av在线| 亚洲一区二区三区四区的| 亚洲自拍偷拍综合| 视频一区二区欧美| 日本欧美久久久久免费播放网| 婷婷久久综合九色综合伊人色| 日韩精品一级二级| 激情综合色丁香一区二区| 国产露脸91国语对白| 成人精品视频一区二区三区 | 国产盗摄视频一区二区三区| 国产乱码精品一区二区三区五月婷 | 国产精品123| 成人美女视频在线看| 欧美综合在线视频| 欧美一级日韩一级| 国产网红主播福利一区二区| 18欧美乱大交hd1984| 亚洲一区二区欧美| 美女免费视频一区二区| 粉嫩av亚洲一区二区图片| 99精品偷自拍| 欧美嫩在线观看| 欧美激情一区二区三区蜜桃视频| 亚洲色图第一区| 麻豆免费精品视频| 97超碰欧美中文字幕| 欧美性猛交xxxxxx富婆| 欧美mv和日韩mv的网站| 国产精品久久免费看| 日日噜噜夜夜狠狠视频欧美人| 国产精品一区二区三区四区| 91免费观看视频| 精品少妇一区二区三区在线视频| 国产精品色呦呦| 亚洲v日本v欧美v久久精品| 国产精品羞羞答答xxdd| 欧美日韩卡一卡二| 日本一区二区在线不卡| 日韩专区一卡二卡| 成人高清视频在线| 日韩写真欧美这视频| 亚洲欧美成人一区二区三区| 裸体健美xxxx欧美裸体表演| 色先锋久久av资源部| 精品sm捆绑视频| 亚洲成年人影院| 床上的激情91.| 日韩欧美国产综合在线一区二区三区| 中文字幕久久午夜不卡| 麻豆一区二区99久久久久| 91精品1区2区| 国产精品久久三| 国产成人av一区| 欧美成人女星排行榜| 亚洲va韩国va欧美va精品 | 欧美乱妇一区二区三区不卡视频| 久久久久久久av麻豆果冻| 日韩国产欧美在线视频| 色综合视频在线观看| 国产农村妇女精品| 国产美女在线精品| 欧美不卡一二三| 免费在线欧美视频| 777奇米四色成人影色区| 悠悠色在线精品| 91同城在线观看| 国产精品久久久久影视| 国产精品一区二区不卡| www国产亚洲精品久久麻豆| 男人的天堂久久精品| 欧美一区二区三区免费视频| 午夜久久久久久| 欧美日韩三级在线| 五月天激情综合网| 欧美精选一区二区| 日本不卡123| 日韩视频免费直播| 久久精品久久久精品美女|