From 7a6030118f448d9e07fa513b62a3fce11c733e3e Mon Sep 17 00:00:00 2001 From: WangQiang <807319473@qq.com> Date: Fri, 23 Oct 2015 09:45:19 +0000 Subject: [PATCH] =?UTF-8?q?TinyConfig=20=20Flash=E6=93=8D=E4=BD=9C=20?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E9=80=9A=E8=BF=87=EF=BC=8C=E6=9C=AA=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Config.cpp | 10 ++++++++++ Config.h | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/Config.cpp b/Config.cpp index 66e1e764..1fd287be 100644 --- a/Config.cpp +++ b/Config.cpp @@ -236,3 +236,13 @@ void TConfig::LoadDefault() PingTime = 15; OfflineTime = 60; } + +void TConfig::Write(Stream& ms)const +{ + ms.Write((byte *)this, 0, sizeof(this[0])); +} + +void TConfig::Read(Stream& ms) +{ + memcpy((byte *)this, ms.GetBuffer(), sizeof(this[0])); +} diff --git a/Config.h b/Config.h index 6ba894dc..a58738a6 100644 --- a/Config.h +++ b/Config.h @@ -82,6 +82,10 @@ public: // 初始化,各字段为0 TConfig(); void LoadDefault(); + + // 序列化到消息数据流 + void Write(Stream& ms) const; + void Read(Stream& ms); }; #pragma pack(pop) // 恢复对齐状态