00001 #ifndef SERIALIZER_H__
00002 #define SERIALIZER_H__
00003
00004 #include <stlrt/atypes.h>
00005 #include <Comm/atracer.h>
00006 #include <stdlib.h>
00007 #include <map>
00008
00009 using namespace std;
00010
00011 #define TYPE_STR 1
00012 #define TYPE_INT 2
00013 #define TYPE_GLOBAL 3
00014
00015 #include <pluginconfig.h>
00016
00017 class PLUGINTOOLKIT_DECL PluginDataType {
00018 public:
00019 PluginDataType() {Type=TYPE_GLOBAL;};
00020
00021
00022 int Type;
00023 Int d_int;
00024 Str d_str;
00025 multimap <Str, PluginDataType> d_mmap;
00026
00027
00028 void setInt(const Str &name, const Int &val);
00029 void setStr(const Str &name, const Str &val);
00030 void set(const Str &name, const PluginDataType &val);
00031
00032
00033 Int getInt(const Str &name);
00034 Str getStr(const Str &name);
00035 PluginDataType get(const Str &name);
00036 list<PluginDataType> getList(const Str &name);
00037 inline PluginDataType operator [] (Str &name) {return get(name);};
00038 };
00039
00040 class PLUGINTOOLKIT_DECL Serializer {
00041 public:
00042 static Str serialize(const PluginDataType &data);
00043 static PluginDataType unserialize (const Str &input);
00044
00045
00046 private:
00047 static PluginDataType unserializeGlobal(const Str &input, int &token);
00048 static Str serializeGlobal(const PluginDataType &data);
00049 static Str serializeInt(const PluginDataType &data);
00050 static Str serializeStr(const PluginDataType &data);
00051 };
00052
00053 #endif