34 #ifndef CARTOBASE_OBJECT_OBJECT_D_H
35 #error This header file must not be included directly, use <cartobase/object/object_d.h> instead.
38 #ifndef CARTOBASE_OBJECT_OBJECT_INTERNALS_H
39 #define CARTOBASE_OBJECT_OBJECT_INTERNALS_H
42 #ifndef DOXYGEN_HIDE_INTERNAL_CLASSES
47 template <
typename T,
bool B>
49 static inline Interface *
get( TypedObject<T> & );
56 static inline Interface *
get( TypedObject<T> &to )
58 return static_cast< Interface *
>( &to.getValue() );
65 static inline Interface *
get( TypedObject<T> &to )
77 template <
typename T,
bool B>
82 static inline bool isScalar(
const TypedObject<T> & )
87 static inline double getScalar(
const TypedObject<T> & )
89 throw std::runtime_error( std::string(
"Cannot convert object of "
91 + DataTypeCode<T>::name() +
" to scalar" );
95 static inline void setScalar( TypedObject<T> &,
double )
97 throw std::runtime_error( std::string(
"Cannot convert scalar to "
99 DataTypeCode<T>::name() );
102 static inline bool equals(
const TypedObject<T> & ,
103 const GenericObject & )
105 throw std::runtime_error( std::string(
"Cannot convert scalar to "
106 "object of type " ) +
107 DataTypeCode<T>::name() );
111 template <
typename T>
116 static inline bool isScalar(
const TypedObject<T> &
object )
118 return object.getValue().isScalar();
121 static inline double getScalar(
const TypedObject<T> &
object )
123 return object.getValue().getScalar();
126 static inline void setScalar( TypedObject<T> &
object,
double value )
128 object.getValue().setScalar( value );
131 static inline bool equals(
const TypedObject<T> & o1,
132 const GenericObject & o2 )
134 return o2.isScalar() && o1.getValue().getScalar() == o2.getScalar();
144 template <
typename T,
bool B>
149 static inline bool isString(
const TypedObject<T> & )
154 static inline std::string
getString(
const TypedObject<T> & )
156 throw std::runtime_error( std::string(
"Cannot convert object of type " )
157 + DataTypeCode<T>::name() +
" to string" );
158 return std::string();
161 static inline void setString( TypedObject<T> &,
const std::string & )
163 throw std::runtime_error( std::string(
"Cannot convert string to "
164 "object of type " ) +
165 DataTypeCode<T>::name() );
168 static inline bool equals(
const TypedObject<T> & ,
169 const GenericObject & )
171 throw std::runtime_error( std::string(
"Cannot convert string to "
172 "object of type " ) +
173 DataTypeCode<T>::name() );
177 template <
typename T>
182 static inline bool isString(
const TypedObject<T> &
object )
184 return object.getValue().isString();
187 static inline std::string
getString(
const TypedObject<T> &
object )
189 return object.getValue().getString();
193 const std::string &value )
195 object.getValue().setString( value );
198 static inline bool equals(
const TypedObject<T> & o1,
199 const GenericObject & o2 )
201 return o2.isString() && o1.getValue().getString() == o2.getString();
211 template <
typename T,
bool B>
215 static inline size_t size(
const TypedObject<T> & )
217 throw std::runtime_error( std::string(
"cannot get size of object of "
219 ) + DataTypeCode<T>::name() );
224 template <
typename T>
228 static inline size_t size(
const TypedObject<T> &
object )
230 return object.getValue().size();
240 template <
typename T,
bool B>
245 static inline bool isArray(
const TypedObject<T> & )
255 static inline bool hasItem(
const TypedObject<T> &,
int )
262 throw std::runtime_error( std::string(
"object of type " ) +
263 DataTypeCode<T>::name() +
" is not an Array" );
269 throw std::runtime_error( std::string(
"object of type " ) +
270 DataTypeCode<T>::name() +
" is not an Array" );
274 template <
typename T>
279 static inline bool isArray(
const TypedObject<T> &
object )
281 return object.getValue().isArray();
286 return object.getValue().isContiguous();
289 static inline bool hasItem(
const TypedObject<T> &
object,
int index )
291 return object.getValue().hasItem( index );
297 return object.getValue().getArrayItem( index );
303 object.getValue().setArrayItem( index, value );
314 template <
typename T,
bool B>
326 throw std::runtime_error( std::string(
"object of type " ) +
327 DataTypeCode<T>::name() +
328 " is not a DynArray" );
333 throw std::runtime_error( std::string(
"object of type " ) +
334 DataTypeCode<T>::name() +
335 " is not a DynArray" );
341 throw std::runtime_error( std::string(
"object of type " ) +
342 DataTypeCode<T>::name() +
343 " is not a DynArray" );
350 throw std::runtime_error( std::string(
"object of type " ) +
351 DataTypeCode<T>::name() +
352 " is not a DynArray" );
356 template <
typename T>
361 static inline bool isDynArray(
const TypedObject<T> &
object )
363 return object.getValue().isDynArray();
369 object.getValue().reserveArray( size );
375 object.getValue().resizeArray( size );
382 object.getValue().removeArrayItem( index );
387 int index, Object value )
389 object.getValue().insertArrayItem( index, value );
401 template <
typename T,
bool B>
412 const std::string &, Object & )
414 throw std::runtime_error( std::string(
"object of type " ) +
415 DataTypeCode<T>::name() +
" is not a "
421 const std::string &, Object )
423 throw std::runtime_error( std::string(
"object of type " ) +
424 DataTypeCode<T>::name() +
" is not a "
430 throw std::runtime_error( std::string(
"object of type " ) +
431 DataTypeCode<T>::name() +
" is not a "
436 static inline bool hasProperty(
const TypedObject<T> &,
const std::string & )
438 throw std::runtime_error( std::string(
"object of type " ) +
439 DataTypeCode<T>::name() +
" is not a "
446 throw std::runtime_error( std::string(
"object of type " ) +
447 DataTypeCode<T>::name() +
" is not a "
451 static inline bool equals(
const TypedObject<T> & ,
452 const GenericObject & )
454 throw std::runtime_error( std::string(
"object of type " ) +
455 DataTypeCode<T>::name() +
" is not a "
461 template <
typename T>
468 return object.getValue().isDictionary();
472 const std::string &key, Object & result )
474 return object.getValue().getProperty( key, result );
478 const std::string &key,
481 object.getValue().setProperty( key, value );
485 const std::string &key )
487 return object.getValue().removeProperty( key );
491 const std::string & key )
493 return object.getValue().hasProperty( key );
498 object.getValue().clearProperties();
501 static inline bool equals(
const TypedObject<T> & o1,
502 const GenericObject & o2 )
504 if( !o2.isDictionary() )
506 const T &
self = o1.getValue();
507 if(
self.size() != o2.size() )
509 Object it, other_value;
510 for( it=
self.objectIterator(); it->isValid(); it->next() )
514 other_value = o2.getProperty( it->key() );
515 if( it->currentValue() != other_value )
535 template <
typename T,
bool B>
547 throw std::runtime_error( std::string(
"object of type " ) +
548 DataTypeCode<T>::name() +
549 " is not iterable" );
553 static inline bool equals(
const TypedObject<T> & ,
554 const GenericObject & )
556 throw std::runtime_error( std::string(
"object of type " ) +
557 DataTypeCode<T>::name() +
558 " is not iterable" );
562 template <
typename T>
567 static inline bool isIterable(
const TypedObject<T> &
object )
569 return object.getValue().isIterable();
574 return object.getValue().objectIterator();
577 static inline bool equals(
const TypedObject<T> & o1,
578 const GenericObject & o2 )
580 if( !o2.isIterable() )
582 const T &
self = o1.getValue();
583 if( o1.size() != o2.size() )
587 it->isValid(); it->next(), it2->next() )
589 if( !it2->isValid() || it->currentValue() != it2->currentValue() )
604 template <
typename T,
bool B>
614 static inline bool isValid(
const TypedObject<T> & )
616 throw std::runtime_error( std::string(
"object of type " ) +
617 DataTypeCode<T>::name() +
618 " is not an iterator" );
624 throw std::runtime_error( std::string(
"object of type " ) +
625 DataTypeCode<T>::name() +
626 " is not an iterator" );
630 static inline void next( TypedObject<T> & )
632 throw std::runtime_error( std::string(
"object of type " ) +
633 DataTypeCode<T>::name() +
634 " is not an iterator" );
639 template <
typename T>
644 static inline bool isIterator(
const TypedObject<T> &
object )
646 return object.getValue().isIterator();
649 static inline bool isValid(
const TypedObject<T> &
object )
651 return object.getValue().isValid();
656 return object.getValue().currentValue();
659 static inline void next( TypedObject<T> &
object )
661 return object.getValue().next();
669 template <
typename T,
bool B>
679 static inline Object
keyObject(
const TypedObject<T> & )
681 throw std::runtime_error( std::string(
"object of type " ) +
682 DataTypeCode<T>::name() +
683 " is not a key iterator" );
688 template <
typename T>
695 return object.getValue().isKeyIterator();
698 static inline Object
keyObject(
const TypedObject<T> &
object )
700 return object.getValue().keyObject();
708 template <
typename T,
bool B>
718 static inline std::string
key(
const TypedObject<T> & )
720 throw std::runtime_error( std::string(
"object of type " ) +
721 DataTypeCode<T>::name() +
722 " is not a dictionary iterator" );
723 return std::string();
727 template <
typename T>
734 return object.getValue().isDictionaryIterator();
737 static inline std::string
key(
const TypedObject<T> &
object )
739 return object.getValue().key();
747 template <
typename T,
bool B>
757 static inline long intKey(
const TypedObject<T> & )
759 throw std::runtime_error( std::string(
"object of type " ) +
760 DataTypeCode<T>::name() +
761 " is not an int dictionary iterator" );
766 template <
typename T>
773 return object.getValue().isIntKeyIterator();
776 static inline long intKey(
const TypedObject<T> &
object )
778 return object.getValue().intKey();
788 template <
typename T,
bool B>
792 static inline bool isNone(
const TypedObject<T> & )
804 template <
typename T,
bool B>
807 static Object
object(
const T & );
810 template <
typename T,
bool B>
813 return Object(
static_cast<GenericObject *
>(
new ValueObject<T>( x ) ) );
816 template <
typename T>
819 static Object
object(
const T & );
822 template <
typename T>
825 return Object(
static_cast<GenericObject *
> ( x ) );
839 static inline bool isScalar(
const TypedObject<char> & )
844 static inline double getScalar(
const TypedObject<char> &to )
846 return to.getValue();
849 static inline void setScalar( TypedObject<char> &to,
double value )
851 to.getValue() =
static_cast<char>( value );
854 static inline bool equals(
const TypedObject<char> & o1,
855 const GenericObject & o2 )
857 return o2.isScalar() && o1.getValue() == o2.getScalar();
871 static inline bool isScalar(
const TypedObject<unsigned char> & )
876 static inline double getScalar(
const TypedObject<unsigned char> &to )
878 return to.getValue();
881 static inline void setScalar( TypedObject<unsigned char> &to,
884 to.getValue() =
static_cast<unsigned char>( value );
887 static inline bool equals(
const TypedObject<unsigned char> & o1,
888 const GenericObject & o2 )
890 return o2.isScalar() && o1.getValue() == o2.getScalar();
904 static inline bool isScalar(
const TypedObject<signed char> & )
909 static inline double getScalar(
const TypedObject<signed char> &to )
911 return to.getValue();
914 static inline void setScalar( TypedObject<signed char> &to,
double value )
916 to.getValue() =
static_cast<signed char>( value );
919 static inline bool equals(
const TypedObject<signed char> & o1,
920 const GenericObject & o2 )
922 return o2.isScalar() && o1.getValue() == o2.getScalar();
935 static inline bool isScalar(
const TypedObject<bool> & )
940 static inline double getScalar(
const TypedObject<bool> &to )
942 return to.getValue();
945 static inline void setScalar( TypedObject<bool> &to,
double value )
947 to.getValue() =
static_cast<bool>( value );
950 static inline bool equals(
const TypedObject<bool> & o1,
951 const GenericObject & o2 )
953 return o2.isScalar() && o1.getValue() == o2.getScalar();
967 static inline bool isScalar(
const TypedObject<unsigned short> & )
972 static inline double getScalar(
const TypedObject<unsigned short> &to )
974 return to.getValue();
977 static inline void setScalar( TypedObject<unsigned short> &to,
double value )
979 to.getValue() =
static_cast<unsigned short>( value );
982 static inline bool equals(
const TypedObject<unsigned short> & o1,
983 const GenericObject & o2 )
985 return o2.isScalar() && o1.getValue() == o2.getScalar();
999 static inline bool isScalar(
const TypedObject<short> & )
1004 static inline double getScalar(
const TypedObject<short> &to )
1006 return to.getValue();
1009 static inline void setScalar( TypedObject<short> &to,
double value )
1011 to.getValue() =
static_cast<short>( value );
1014 static inline bool equals(
const TypedObject<short> & o1,
1015 const GenericObject & o2 )
1017 return o2.isScalar() && o1.getValue() == o2.getScalar();
1030 static inline bool isScalar(
const TypedObject<unsigned> & )
1035 static inline double getScalar(
const TypedObject<unsigned> &to )
1037 return to.getValue();
1040 static inline void setScalar( TypedObject<unsigned> &to,
double value )
1042 to.getValue() =
static_cast<unsigned>( value );
1045 static inline bool equals(
const TypedObject<unsigned> & o1,
1046 const GenericObject & o2 )
1048 return o2.isScalar() && o1.getValue() == o2.getScalar();
1062 static inline bool isScalar(
const TypedObject<int> & )
1067 static inline double getScalar(
const TypedObject<int> &to )
1069 return to.getValue();
1072 static inline void setScalar( TypedObject<int> &to,
double value )
1074 to.getValue() =
static_cast<int>( value );
1077 static inline bool equals(
const TypedObject<int> & o1,
1078 const GenericObject & o2 )
1080 return o2.isScalar() && o1.getValue() == o2.getScalar();
1094 static inline bool isScalar(
const TypedObject<long> & )
1099 static inline double getScalar(
const TypedObject<long> &to )
1101 return to.getValue();
1104 static inline void setScalar( TypedObject<long> &to,
double value )
1106 to.getValue() =
static_cast<long>( value );
1109 static inline bool equals(
const TypedObject<long> & o1,
1110 const GenericObject & o2 )
1112 return o2.isScalar() && o1.getValue() == o2.getScalar();
1126 static inline bool isScalar(
const TypedObject<unsigned long> & )
1131 static inline double getScalar(
const TypedObject<unsigned long> &to )
1133 return to.getValue();
1136 static inline void setScalar( TypedObject<unsigned long> &to,
1139 to.getValue() =
static_cast<unsigned long>( value );
1142 static inline bool equals(
const TypedObject<unsigned long> & o1,
1143 const GenericObject & o2 )
1145 return o2.isScalar() && o1.getValue() == o2.getScalar();
1159 static inline bool isScalar(
const TypedObject<long long> & )
1164 static inline double getScalar(
const TypedObject<long long> &to )
1166 return to.getValue();
1169 static inline void setScalar( TypedObject<long long> &to,
double value )
1171 to.getValue() =
static_cast<long long>( value );
1174 static inline bool equals(
const TypedObject<long long> & o1,
1175 const GenericObject & o2 )
1177 return o2.isScalar() && o1.getValue() == o2.getScalar();
1191 static inline bool isScalar(
const TypedObject<unsigned long long> & )
1196 static inline double getScalar(
const TypedObject<unsigned long long> &to )
1198 return to.getValue();
1201 static inline void setScalar( TypedObject<unsigned long long> &to,
1204 to.getValue() =
static_cast<unsigned long long>( value );
1207 static inline bool equals(
const TypedObject<unsigned long long> & o1,
1208 const GenericObject & o2 )
1210 return o2.isScalar() && o1.getValue() == o2.getScalar();
1224 static inline bool isScalar(
const TypedObject<float> & )
1229 static inline double getScalar(
const TypedObject<float> &to )
1231 return to.getValue();
1234 static inline void setScalar( TypedObject<float> &to,
double value )
1236 to.getValue() =
static_cast<float>( value );
1239 static inline bool equals(
const TypedObject<float> & o1,
1240 const GenericObject & o2 )
1242 return o2.isScalar() && o1.getValue() == o2.getScalar();
1255 static inline bool isScalar(
const TypedObject<double> & )
1260 static inline double getScalar(
const TypedObject<double> &to )
1262 return to.getValue();
1265 static inline void setScalar( TypedObject<double> &to,
double value )
1267 to.getValue() = value;
1270 static inline bool equals(
const TypedObject<double> & o1,
1271 const GenericObject & o2 )
1273 return o2.isScalar() && o1.getValue() == o2.getScalar();
1287 static inline bool isScalar(
const TypedObject<std::string> & )
1292 static inline double getScalar(
const TypedObject<std::string> &to )
1299 static inline void setScalar( TypedObject<std::string> &to,
double value )
1304 static inline bool equals(
const TypedObject<std::string> & o1,
1305 const GenericObject & o2 )
1307 return o2.isString() && o1.getValue() == o2.getString();
1321 static inline bool isString(
const TypedObject< std::string> & )
1326 static inline std::string
getString(
const TypedObject<std::string> &to )
1328 return to.getValue();
1332 const std::string &value )
1334 to.getValue() = value;
1337 static inline bool equals(
const TypedObject<std::string> & o1,
1338 const GenericObject & o2 )
1340 return o2.isString() && o1.getValue() == o2.getString();
1355 const std::string &value )
1371 const std::string &value )
1379 TypedObject<unsigned char>
1389 const std::string &value )
1404 const std::string &value )
1412 TypedObject<unsigned short>
1422 const std::string &value )
1437 const std::string &value )
1452 const std::string &value )
1467 const std::string &value )
1475 TypedObject<unsigned long> &
1485 const std::string &value )
1500 const std::string &value )
1515 const std::string &value )
1528 template <
typename T>
1532 static inline size_t
1533 size(
const TypedObject<std::vector<T> > &
object )
1535 return object.getValue().size();
1542 template <
typename T>
1547 static inline bool isArray(
const TypedObject< std::vector<T> > & )
1553 const TypedObject< std::vector<T> > &
object )
1558 static inline bool hasItem(
const TypedObject< std::vector<T> > &
object,
1561 return index >= 0 && index <
object.getValue().size();
1564 static inline Object
1569 return Object::reference(
const_cast<T &
>
1570 (
object.getValue()[ index ] ) );
1574 int index, Object value )
1576 object.getValue()[ index ] = value->GenericObject::value<T>();
1584 template <
typename T>
1588 static inline bool isDynArray(
const TypedObject< std::vector<T> > & )
1597 object.getValue().reserve( size );
1604 object.getValue().resize( size );
1611 object.getValue().erase(
object.getValue().begin() + index );
1617 int index, Object value )
1620 object.getValue().insert(
object.getValue().begin() + index,
1621 value->GenericObject::value<T>() );
1623 object.getValue().insert(
object.getValue().end() + ( index + 1 ),
1624 value->GenericObject::value<T>() );
1631 template <
typename T>
1635 static inline bool isIterable(
const TypedObject< std::vector<T> > & )
1640 static inline Object
1643 static inline bool equals(
const TypedObject< std::vector<T> > & o1,
1644 const GenericObject & o2 )
1646 if( !o2.isIterable() )
1648 const std::vector<T> &
self = o1.getValue();
1649 if(
self.size() != o2.size() )
1652 for( it=o1.objectIterator(), it2=o2.objectIterator();
1653 it->isValid(); it->next(), it2->next() )
1655 if( !it2->isValid() || it->currentValue() != it2->currentValue() )
1664 template <
typename V>
1676 const typename V::const_iterator &end ) :
1686 template <
typename V>
1695 template <
typename V>
1698 return _iterator != _end;
1701 template <
typename V>
1705 return Object::reference(
const_cast<typename V::reference
>( *_iterator ) );
1714 template <
typename V>
1720 template <
typename T>
1722 (
const TypedObject<std::vector<T> > &
object )
1725 (
object.getValue().begin(),
1726 object.getValue().end() ) );
1739 false >::getArrayItem(
const TypedObject<std::vector<Object> > &
1742 return object.getValue()[ index ];
1748 false >::setArrayItem( TypedObject<std::vector<Object> > &
1749 object,
int index, Object value )
1751 object.getValue()[ index ] = value;
1760 insertArrayItem( TypedObject< std::vector<Object> > &
object,
1761 int index, Object value )
1764 object.getValue().insert(
object.getValue().begin() + index, value );
1766 object.getValue().insert(
object.getValue().end() + (index + 1), value );
1779 template <
typename T>
1783 static inline size_t
1784 size(
const TypedObject<std::set<T> > &
object )
1786 return object.getValue().size();
1793 template <
typename S>
1813 const typename S::const_iterator &end )
1823 template <
typename T>
1832 template <
typename T>
1837 static inline bool isIterable(
const TypedObject< std::set<T> > & )
1842 static inline Object
1846 const TypedObject< std::set<T> > & o1,
1847 const GenericObject & o2 )
1849 if( !o2.isIterable() )
1851 const std::set<T> &
self = o1.getValue();
1852 if(
self.size() != o2.size() )
1855 for( it2=o2.objectIterator(); it2->isValid(); it2->next() )
1857 value = it2->currentValue();
1862 const T & tval = value->value<T>();
1863 if(
self.find( tval ) ==
self.end() )
1877 template <
typename T>
inline
1880 (
const TypedObject<std::set<T> > &
object )
1882 return Object::value(
SetIterator< std::set<T> >(
object.getValue().begin(),
1883 object.getValue().end() ) );
1910 const std::set<Object>::const_iterator &end )
1915 std::set<Object>::const_iterator
_end;
1926 template <
typename T,
typename U>
1930 static inline size_t
1931 size(
const TypedObject<std::map<T, U> > &
object )
1933 return object.getValue().size();
1940 template <
typename T,
typename U>
1946 TypedObject< std::map<T, U> > & )
1951 static inline Object
1955 const TypedObject< std::map<T, U> > & o1,
1956 const GenericObject & o2 )
1958 if( !o2.isDictionary() )
1960 const std::map<T, U> &
self = o1.getValue();
1961 if(
self.size() != o2.size() )
1964 for( it=o1.objectIterator(); it->isValid(); it->next() )
1968 value = o2.getProperty( it->key() );
1969 if( it->currentValue() != value )
1982 template <
typename M>
1993 return Object::reference(
_iterator->second );
2002 return Object::reference(
_iterator->first );
2008 const typename M::const_iterator
2009 &end ) : IteratorInterface(),
2019 template <
typename T,
typename U>
2027 template <
typename T,
typename U>
inline
2030 (
const TypedObject<std::map<T, U> > &
object )
2032 return Object::value(
MapIterator< std::map<T, U> >
2033 (
object.getValue().begin(),
2034 object.getValue().end() ) );
2042 template <
typename T>
2048 TypedObject< std::map<T, Object> > & )
2053 static inline Object
2054 objectIterator(
const TypedObject<std::map<T, Object> > &
object );
2057 const TypedObject< std::map<T, Object> > & o1,
2058 const GenericObject & o2 )
2060 if( !o2.isIterable() )
2062 const std::map<T, Object> &
self = o1.getValue();
2063 if(
self.size() != o2.size() )
2065 typename std::map<T, Object>::const_iterator it;
2070 for( it=
self.begin(), it2=o2.objectIterator(); it!=
self.end();
2073 if( it->second != it2->currentValue() )
2081 template <
typename T>
2082 class MapIterator< std::map< T, Object > > :
public KeyIteratorInterface
2100 return Object::reference(
_iterator->first );
2104 MapIterator(
const typename std::map< T, Object >::const_iterator &begin,
2105 const typename std::map< T, Object >::const_iterator &end ) :
2106 IteratorInterface(),
2111 typename std::map< T, Object >::const_iterator
_end;
2115 template <
typename T>
inline
2118 (
const TypedObject<std::map<T, Object> > &
object )
2120 return Object::value(
MapIterator<std::map<T, Object> >(
object.getValue().begin(),
2121 object.getValue().end() ) );
2132 template <
typename T>
2138 TypedObject< std::map<std::string, T> > &)
2145 const std::string & key, Object & result )
2147 typename std::map<std::string, T>::const_iterator
2148 i =
object.getValue().find( key );
2149 if( i ==
object.getValue().end() )
2152 result = Object::reference(
const_cast<T &
>( i->second ) );
2158 const std::string & key, Object value )
2160 T & val = value->GenericObject::value<T>();
2161 object.getValue()[ key ] = val;
2166 const std::string & key )
2168 return object.getValue().erase( key );
2174 object.getValue().clear();
2179 object,
const std::string & key )
2181 return object.getValue().find( key ) !=
object.getValue().end();
2184 static bool equals(
const TypedObject<std::map<std::string, T> > &
2185 object,
const GenericObject & other )
2187 if( !other.isDictionary() )
2189 const std::map<std::string, T> &
self =
object.getValue();
2190 if(
self.size() != other.size() )
2192 Object it, other_value;
2193 for( it=
object.objectIterator(); it->isValid(); it->next() )
2197 other_value = other.getProperty( it->key() );
2198 if( it->currentValue() != other_value )
2213 template <
typename T>
2215 public KeyIteratorInterface,
public DictionaryIteratorInterface
2227 return Object::reference(
_iterator->second );
2242 return Object::reference(
_iterator->first );
2247 std::map< std::string, T >::const_iterator &begin,
2249 std::map< std::string, T >::const_iterator &end ) :
2250 IteratorInterface(),
2254 typename std::map< std::string, T >::const_iterator
_iterator;
2255 typename std::map< std::string, T >::const_iterator
_end;
2258 template <
typename T>
2264 TypedObject< std::map<std::string, T> > & )
2269 static inline Object
2270 objectIterator(
const TypedObject<std::map<std::string, T> > &
object );
2273 const TypedObject< std::map<std::string, T> > & o1,
2274 const GenericObject & o2 )
2276 if( !o2.isDictionary() )
2278 const std::map<std::string, T> &
self = o1.getValue();
2279 if(
self.size() != o2.size() )
2282 for( it=o1.objectIterator(); it->isValid(); it->next() )
2286 value = o2.getProperty( it->key() );
2287 if( it->currentValue() != value )
2301 template <
typename T>
inline
2304 (
const TypedObject<std::map<std::string, T> > &
object )
2306 return Object::value(
MapIterator<std::map<std::string, T> >
2307 (
object.getValue().begin(),
2308 object.getValue().end() ) );
2321 public KeyIteratorInterface,
public DictionaryIteratorInterface
2348 return Object::reference(
_iterator->first );
2352 MapIterator(
const std::map< std::string, Object >::const_iterator &begin,
2353 const std::map< std::string, Object >::const_iterator &end ) :
2354 IteratorInterface(), DictionaryIteratorInterface(),
2359 std::map< std::string, Object >::const_iterator
_end;
2369 TypedObject< std::map<std::string,
2375 static inline Object
2377 TypedObject<std::map<std::string, Object> > &
object );
2380 const TypedObject< std::map<std::string, Object> > & o1,
2381 const GenericObject & o2 )
2383 if( !o2.isDictionary() )
2385 const std::map<std::string, Object> &
self = o1.getValue();
2386 if(
self.size() != o2.size() )
2388 std::map<std::string, Object>::const_iterator it;
2390 for( it=
self.begin(); it!=
self.end(); ++it )
2394 value = o2.getProperty( it->first );
2395 if( it->second != value )
2412 (
const TypedObject<std::map<std::string, Object> > &
object )
2414 return Object::value(
MapIterator<std::map<std::string, Object> >
2415 (
object.getValue().begin(),
2416 object.getValue().end() ) );
2426 (
const TypedObject<std::map<std::string, Object> > &
object,
2427 const std::string & key, Object & result )
2429 std::map<std::string, Object>::const_iterator
2430 i =
object.getValue().find( key );
2431 if( i ==
object.getValue().end() )
2440 ( TypedObject<std::map<std::string, Object> > &
object,
2441 const std::string & key, Object value )
2443 object.getValue()[ key ] = value;
2454 template <
typename T>
2459 static inline bool isArray(
const TypedObject< std::map<int,T> > & )
2465 const TypedObject< std::map<int, T> > &
object )
2470 static inline bool hasItem(
const TypedObject< std::map<int, T> > &
object,
2473 const std::map<int,T> & val =
object.getValue();
2474 return val.find( index ) != val.end();
2477 static inline Object
2481 const std::map<int,T> & val =
object.getValue();
2482 typename std::map<int,T>::const_iterator i = val.find( index );
2483 if( i == val.end() )
2486 return Object::reference(
const_cast<T &
>( i->second ) );
2490 int index, Object value )
2492 object.getValue()[ index ] = value->GenericObject::value<T>();
2500 template <
typename T>
2504 static inline bool isDynArray(
const TypedObject< std::map<int,T> > & )
2523 object.getValue().erase( index );
2529 int index, Object value )
2531 object.getValue()[ index ] = value->GenericObject::value<T>();
2544 ArrayImpl< std::map<int,Object>,
2545 false >::getArrayItem(
const TypedObject<std::map<int,Object> > &
2548 const std::map<int,Object> & val =
object.getValue();
2549 std::map<int,Object>::const_iterator i = val.find( index );
2550 if( i == val.end() )
2558 false >::setArrayItem( TypedObject<std::map<int,Object> > &
2559 object,
int index, Object value )
2561 object.getValue()[ index ] = value;
2570 insertArrayItem( TypedObject< std::map<int,Object> > &
object,
2571 int index, Object value )
2573 object.getValue()[ index ] = value;
2582 public KeyIteratorInterface,
public IntKeyIteratorInterface
2609 return Object::reference(
_iterator->first );
2614 const std::map< int, Object >::const_iterator &end ) :
2615 IteratorInterface(), IntKeyIteratorInterface(),
2620 std::map< int, Object >::const_iterator
_end;
2630 TypedObject< std::map<
int,
2636 static inline Object
2638 TypedObject<std::map<int, Object> > &
object );
2641 const TypedObject< std::map<int, Object> > & o1,
2642 const GenericObject & o2 )
2644 const std::map<int, Object> &
self = o1.getValue();
2645 if(
self.size() != o2.size() )
2647 std::map<int, Object>::const_iterator it;
2648 Object o2it = o2.objectIterator();
2649 if( !o2it || !o2it->isValid() || !o2it->isIntKeyIterator() )
2651 for( it=
self.begin(); it!=
self.end(); ++it, o2it->next() )
2653 if( !o2it || !o2it->isValid() )
2657 if( it->first != o2it->intKey() )
2659 if( it->second != o2it->currentValue() )
2676 (
const TypedObject<std::map<int, Object> > &
object )
2678 return Object::value(
MapIterator<std::map<int, Object> >
2679 (
object.getValue().begin(),
2680 object.getValue().end() ) );
static Object getArrayItem(const TypedObject< T > &object, int index)
static bool isContiguous(const TypedObject< T > &object)
static void setArrayItem(TypedObject< T > &object, int index, Object value)
static bool hasItem(const TypedObject< T > &object, int index)
static bool isArray(const TypedObject< T > &object)
static void setArrayItem(TypedObject< std::map< int, T > > &object, int index, Object value)
static bool hasItem(const TypedObject< std::map< int, T > > &object, int index)
static bool isContiguous(const TypedObject< std::map< int, T > > &object)
static bool isArray(const TypedObject< std::map< int, T > > &)
static Object getArrayItem(const TypedObject< std::map< int, T > > &object, int index)
static Object getArrayItem(const TypedObject< std::vector< T > > &object, int index)
static bool isContiguous(const TypedObject< std::vector< T > > &object)
static bool isArray(const TypedObject< std::vector< T > > &)
static void setArrayItem(TypedObject< std::vector< T > > &object, int index, Object value)
static bool hasItem(const TypedObject< std::vector< T > > &object, int index)
static bool isArray(const TypedObject< T > &)
static void setArrayItem(TypedObject< T > &, int, Object)
static bool hasItem(const TypedObject< T > &, int)
static bool isContiguous(const TypedObject< T > &)
static Object getArrayItem(const TypedObject< T > &, int)
static bool hasProperty(const TypedObject< T > &object, const std::string &key)
static bool removeProperty(TypedObject< T > &object, const std::string &key)
static void setProperty(TypedObject< T > &object, const std::string &key, Object value)
static void clearProperties(TypedObject< T > &object)
static bool equals(const TypedObject< T > &o1, const GenericObject &o2)
static bool isDictionary(const TypedObject< T > &object)
static bool getProperty(const TypedObject< T > &object, const std::string &key, Object &result)
static bool removeProperty(TypedObject< std::map< std::string, T > > &object, const std::string &key)
static bool hasProperty(const TypedObject< std::map< std::string, T > > &object, const std::string &key)
static void clearProperties(TypedObject< std::map< std::string, T > > &object)
static bool getProperty(const TypedObject< std::map< std::string, T > > &object, const std::string &key, Object &result)
static bool equals(const TypedObject< std::map< std::string, T > > &object, const GenericObject &other)
static bool isDictionary(const TypedObject< std::map< std::string, T > > &)
static void setProperty(TypedObject< std::map< std::string, T > > &object, const std::string &key, Object value)
static void setProperty(TypedObject< T > &, const std::string &, Object)
static bool getProperty(const TypedObject< T > &, const std::string &, Object &)
static bool removeProperty(TypedObject< T > &, const std::string &)
static void clearProperties(TypedObject< T > &)
static bool hasProperty(const TypedObject< T > &, const std::string &)
static bool equals(const TypedObject< T > &, const GenericObject &)
static bool isDictionary(const TypedObject< T > &)
static bool isDictionaryIterator(const TypedObject< T > &object)
static std::string key(const TypedObject< T > &object)
static std::string key(const TypedObject< T > &)
static bool isDictionaryIterator(const TypedObject< T > &)
static void insertArrayItem(TypedObject< T > &object, int index, Object value)
static void removeArrayItem(TypedObject< T > &object, int index)
static void resizeArray(TypedObject< T > &object, size_t size)
static bool isDynArray(const TypedObject< T > &object)
static void reserveArray(TypedObject< T > &object, size_t size)
static void removeArrayItem(TypedObject< std::map< int, T > > &object, int index)
static void reserveArray(TypedObject< std::map< int, T > > &, size_t)
static void resizeArray(TypedObject< std::map< int, T > > &, size_t)
static void insertArrayItem(TypedObject< std::map< int, T > > &object, int index, Object value)
static bool isDynArray(const TypedObject< std::map< int, T > > &)
static void insertArrayItem(TypedObject< std::vector< T > > &object, int index, Object value)
static void reserveArray(TypedObject< std::vector< T > > &object, size_t size)
static bool isDynArray(const TypedObject< std::vector< T > > &)
static void removeArrayItem(TypedObject< std::vector< T > > &object, int index)
static void resizeArray(TypedObject< std::vector< T > > &object, size_t size)
static void insertArrayItem(TypedObject< T > &, int, Object)
static void resizeArray(TypedObject< T > &, size_t)
static void reserveArray(TypedObject< T > &, size_t)
static void removeArrayItem(TypedObject< T > &, int)
static bool isDynArray(const TypedObject< T > &)
static long intKey(const TypedObject< T > &object)
static bool isIntKeyIterator(const TypedObject< T > &object)
static long intKey(const TypedObject< T > &)
static bool isIntKeyIterator(const TypedObject< T > &)
static Object objectIterator(const TypedObject< T > &object)
static bool equals(const TypedObject< T > &o1, const GenericObject &o2)
static bool isIterable(const TypedObject< T > &object)
static bool isIterable(const TypedObject< std::map< T, Object > > &)
static bool equals(const TypedObject< std::map< T, Object > > &o1, const GenericObject &o2)
static bool isIterable(const TypedObject< std::map< T, U > > &)
static bool equals(const TypedObject< std::map< T, U > > &o1, const GenericObject &o2)
static bool isIterable(const TypedObject< std::map< int, Object > > &)
static bool equals(const TypedObject< std::map< int, Object > > &o1, const GenericObject &o2)
static bool isIterable(const TypedObject< std::map< std::string, Object > > &)
static bool equals(const TypedObject< std::map< std::string, Object > > &o1, const GenericObject &o2)
static bool isIterable(const TypedObject< std::map< std::string, T > > &)
static bool equals(const TypedObject< std::map< std::string, T > > &o1, const GenericObject &o2)
static bool isIterable(const TypedObject< std::set< T > > &)
static bool equals(const TypedObject< std::set< T > > &o1, const GenericObject &o2)
static bool isIterable(const TypedObject< std::vector< T > > &)
static bool equals(const TypedObject< std::vector< T > > &o1, const GenericObject &o2)
static bool isIterable(const TypedObject< T > &)
static bool equals(const TypedObject< T > &, const GenericObject &)
static Object objectIterator(const TypedObject< T > &)
static Object currentValue(const TypedObject< T > &object)
static void next(TypedObject< T > &object)
static bool isIterator(const TypedObject< T > &object)
static bool isValid(const TypedObject< T > &object)
static Object currentValue(const TypedObject< T > &)
static bool isIterator(const TypedObject< T > &)
static void next(TypedObject< T > &)
static bool isValid(const TypedObject< T > &)
static Object keyObject(const TypedObject< T > &object)
static bool isKeyIterator(const TypedObject< T > &object)
static Object keyObject(const TypedObject< T > &)
static bool isKeyIterator(const TypedObject< T > &)
std::map< T, Object >::const_iterator _iterator
MapIterator(const typename std::map< T, Object >::const_iterator &begin, const typename std::map< T, Object >::const_iterator &end)
virtual Object keyObject() const
std::map< T, Object >::const_iterator _end
Object currentValue() const
std::map< int, Object >::const_iterator _end
Object currentValue() const
virtual Object keyObject() const
std::map< int, Object >::const_iterator _iterator
MapIterator(const std::map< int, Object >::const_iterator &begin, const std::map< int, Object >::const_iterator &end)
Object currentValue() const
std::map< std::string, Object >::const_iterator _end
MapIterator(const std::map< std::string, Object >::const_iterator &begin, const std::map< std::string, Object >::const_iterator &end)
virtual Object keyObject() const
std::map< std::string, Object >::const_iterator _iterator
Object currentValue() const
virtual Object keyObject() const
MapIterator(const typename std::map< std::string, T >::const_iterator &begin, const typename std::map< std::string, T >::const_iterator &end)
std::map< std::string, T >::const_iterator _end
std::map< std::string, T >::const_iterator _iterator
Object currentValue() const
virtual Object keyObject() const
MapIterator(const typename M::const_iterator &begin, const typename M::const_iterator &end)
M::const_iterator _iterator
static bool isNone(const TypedObject< T > &)
static bool isScalar(const TypedObject< T > &object)
static double getScalar(const TypedObject< T > &object)
static bool equals(const TypedObject< T > &o1, const GenericObject &o2)
static void setScalar(TypedObject< T > &object, double value)
static double getScalar(const TypedObject< bool > &to)
static void setScalar(TypedObject< bool > &to, double value)
static bool equals(const TypedObject< bool > &o1, const GenericObject &o2)
static bool isScalar(const TypedObject< bool > &)
static double getScalar(const TypedObject< char > &to)
static void setScalar(TypedObject< char > &to, double value)
static bool equals(const TypedObject< char > &o1, const GenericObject &o2)
static bool isScalar(const TypedObject< char > &)
static double getScalar(const TypedObject< double > &to)
static bool isScalar(const TypedObject< double > &)
static bool equals(const TypedObject< double > &o1, const GenericObject &o2)
static void setScalar(TypedObject< double > &to, double value)
static double getScalar(const TypedObject< float > &to)
static bool equals(const TypedObject< float > &o1, const GenericObject &o2)
static void setScalar(TypedObject< float > &to, double value)
static bool isScalar(const TypedObject< float > &)
static void setScalar(TypedObject< int > &to, double value)
static bool equals(const TypedObject< int > &o1, const GenericObject &o2)
static double getScalar(const TypedObject< int > &to)
static bool isScalar(const TypedObject< int > &)
static double getScalar(const TypedObject< long > &to)
static bool equals(const TypedObject< long > &o1, const GenericObject &o2)
static bool isScalar(const TypedObject< long > &)
static void setScalar(TypedObject< long > &to, double value)
static double getScalar(const TypedObject< long long > &to)
static bool isScalar(const TypedObject< long long > &)
static void setScalar(TypedObject< long long > &to, double value)
static bool equals(const TypedObject< long long > &o1, const GenericObject &o2)
static bool equals(const TypedObject< short > &o1, const GenericObject &o2)
static bool isScalar(const TypedObject< short > &)
static double getScalar(const TypedObject< short > &to)
static void setScalar(TypedObject< short > &to, double value)
static bool isScalar(const TypedObject< signed char > &)
static void setScalar(TypedObject< signed char > &to, double value)
static bool equals(const TypedObject< signed char > &o1, const GenericObject &o2)
static double getScalar(const TypedObject< signed char > &to)
static bool equals(const TypedObject< std::string > &o1, const GenericObject &o2)
static void setScalar(TypedObject< std::string > &to, double value)
static bool isScalar(const TypedObject< std::string > &)
static double getScalar(const TypedObject< std::string > &to)
static double getScalar(const TypedObject< unsigned > &to)
static bool isScalar(const TypedObject< unsigned > &)
static bool equals(const TypedObject< unsigned > &o1, const GenericObject &o2)
static void setScalar(TypedObject< unsigned > &to, double value)
static double getScalar(const TypedObject< unsigned char > &to)
static void setScalar(TypedObject< unsigned char > &to, double value)
static bool equals(const TypedObject< unsigned char > &o1, const GenericObject &o2)
static bool isScalar(const TypedObject< unsigned char > &)
static bool isScalar(const TypedObject< unsigned long > &)
static bool equals(const TypedObject< unsigned long > &o1, const GenericObject &o2)
static void setScalar(TypedObject< unsigned long > &to, double value)
static double getScalar(const TypedObject< unsigned long > &to)
static void setScalar(TypedObject< unsigned long long > &to, double value)
static double getScalar(const TypedObject< unsigned long long > &to)
static bool isScalar(const TypedObject< unsigned long long > &)
static bool equals(const TypedObject< unsigned long long > &o1, const GenericObject &o2)
static double getScalar(const TypedObject< unsigned short > &to)
static bool equals(const TypedObject< unsigned short > &o1, const GenericObject &o2)
static bool isScalar(const TypedObject< unsigned short > &)
static void setScalar(TypedObject< unsigned short > &to, double value)
static bool isScalar(const TypedObject< T > &)
static bool equals(const TypedObject< T > &, const GenericObject &)
static void setScalar(TypedObject< T > &, double)
static double getScalar(const TypedObject< T > &)
std::set< Object >::const_iterator _iterator
Object currentValue() const
std::set< Object >::const_iterator _end
SetIterator(const std::set< Object >::const_iterator &begin, const std::set< Object >::const_iterator &end)
SetIterator(const typename S::const_iterator &begin, const typename S::const_iterator &end)
S::const_iterator _iterator
Object currentValue() const
static size_t size(const TypedObject< T > &object)
static size_t size(const TypedObject< std::map< T, U > > &object)
static size_t size(const TypedObject< std::set< T > > &object)
static size_t size(const TypedObject< std::vector< T > > &object)
static size_t size(const TypedObject< T > &)
static bool equals(const TypedObject< T > &o1, const GenericObject &o2)
static bool isString(const TypedObject< T > &object)
static void setString(TypedObject< T > &object, const std::string &value)
static std::string getString(const TypedObject< T > &object)
static std::string getString(const TypedObject< std::string > &to)
static bool isString(const TypedObject< std::string > &)
static bool equals(const TypedObject< std::string > &o1, const GenericObject &o2)
static void setString(TypedObject< std::string > &to, const std::string &value)
static bool isString(const TypedObject< T > &)
static void setString(TypedObject< T > &, const std::string &)
static bool equals(const TypedObject< T > &, const GenericObject &)
static std::string getString(const TypedObject< T > &)
V::const_iterator _iterator
VectorIterator(const typename V::const_iterator &begin, const typename V::const_iterator &end)
Object currentValue() const
std::string toString(const T &object)
void stringTo(const std::string &value, T &result)
Object none()
An empty singleton object (holds a null pointer)
static Interface * get(TypedObject< T > &to)
static Interface * get(TypedObject< T > &to)
static Interface * get(TypedObject< T > &)
static Object object(const T &)