00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __WEOPTIONS_H__
00021 #define __WEOPTIONS_H__
00022 #include <string>
00023 #include <boost/serialization/map.hpp>
00024 #include <boost/serialization/assume_abstract.hpp>
00025 #include <boost/variant.hpp>
00026 #include <boost/serialization/variant.hpp>
00027
00028 using namespace std;
00029
00030 typedef boost::variant< char,
00031 unsigned char,
00032 int,
00033 unsigned int,
00034 long,
00035 unsigned long,
00036 bool,
00037 double,
00038 string> WeOptionVal;
00039
00048 class WeOption
00049 {
00050 public:
00051 WeOption() { empty = true; };
00052 WeOption(string nm) { name = nm; empty = true; };
00053 ~WeOption() {};
00054
00056
00057 const string &Name(void) const { return(name); };
00058 void Name(const string &nm) { name = nm; };
00060
00062
00063
00064 template <typename T>
00065 void GetValue(T& dt)
00066 { dt = boost::get<T>(val); };
00067 template <typename T>
00068 void SetValue(T dt)
00069 { val = dt; empty = false; };
00071
00072 bool IsEmpty(void) { return empty; };
00073 string GetTypeName(void) { return val.type().name();};
00074 const std::type_info& GetType(void) const { return val.type(); };
00075
00077 WeOption& operator=(WeOption& cpy)
00078 { name = cpy.name;
00079 val = cpy.val;
00080 empty = cpy.empty;
00081 return *this; };
00082
00083 #ifndef __DOXYGEN__
00084 protected:
00085 string name;
00086 WeOptionVal val;
00087 bool empty;
00088 #endif //__DOXYGEN__
00089
00090 private:
00091 DECLARE_SERIALIZATOR
00092 {
00093 ar & BOOST_SERIALIZATION_NVP(name);
00094 ar & BOOST_SERIALIZATION_NVP(val);
00095 empty = false;
00096 };
00097 };
00098
00099 BOOST_CLASS_TRACKING(WeOption, boost::serialization::track_never)
00100
00101 typedef map<string, WeOption*> WeOptions;
00102
00111 class iweOptionsProvider
00112 {
00113 public:
00114 iweOptionsProvider() {};
00115 virtual ~iweOptionsProvider() {};
00116
00117 virtual WeOption& Option(const string& name) = 0;
00118 virtual bool IsSet(const string& name) = 0;
00119 virtual void Option(const string& name, WeOptionVal val) = 0;
00120 virtual void Erase(const string& name)
00121 {
00122 WeOptions::iterator it;
00123 it = options.find(name);
00124 if (it != options.end()) {
00125 options.erase(it);
00126 }
00127 };
00128
00129 #ifndef __DOXYGEN__
00130 protected:
00131 WeOptions options;
00132 #endif //__DOXYGEN__
00133
00134 private:
00135 DECLARE_SERIALIZATOR
00136 {
00137 ar & BOOST_SERIALIZATION_NVP(options);
00138 };
00139 };
00140
00142
00144 extern string weoTransport;
00145 extern string weoParser;
00146 extern string weoFollowLinks;
00147 extern string weoLoadImages;
00148 extern string weoLoadScripts;
00149 extern string weoLoadFrames;
00150 extern string weoLoadIframes;
00151 extern string weoCollapseSpaces;
00152 extern string weoStayInDomain;
00153 extern string weoStayInHost;
00154 extern string weoStayInDir;
00155 extern string weoAutoProcess;
00156 extern string weoCheckForLoops;
00157
00158
00159 #endif //__WEOPTIONS_H__