KeySerialize.h

Go to the documentation of this file.
00001 /*
00002  *    Copyright 2006 Intel Corporation
00003  * 
00004  *    Licensed under the Apache License, Version 2.0 (the "License");
00005  *    you may not use this file except in compliance with the License.
00006  *    You may obtain a copy of the License at
00007  * 
00008  *        http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  *    Unless required by applicable law or agreed to in writing, software
00011  *    distributed under the License is distributed on an "AS IS" BASIS,
00012  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  *    See the License for the specific language governing permissions and
00014  *    limitations under the License.
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 } // namespace oasys
00105 
00106 #endif /* __KEYSERIALIZE_H__ */

Generated on Thu Jun 7 16:56:50 2007 for DTN Reference Implementation by  doxygen 1.5.1