KeySerialize.h

Go to the documentation of this file.
00001 #ifndef __KEYSERIALIZE_H__
00002 #define __KEYSERIALIZE_H__
00003 
00004 #include "Serialize.h"
00005 #include "../util/ExpandableBuffer.h"
00006 
00007 namespace oasys {
00008 
00022 class KeyMarshal : public SerializeAction {
00023 public:
00024     KeyMarshal(ExpandableBuffer* buf,
00025                const char*       border = 0);
00026     
00028     void process(const char* name, u_int32_t* i);
00029     void process(const char* name, u_int16_t* i);
00030     void process(const char* name, u_int8_t* i);
00031     void process(const char* name, bool* b);
00032     void process(const char* name, u_char* bp, size_t len);
00033     void process(const char* name, u_char** bp, size_t* lenp, int flags);
00034     void process(const char* name, std::string* s);
00035     void process(const char* name, SerializableObject* object);
00036 
00037     void end_action();
00039 
00041     int action(const SerializableObject* object) {
00042         return SerializeAction::action(
00043             const_cast<SerializableObject*>(object));
00044     }
00045     
00046 private:
00047     ExpandableBuffer* buf_;
00048     const char*       border_;
00049 
00050     void process_int(u_int32_t i, size_t size, const char* format);
00051     void border();
00052 };
00053 
00057 class KeyUnmarshal : public SerializeAction {
00058 public:
00059     KeyUnmarshal(const char* buf,
00060                  size_t      buf_len,
00061                  const char* border = 0);
00062     
00064     void process(const char* name, u_int32_t* i);
00065     void process(const char* name, u_int16_t* i);
00066     void process(const char* name, u_int8_t* i);
00067     void process(const char* name, bool* b);
00068     void process(const char* name, u_char* bp, size_t len);
00069     void process(const char* name, u_char** bp, size_t* lenp, int flags);
00070     void process(const char* name, std::string* s);
00071     void process(const char* name, SerializableObject* object);
00072 
00074 private:
00075     const char* buf_;
00076     size_t      buf_len_;
00077     size_t      border_len_;
00078     size_t      cur_;
00079 
00080     u_int32_t process_int(size_t size);
00081     void border();
00082 };
00083 
00084 } // namespace oasys
00085 
00086 #endif /* __KEYSERIALIZE_H__ */

Generated on Fri Dec 22 14:47:59 2006 for DTN Reference Implementation by  doxygen 1.5.1