5 #ifndef _iqxmlrpc_value_type_h_
6 #define _iqxmlrpc_value_type_h_
19 #pragma warning(disable: 4275)
26 class Value_type_visitor;
27 typedef util::ExplicitPtr<Value*> Value_ptr;
42 virtual const std::string& type_name()
const = 0;
54 const std::string& type_name()
const;
66 Scalar(
const T& t ): value_(t) {}
67 Scalar<T>* clone()
const {
return new Scalar<T>(value_); }
69 void apply_visitor(Value_type_visitor&)
const;
70 const std::string& type_name()
const;
72 const T& value()
const {
return value_; }
73 T& value() {
return value_; }
78 #pragma warning(disable: 4251)
83 typedef std::vector<Value*> Val_vector;
84 typedef Val_vector::iterator iterator;
87 friend class Array_inserter;
103 Exception(
"Array: index out of range." ) {}
116 void swap(
Array&) throw();
117 Array* clone() const;
118 const std::
string& type_name() const;
121 size_t size()
const {
return values.size(); }
123 const Value& operator [](
unsigned i )
const
126 return (*values.at(i));
128 catch(
const std::out_of_range& )
130 throw Out_of_range();
134 Value& operator [](
unsigned i )
137 return (*values.at(i));
139 catch(
const std::out_of_range& )
141 throw Out_of_range();
145 void push_back(
const Value& );
146 void push_back( Value_ptr );
152 void assign( In first, In last );
154 Array::const_iterator begin()
const;
155 Array::const_iterator end()
const;
161 public std::iterator<std::bidirectional_iterator_tag, Value>
163 Array::Val_vector::const_iterator i;
170 const Value& operator *()
const {
return *(*i); }
171 const Value* operator ->()
const {
return *i; }
186 return !(*
this == ci );
192 return values.begin();
210 Exception(
"Struct: field '" + f +
"' not exist." ) {}
214 typedef std::map<std::string, Value*> Value_stor;
215 class Struct_inserter;
216 friend class Struct_inserter;
221 typedef Value_stor::const_iterator const_iterator;
222 typedef Value_stor::iterator iterator;
230 void swap(
Struct&) throw();
232 const std::
string& type_name() const;
236 bool has_field( const std::
string& ) const;
238 const
Value& operator []( const std::
string& ) const;
239 Value& operator []( const std::
string& );
242 void insert( const std::
string&,
Value_ptr );
243 void insert( const std::
string&, const
Value& );
245 const_iterator begin()
const {
return values.begin(); }
246 const_iterator end()
const {
return values.end(); }
248 const_iterator find(
const std::string& key )
const {
return values.find(key); }
249 iterator find(
const std::string& key ) {
return values.find(key); }
251 void erase(
const std::string& key ) { values.erase(key); }
255 #pragma warning(disable: 4251)
265 Exception(
"Malformed base64 format." ) {}
269 static const char base64_alpha[64];
272 mutable std::string base64;
276 static Binary_data* from_base64(
const std::string& );
278 static Binary_data* from_data(
const std::string& );
280 static Binary_data* from_data(
const char*,
size_t size );
283 const std::string& get_base64()
const;
285 const std::string& get_data()
const;
288 const std::string& type_name()
const;
292 class End_of_data {};
296 void add_base64_char(
int idx )
const;
299 char get_idx(
char );
300 void decode_four(
const std::string& );
312 Exception(
"Malformed date-time format." ) {}
317 mutable std::string cache;
321 explicit Date_time(
const std::string& dateTime_iso8601 );
324 const struct tm& get_tm()
const {
return tm_; }
325 const std::string& to_string()
const;
328 const std::string& type_name()
const;