优秀的数据序列和还原类----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;
本文来自博客园,作者:{咏南中间件},转载请注明原文链接:https://www.cnblogs.com/hnxxcxg/p/6004607.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?