Changeset 693 for trunk/include/mapnik/value.hpp
- Timestamp:
- 04/12/08 11:22:27 (7 months ago)
- Files:
-
- 1 modified
-
trunk/include/mapnik/value.hpp (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/mapnik/value.hpp
r660 r693 40 40 namespace mapnik { 41 41 42 typedef boost::variant<bool,int,double,UnicodeString> value_base; 42 struct value_null 43 { 44 }; 45 46 typedef boost::variant<value_null,bool,int,double,UnicodeString> value_base; 43 47 44 48 namespace impl { … … 47 51 { 48 52 template <typename T, typename U> 49 bool operator() (const T &, const U & ) const53 bool operator() (const T &, const U &) const 50 54 { 51 55 return false; … … 73 77 return lhs == rhs; 74 78 } 79 80 bool operator() (value_null, value_null) const 81 { 82 return false; 83 } 75 84 }; 76 85 86 struct not_equals 87 : public boost::static_visitor<bool> 88 { 89 template <typename T, typename U> 90 bool operator() (const T &, const U &) const 91 { 92 return true; 93 } 94 95 template <typename T> 96 bool operator() (T lhs, T rhs) const 97 { 98 return lhs != rhs; 99 } 100 101 bool operator() (int lhs, double rhs) const 102 { 103 return lhs != rhs; 104 } 105 106 bool operator() (double lhs, int rhs) const 107 { 108 return lhs != rhs; 109 } 110 111 bool operator() (UnicodeString const& lhs, 112 UnicodeString const& rhs) const 113 { 114 return lhs != rhs; 115 } 116 117 bool operator() (value_null, value_null) const 118 { 119 return false; 120 } 121 122 template <typename T> 123 bool operator() (value_null, const T &) const 124 { 125 return false; 126 } 127 128 template <typename T> 129 bool operator() (const T &, value_null) const 130 { 131 return false; 132 } 133 }; 134 77 135 struct greater_than 78 136 : public boost::static_visitor<bool> 79 137 { 80 138 template <typename T, typename U> 81 bool operator()( const T &, const U &) const82 { 83 return false; 84 } 85 86 template <typename T> 87 bool operator()( T lhs, T rhs) const139 bool operator()(const T &, const U &) const 140 { 141 return false; 142 } 143 144 template <typename T> 145 bool operator()(T lhs, T rhs) const 88 146 { 89 147 return lhs > rhs; … … 103 161 { 104 162 return lhs > rhs; 163 } 164 165 bool operator() (value_null, value_null) const 166 { 167 return false; 105 168 } 106 169 }; … … 110 173 { 111 174 template <typename T, typename U> 112 bool operator()( const T &, const U &) const175 bool operator()(const T &, const U &) const 113 176 { 114 177 return false; … … 131 194 } 132 195 133 bool operator() (UnicodeString const& lhs, UnicodeString const& rhs ) const196 bool operator() (UnicodeString const& lhs, UnicodeString const& rhs) const 134 197 { 135 198 return lhs >= rhs; 199 } 200 201 bool operator() (value_null, value_null) const 202 { 203 return false; 136 204 } 137 205 }; … … 141 209 { 142 210 template <typename T, typename U> 143 bool operator()( const T &, const U &) const144 { 145 return false; 146 } 147 148 template <typename T> 149 bool operator()( T lhs,Trhs) const211 bool operator()(const T &, const U &) const 212 { 213 return false; 214 } 215 216 template <typename T> 217 bool operator()(T lhs, T rhs) const 150 218 { 151 219 return lhs < rhs; … … 162 230 } 163 231 164 bool operator()( UnicodeString const& lhs,165 UnicodeString const& rhs ) const232 bool operator()(UnicodeString const& lhs, 233 UnicodeString const& rhs ) const 166 234 { 167 235 return lhs < rhs; 236 } 237 238 bool operator() (value_null, value_null) const 239 { 240 return false; 168 241 } 169 242 }; … … 173 246 { 174 247 template <typename T, typename U> 175 bool operator()( const T &, const U &) const176 { 177 return false; 178 } 179 180 template <typename T> 181 bool operator()(T lhs, T rhs ) const248 bool operator()(const T &, const U &) const 249 { 250 return false; 251 } 252 253 template <typename T> 254 bool operator()(T lhs, T rhs) const 182 255 { 183 256 return lhs <= rhs; … … 195 268 196 269 template <typename T> 197 bool operator()( UnicodeString const& lhs,198 UnicodeString const& rhs ) const270 bool operator()(UnicodeString const& lhs, 271 UnicodeString const& rhs ) const 199 272 { 200 273 return lhs <= rhs; 274 } 275 276 bool operator() (value_null, value_null) const 277 { 278 return false; 201 279 } 202 280 }; … … 387 465 return ss.str(); 388 466 } 389 }; 467 468 std::string operator() (value_null const& val) const 469 { 470 return ""; 471 } 472 }; 390 473 391 474 struct to_unicode : public boost::static_visitor<UnicodeString> … … 411 494 out << std::setprecision(16) << val; 412 495 return UnicodeString(out.str().c_str()); 496 } 497 498 UnicodeString operator() (value_null const& val) const 499 { 500 return UnicodeString(""); 413 501 } 414 502 }; … … 456 544 return ss.str(); 457 545 } 546 547 std::string operator() (value_null const& val) const 548 { 549 return "null"; 550 } 458 551 }; 459 552 } 460 553 461 554 class value 462 555 { … … 469 562 public: 470 563 value () 471 : base_( 0) {}564 : base_(value_null()) {} 472 565 473 566 template <typename T> value(T _val_) … … 481 574 bool operator!=(value const& other) const 482 575 { 483 return !(boost::apply_visitor(impl::equals(),base_,other.base_));576 return boost::apply_visitor(impl::not_equals(),base_,other.base_); 484 577 } 485 578
