• 优秀的数据序列和还原类----TSimpleMsgPack


    优秀的数据序列和还原类----TSimpleMsgPack

    TSimpleMsgPack是D10天地弦的作品。

    优点:至简,就一个单元文件实现,不需要引用其他单元。

    缺点:不是标准的MSGPACK实现,不能跨语言兼容。

    所以:TSimpleMsgPack只能用于DELPHI开发,不能用于其他语言。

    而QDAC的QMsgPack却是标准的MSGPACK实现,能跨语言兼容。

    有了它,从此数据的序列和还原不再是梦魔。

    适用极广:可以适用于所有版本的DELPHI,不论D7还是最新的XE10.1,都支持。激动!

    封装极简:完全独立的一个单元即可,不需引用任何其它的单元。

    用法极简:调用非常简单。

    其支持的序列的数据格式非常丰富。

    下面列出该类的一些常用的接口方法:

    procedure LoadBinaryFromStream(pvStream: TStream; pvLen: cardinal = 0);
    procedure SaveBinaryToStream(pvStream:TStream);

    procedure LoadBinaryFromFile(pvFileName:String);
    procedure SaveBinaryToFile(pvFileName:String);

    procedure EncodeToStream(pvStream:TStream);
    procedure EncodeToFile(pvFileName:string);


    procedure DecodeFromStream(pvStream:TStream);
    procedure DecodeFromFile(pvFileName:string);

    function EncodeToBytes: TBytes;
    procedure DecodeFromBytes(pvBytes:TBytes);

    function Add(pvNameKey, pvValue: string): TSimpleMsgPack; overload;
    function Add(pvNameKey: string; pvValue: Int64): TSimpleMsgPack; overload;
    function Add(pvNameKey: string; pvValue: TBytes): TSimpleMsgPack; overload;
    function Add(pvNameKey: String): TSimpleMsgPack; overload;
    function Add():TSimpleMsgPack; overload;

    function ForcePathObject(pvPath:string): TSimpleMsgPack;

    /// <summary>
    /// remove and free object
    /// false : object is not found!
    /// </summary>
    function DeleteObject(pvPath:String):Boolean;

    property AsInteger:Int64 read getAsInteger write setAsInteger;
    property AsString:string read getAsString write setAsString;
    property AsBoolean: Boolean read GetAsBoolean write SetAsBoolean;
    property AsFloat: Double read GetAsFloat write SetAsFloat;
    property AsSingle: Single read GetAsSingle write SetAsSingle;
    property AsDateTime: TDateTime read GetAsDateTime write SetAsDateTime;
    property AsVariant: Variant read GetAsVariant write SetAsVariant;

    property AsBytes: TBytes read GetAsBytes write SetAsBytes;

    property O[pvPath: String]: TSimpleMsgPack read GetO write SetO;
    property S[pvPath: String]: string read GetS write SetS;
    property I[pvPath: String]: Int64 read GetI write SetI;
    property B[pvPath: String]: Boolean read GetB write SetB;
    property D[pvPath: String]: Double read GetD write SetD;

    property Items[AIndex: Integer]: TSimpleMsgPack read GetItems; default;

  • 相关阅读:
    正态分布与中心极限定理
    超几何分布与二项分布及其期望
    cf492E. Vanya and Field(扩展欧几里得)
    ZR#317.【18 提高 2】A(计算几何 二分)
    小米OJ刷题日志
    cf519D. A and B and Interesting Substrings(前缀和)
    cf519C. A and B and Team Training(找规律)
    BZOJ2118: 墨墨的等式(最短路 数论)
    Service生命周期图
    python2.7中使用mysql (windows XP)
  • 原文地址:https://www.cnblogs.com/hnxxcxg/p/6004607.html
Copyright © 2020-2023  润新知