00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __KEYSERIALIZE_H__
00018 #define __KEYSERIALIZE_H__
00019
00020 #include "Serialize.h"
00021 #include "../util/ExpandableBuffer.h"
00022
00023 namespace oasys {
00024
00038 class KeyMarshal : public SerializeAction {
00039 public:
00040 KeyMarshal(ExpandableBuffer* buf,
00041 const char* border = 0);
00042
00044 void process(const char* name, u_int64_t* i);
00045 void process(const char* name, u_int32_t* i);
00046 void process(const char* name, u_int16_t* i);
00047 void process(const char* name, u_int8_t* i);
00048 void process(const char* name, bool* b);
00049 void process(const char* name, u_char* bp, u_int32_t len);
00050 void process(const char* name, u_char** bp, u_int32_t* lenp, int flags);
00051 void process(const char* name, std::string* s);
00052 void process(const char* name, SerializableObject* object);
00053
00054 void end_action();
00056
00058 int action(const SerializableObject* object) {
00059 return SerializeAction::action(
00060 const_cast<SerializableObject*>(object));
00061 }
00062
00063 private:
00064 ExpandableBuffer* buf_;
00065 const char* border_;
00066
00067 void process_int(u_int32_t i, u_int32_t size, const char* format);
00068 void process_int64(u_int64_t i, u_int32_t size, const char* format);
00069 void border();
00070 };
00071
00075 class KeyUnmarshal : public SerializeAction {
00076 public:
00077 KeyUnmarshal(const char* buf,
00078 u_int32_t buf_len,
00079 const char* border = 0);
00080
00082 void process(const char* name, u_int64_t* i);
00083 void process(const char* name, u_int32_t* i);
00084 void process(const char* name, u_int16_t* i);
00085 void process(const char* name, u_int8_t* i);
00086 void process(const char* name, bool* b);
00087 void process(const char* name, u_char* bp, u_int32_t len);
00088 void process(const char* name, u_char** bp, u_int32_t* lenp, int flags);
00089 void process(const char* name, std::string* s);
00090 void process(const char* name, SerializableObject* object);
00091
00093 private:
00094 const char* buf_;
00095 u_int32_t buf_len_;
00096 u_int32_t border_len_;
00097 u_int32_t cur_;
00098
00099 u_int32_t process_int(u_int32_t size);
00100 u_int64_t process_int64();
00101 void border();
00102 };
00103
00104 }
00105
00106 #endif