diff options
Diffstat (limited to 'src/variant.h')
-rw-r--r-- | src/variant.h | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/src/variant.h b/src/variant.h index 2b88efe..a4f09af 100644 --- a/src/variant.h +++ b/src/variant.h | |||
@@ -10,7 +10,6 @@ | |||
10 | 10 | ||
11 | #include <bu/string.h> | 11 | #include <bu/string.h> |
12 | #include <typeinfo> | 12 | #include <typeinfo> |
13 | #include <bu/membuf.h> | ||
14 | #include <bu/formatter.h> | 13 | #include <bu/formatter.h> |
15 | 14 | ||
16 | namespace Bu | 15 | namespace Bu |
@@ -26,9 +25,9 @@ namespace Bu | |||
26 | VariantTypeRoot(); | 25 | VariantTypeRoot(); |
27 | virtual ~VariantTypeRoot(); | 26 | virtual ~VariantTypeRoot(); |
28 | 27 | ||
29 | virtual Bu::String toString() const=0; | ||
30 | virtual const std::type_info &getType() const=0; | 28 | virtual const std::type_info &getType() const=0; |
31 | virtual VariantTypeRoot *clone() const=0; | 29 | virtual VariantTypeRoot *clone() const=0; |
30 | virtual void format( Bu::Formatter &f ) const=0; | ||
32 | }; | 31 | }; |
33 | 32 | ||
34 | template<class t> | 33 | template<class t> |
@@ -65,12 +64,9 @@ namespace Bu | |||
65 | return data; | 64 | return data; |
66 | } | 65 | } |
67 | 66 | ||
68 | virtual Bu::String toString() const | 67 | virtual void format( Formatter &f ) const |
69 | { | 68 | { |
70 | MemBuf mb; | ||
71 | Formatter f( mb ); | ||
72 | f << data; | 69 | f << data; |
73 | return mb.getString(); | ||
74 | } | 70 | } |
75 | 71 | ||
76 | virtual const std::type_info &getType() const | 72 | virtual const std::type_info &getType() const |
@@ -111,6 +107,7 @@ namespace Bu | |||
111 | */ | 107 | */ |
112 | class Variant | 108 | class Variant |
113 | { | 109 | { |
110 | friend Bu::Formatter &operator<<( Bu::Formatter &f, const Variant &v ); | ||
114 | public: | 111 | public: |
115 | Variant(); | 112 | Variant(); |
116 | Variant( const Variant &v ); | 113 | Variant( const Variant &v ); |
@@ -123,8 +120,8 @@ namespace Bu | |||
123 | } | 120 | } |
124 | virtual ~Variant(); | 121 | virtual ~Variant(); |
125 | 122 | ||
126 | bool isSet() const; | ||
127 | Bu::String toString() const; | 123 | Bu::String toString() const; |
124 | bool isSet() const; | ||
128 | const std::type_info &getType() const; | 125 | const std::type_info &getType() const; |
129 | 126 | ||
130 | Variant &operator=( const Variant &rhs ); | 127 | Variant &operator=( const Variant &rhs ); |
@@ -219,17 +216,14 @@ namespace Bu | |||
219 | private: | 216 | private: |
220 | VariantTypeRoot *pCore; | 217 | VariantTypeRoot *pCore; |
221 | }; | 218 | }; |
222 | 219 | /* | |
223 | template<class t> | 220 | template<class t> |
224 | Bu::Formatter &operator<<( Bu::Formatter &f, const VariantType<t> &vt ) | 221 | Bu::Formatter &operator<<( Bu::Formatter &f, const VariantType<t> &vt ) |
225 | { | 222 | { |
226 | return f << vt.toString(); | 223 | return f << vt.getData; |
227 | } | 224 | }*/ |
228 | 225 | ||
229 | Bu::Formatter &operator<<( Bu::Formatter &f, const Variant &v ); | 226 | Bu::Formatter &operator<<( Bu::Formatter &f, const Variant &v ); |
230 | |||
231 | template<> Bu::String VariantType<int>::toString() const; | ||
232 | template<> Bu::String VariantType<bool>::toString() const; | ||
233 | }; | 227 | }; |
234 | 228 | ||
235 | #endif | 229 | #endif |