优秀的数据序列和还原类----TSimpleMsgPack
Posted 咏南中间件和开发框架
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了优秀的数据序列和还原类----TSimpleMsgPack相关的知识,希望对你有一定的参考价值。
优秀的数据序列和还原类----TSimpleMsgPack
有了它,从此数据的序列和还原不再是梦魔。
适用极广:可以适用于所有版本的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;
以上是关于优秀的数据序列和还原类----TSimpleMsgPack的主要内容,如果未能解决你的问题,请参考以下文章