00001 #ifndef LUX_DOCUMENTSERIALIZER_H
00002 #define LUX_DOCUMENTSERIALIZER_H
00003
00004 #include "lux/lux.h"
00005 #include "document.h"
00006 #include "document_definition.pb.h"
00007 #include <string>
00008 #include <map>
00009
00010 #define EXTID "_ID"
00011 #define FIELD_SEP ":"
00012 #define FIELDS_SEP ""
00013
00014 namespace Lux {
00015
00016 typedef std::map< std::string, std::string > StrMap;
00017 typedef StrMap::iterator SMItr;
00018
00019 class DocumentSerializer {
00020 public:
00021 DocumentSerializer(void) {}
00022 DocumentSerializer(Config::Document &dd);
00023 ~DocumentSerializer(void) {}
00024 std::string pack(const Document &doc, bool disp_only = false);
00025 Document unpack(char *data);
00026
00027 private:
00028 StrMap disp_field_map_;
00029
00030 std::string serialize_field(std::string name, std::string val)
00031 {
00032 return name + FIELD_SEP + val + FIELDS_SEP;
00033 }
00034 };
00035
00036 }
00037
00038 #endif