1 #ifndef DATOR_H_INCLUDED
\r
2 #define DATOR_H_INCLUDED
\r
4 #include "mmanager.h"
\r
6 class BaseDator : public IMMObject
\r
10 BaseDator(BaseDator &b){(*this)=b;}
\r
12 virtual BaseDator &operator =(std::string &s)=0;
\r
13 virtual BaseDator &operator +=(std::string &s)=0;
\r
14 virtual BaseDator &operator -=(std::string &s)=0;
\r
15 virtual bool operator ==(std::string &s)=0;
\r
16 virtual bool operator !=(std::string &s)=0;
\r
18 virtual bool hasMultipleValues()=0;
\r
20 virtual operator std::string()=0;
\r
24 class Dator : public BaseDator
\r
28 T toVal(std::string &s)
\r
30 std::stringstream str;
\r
31 str.unsetf(std::ios::skipws);
\r
37 std::string toString(T &val)
\r
39 std::stringstream str;
\r
40 str.unsetf(std::ios::skipws);
\r
47 Dator(T& t) : target(t) {}
\r
48 BaseDator &operator =(std::string &s) { target=toVal(s); return *this; }
\r
49 BaseDator &operator +=(std::string &s) { target+=toVal(s); return *this; }
\r
50 BaseDator &operator -=(std::string &s) { target-=toVal(s); return *this; }
\r
51 bool operator ==(std::string &s) { return (s==(std::string)(*this)); }
\r
52 bool operator !=(std::string &s) { return (s!=(std::string)(*this)); }
\r
53 operator std::string() { return toString(target); }
\r
55 bool hasMultipleValues() { return false; }
\r
61 class ListDator : public BaseDator
\r
64 std::list<T> &values;
\r
65 T toVal(std::string &s)
\r
67 std::stringstream str;
\r
68 str.unsetf(std::ios::skipws);
\r
74 std::string toString(T &val)
\r
76 std::stringstream str;
\r
77 str.unsetf(std::ios::skipws);
\r
84 ListDator(std::list<T> &v) : values(v) { }
\r
85 BaseDator &operator =(std::string &s) { values.clear(); values.push_back(toVal(s)); return *this; }
\r
86 BaseDator &operator +=(std::string &s) { values.push_back(toVal(s)); return *this; }
\r
87 BaseDator &operator -=(std::string &s) { values.remove(toVal(s)); return *this; }
\r
88 bool operator ==(std::string &s) { return (std::find(values.begin(),values.end(),toVal(s))!=values.end()); }
\r
89 bool operator !=(std::string &s) { return !((*this)==s); }
\r
91 operator std::string() { return toString(values.back()); }
\r
92 operator std::list<T>&() { return values; }
\r
94 bool hasMultipleValues(){return true;}
\r