StringSerialize.h

Go to the documentation of this file.
00001 /*
00002  *    Copyright 2005-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 _OASYS_STRING_SERIALIZE_H_
00018 #define _OASYS_STRING_SERIALIZE_H_
00019 
00020 #include "Serialize.h"
00021 #include "../util/StringBuffer.h"
00022 
00023 namespace oasys {
00024 
00029 class StringSerialize : public SerializeAction {
00030 public:
00032     enum {
00033         INCLUDE_NAME    = 1 << 0, 
00034         INCLUDE_TYPE    = 1 << 1, 
00035         SCHEMA_ONLY     = 1 << 2, 
00036         DOT_SEPARATED   = 1 << 3, 
00037     };
00038 
00042     StringSerialize(context_t context, int options);
00043  
00047     int action(const SerializableObject* const_object)
00048     {
00049         SerializableObject* object = (SerializableObject*)const_object;
00050         return SerializeAction::action(object);
00051     }
00052     
00053     void process(const char* name, SerializableObject* const_object)
00054     {
00055         SerializableObject* object = (SerializableObject*)const_object;
00056         return SerializeAction::process(name, object);
00057     }
00058 
00062     const StringBuffer& buf() { return buf_; }
00063 
00066     void end_action();
00067     void process(const char* name, u_int64_t* i);
00068     void process(const char* name, u_int32_t* i);
00069     void process(const char* name, u_int16_t* i);
00070     void process(const char* name, u_int8_t* i);
00071     void process(const char* name, bool* b);
00072     void process(const char* name, u_char* bp, u_int32_t len);
00073     void process(const char* name, u_char** bp, u_int32_t* lenp, int flags);
00074     void process(const char* name, std::string* s);
00076 
00077 private:
00078     void add_preamble(const char* name, const char* type);
00079     
00080     StringBuffer buf_; 
00081     char         sep_; 
00082 };
00083 
00084 } // namespace oasys
00085 
00086 #endif /* _OASYS_STRING_SERIALIZE_H_ */

Generated on Sat Sep 8 08:43:34 2007 for DTN Reference Implementation by  doxygen 1.5.3