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> & )
   252       throw std::runtime_error( std::string( 
"object of type " ) + 
   253                                 DataTypeCode<T>::name() + 
" is not an Array" );
   259       throw std::runtime_error( std::string( 
"object of type " ) + 
   260                                 DataTypeCode<T>::name() + 
" is not an Array" );
   264   template <
typename T>
   269     static inline bool isArray( 
const TypedObject<T> & 
object )
   271       return object.getValue().isArray();
   277       return object.getValue().getArrayItem( index );
   283       object.getValue().setArrayItem( index, value );
   294   template <
typename T, 
bool B>
   306       throw std::runtime_error( std::string( 
"object of type " ) + 
   307                                 DataTypeCode<T>::name() + 
   308                                 " is not a DynArray" );
   313       throw std::runtime_error( std::string( 
"object of type " ) + 
   314                                 DataTypeCode<T>::name() + 
   315                                 " is not a DynArray" );
   321       throw std::runtime_error( std::string( 
"object of type " ) + 
   322                                 DataTypeCode<T>::name() + 
   323                                 " is not a DynArray" );
   330       throw std::runtime_error( std::string( 
"object of type " ) + 
   331                                 DataTypeCode<T>::name() + 
   332                                 " is not a DynArray" );
   336   template <
typename T>
   341     static inline bool isDynArray( 
const TypedObject<T> & 
object )
   343       return object.getValue().isDynArray();
   349       object.getValue().reserveArray( size ); 
   355       object.getValue().resizeArray( size ); 
   362       object.getValue().removeArrayItem( index ); 
   367                                         int index, Object value )
   369       object.getValue().insertArrayItem( index, value ); 
   381   template <
typename T, 
bool B>
   392                                     const std::string &, Object & )
   394       throw std::runtime_error( std::string( 
"object of type " ) + 
   395                                 DataTypeCode<T>::name() + 
" is not a "   401                                     const std::string &, Object )
   403       throw std::runtime_error( std::string( 
"object of type " ) + 
   404                                 DataTypeCode<T>::name() + 
" is not a "   410       throw std::runtime_error( std::string( 
"object of type " ) + 
   411                                 DataTypeCode<T>::name() + 
" is not a "   416     static inline bool hasProperty( 
const TypedObject<T> &, 
const std::string & )
   418       throw std::runtime_error( std::string( 
"object of type " ) + 
   419                                 DataTypeCode<T>::name() + 
" is not a "   426       throw std::runtime_error( std::string( 
"object of type " ) + 
   427                                 DataTypeCode<T>::name() + 
" is not a "   431     static inline bool equals( 
const TypedObject<T> & ,
   432                                const GenericObject &  )
   434       throw std::runtime_error( std::string( 
"object of type " ) +
   435                                 DataTypeCode<T>::name() + 
" is not a "   441   template <
typename T>
   448       return object.getValue().isDictionary();
   452                                     const std::string &key, Object & result )
   454       return object.getValue().getProperty( key, result );
   458                                           const std::string &key,
   461       object.getValue().setProperty( key, value );
   465                                         const std::string &key )
   467       return object.getValue().removeProperty( key );
   471                                const std::string & key )
   473       return object.getValue().hasProperty( key );
   478       object.getValue().clearProperties();
   481     static inline bool equals( 
const TypedObject<T> & o1,
   482                                const GenericObject & o2 )
   484       if( !o2.isDictionary() )
   486       const T & 
self = o1.getValue();
   487       if( 
self.size() != o2.size() )
   489       Object it, other_value;
   490       for( it=
self.objectIterator(); it->isValid(); it->next() )
   494           other_value = o2.getProperty( it->key() );
   495           if( it->currentValue() != other_value )
   515   template <
typename T, 
bool B>
   527       throw std::runtime_error( std::string( 
"object of type " ) + 
   528                                 DataTypeCode<T>::name() + 
   529                                 " is not iterable" );
   533     static inline bool equals( 
const TypedObject<T> & ,
   534                                const GenericObject &  )
   536       throw std::runtime_error( std::string( 
"object of type " ) +
   537                                 DataTypeCode<T>::name() +
   538                                 " is not iterable" );
   542   template <
typename T>
   547     static inline bool isIterable( 
const TypedObject<T> & 
object )
   549       return object.getValue().isIterable();
   554       return object.getValue().objectIterator();
   557     static inline bool equals( 
const TypedObject<T> & o1,
   558                                const GenericObject & o2 )
   560       if( !o2.isIterable() )
   562       const T & 
self = o1.getValue();
   563       if( o1.size() != o2.size() )
   566       for( it=
self.objectIterator(), it2=o2.objectIterator();
   567            it->isValid(); it->next(), it2->next() )
   569         if( !it2->isValid() || it->currentValue() != it2->currentValue() )
   584   template <
typename T, 
bool B>
   594     static inline bool isValid( 
const TypedObject<T> & )
   596       throw std::runtime_error( std::string( 
"object of type " ) + 
   597                                 DataTypeCode<T>::name() + 
   598                                 " is not an iterator" );
   604       throw std::runtime_error( std::string( 
"object of type " ) + 
   605                                 DataTypeCode<T>::name() + 
   606                                 " is not an iterator" );
   610     static inline void next( TypedObject<T> & )
   612       throw std::runtime_error( std::string( 
"object of type " ) + 
   613                                 DataTypeCode<T>::name() + 
   614                                 " is not an iterator" );
   619   template <
typename T>
   624     static inline bool isIterator( 
const TypedObject<T> & 
object )
   626       return object.getValue().isIterator();
   629     static inline bool isValid( 
const TypedObject<T> &
object )
   631       return object.getValue().isValid();
   636       return object.getValue().currentValue();
   639     static inline void next( TypedObject<T> &
object )
   641       return object.getValue().next();
   649   template <
typename T, 
bool B>
   659     static inline Object 
keyObject( 
const TypedObject<T> & )
   661       throw std::runtime_error( std::string( 
"object of type " ) +
   662                                 DataTypeCode<T>::name() +
   663                                 " is not a key iterator" );
   668   template <
typename T>
   675       return object.getValue().isKeyIterator();
   678     static inline Object 
keyObject( 
const TypedObject<T> &
object )
   680       return object.getValue().keyObject();
   688   template <
typename T, 
bool B>
   698     static inline std::string 
key( 
const TypedObject<T> & )
   700       throw std::runtime_error( std::string( 
"object of type " ) + 
   701                                 DataTypeCode<T>::name() + 
   702                                 " is not a dictionary iterator" );
   703       return std::string();
   707   template <
typename T>
   714       return object.getValue().isDictionaryIterator();
   717     static inline std::string 
key( 
const TypedObject<T> &
object )
   719       return object.getValue().key();
   727   template <
typename T, 
bool B>
   737     static inline long intKey( 
const TypedObject<T> & )
   739       throw std::runtime_error( std::string( 
"object of type " ) +
   740                                 DataTypeCode<T>::name() +
   741                                 " is not an int dictionary iterator" );
   746   template <
typename T>
   753       return object.getValue().isIntKeyIterator();
   756     static inline long intKey( 
const TypedObject<T> &
object )
   758       return object.getValue().intKey();
   768   template <
typename T, 
bool B>
   772     static inline bool isNone( 
const TypedObject<T> & )
   784   template <
typename T, 
bool B>
   787     static Object object( 
const T & );
   790   template <
typename T, 
bool B>
   793     return Object( static_cast<GenericObject *>( 
new ValueObject<T>( x ) ) );
   796   template <
typename T>
   799     static Object object( 
const T & );
   802   template <
typename T>
   805     return Object( static_cast<GenericObject *> ( x ) );
   819     static inline bool isScalar( 
const TypedObject<char> & )
   824     static inline double getScalar( 
const TypedObject<char> &to )
   826       return to.getValue();
   829     static inline void setScalar( TypedObject<char> &to, 
double value )
   831       to.getValue() = 
static_cast<char>( value );
   834     static inline bool equals( 
const TypedObject<char> & o1,
   835                                const GenericObject & o2 )
   837       return o2.isScalar() && o1.getValue() == o2.getScalar();
   851     static inline bool isScalar( 
const TypedObject<unsigned char> & )
   856     static inline double getScalar( 
const TypedObject<unsigned char> &to )
   858       return to.getValue();
   861     static inline void setScalar( TypedObject<unsigned char> &to, 
   864       to.getValue() = 
static_cast<unsigned char>( value );
   867     static inline bool equals( 
const TypedObject<unsigned char> & o1,
   868                                const GenericObject & o2 )
   870       return o2.isScalar() && o1.getValue() == o2.getScalar();
   884     static inline bool isScalar( 
const TypedObject<signed char> & )
   889     static inline double getScalar( 
const TypedObject<signed char> &to )
   891       return to.getValue();
   894     static inline void setScalar( TypedObject<signed char> &to, 
double value )
   896       to.getValue() = 
static_cast<signed char>( value );
   899     static inline bool equals( 
const TypedObject<signed char> & o1,
   900                                const GenericObject & o2 )
   902       return o2.isScalar() && o1.getValue() == o2.getScalar();
   915     static inline bool isScalar( 
const TypedObject<bool> & )
   920     static inline double getScalar( 
const TypedObject<bool> &to )
   922       return to.getValue();
   925     static inline void setScalar( TypedObject<bool> &to, 
double value )
   927       to.getValue() = 
static_cast<bool>( value );
   930     static inline bool equals( 
const TypedObject<bool> & o1,
   931                                const GenericObject & o2 )
   933       return o2.isScalar() && o1.getValue() == o2.getScalar();
   947     static inline bool isScalar( 
const TypedObject<unsigned short> & )
   952     static inline double getScalar( 
const TypedObject<unsigned short> &to )
   954       return to.getValue();
   957     static inline void setScalar( TypedObject<unsigned short> &to, 
double value )
   959       to.getValue() = 
static_cast<unsigned short>( value );
   962     static inline bool equals( 
const TypedObject<unsigned short> & o1,
   963                                const GenericObject & o2 )
   965       return o2.isScalar() && o1.getValue() == o2.getScalar();
   979     static inline bool isScalar( 
const TypedObject<short> & )
   984     static inline double getScalar( 
const TypedObject<short> &to )
   986       return to.getValue();
   989     static inline void setScalar( TypedObject<short> &to, 
double value )
   991       to.getValue() = 
static_cast<short>( value );
   994     static inline bool equals( 
const TypedObject<short> & o1,
   995                                const GenericObject & o2 )
   997       return o2.isScalar() && o1.getValue() == o2.getScalar();
  1010     static inline bool isScalar( 
const TypedObject<unsigned> & )
  1015     static inline double getScalar( 
const TypedObject<unsigned> &to )
  1017       return to.getValue();
  1020     static inline void setScalar( TypedObject<unsigned> &to, 
double value )
  1022       to.getValue() = 
static_cast<unsigned>( value );
  1025     static inline bool equals( 
const TypedObject<unsigned> & o1,
  1026                                const GenericObject & o2 )
  1028       return o2.isScalar() && o1.getValue() == o2.getScalar();
  1042     static inline bool isScalar( 
const TypedObject<int> & )
  1047     static inline double getScalar( 
const TypedObject<int> &to )
  1049       return to.getValue();
  1052     static inline void setScalar( TypedObject<int> &to, 
double value )
  1054       to.getValue() = 
static_cast<int>( value );
  1057     static inline bool equals( 
const TypedObject<int> & o1,
  1058                                const GenericObject & o2 )
  1060       return o2.isScalar() && o1.getValue() == o2.getScalar();
  1074     static inline bool isScalar( 
const TypedObject<long> & )
  1079     static inline double getScalar( 
const TypedObject<long> &to )
  1081       return to.getValue();
  1084     static inline void setScalar( TypedObject<long> &to, 
double value )
  1086       to.getValue() = 
static_cast<long>( value );
  1089     static inline bool equals( 
const TypedObject<long> & o1,
  1090                                const GenericObject & o2 )
  1092       return o2.isScalar() && o1.getValue() == o2.getScalar();
  1106     static inline bool isScalar( 
const TypedObject<unsigned long> & )
  1111     static inline double getScalar( 
const TypedObject<unsigned long> &to )
  1113       return to.getValue();
  1116     static inline void setScalar( TypedObject<unsigned long> &to, 
  1119       to.getValue() = 
static_cast<unsigned long>( value );
  1122     static inline bool equals( 
const TypedObject<unsigned long> & o1,
  1123                                const GenericObject & o2 )
  1125       return o2.isScalar() && o1.getValue() == o2.getScalar();
  1139     static inline bool isScalar( 
const TypedObject<long long> & )
  1144     static inline double getScalar( 
const TypedObject<long long> &to )
  1146       return to.getValue();
  1149     static inline void setScalar( TypedObject<long long> &to, 
double value )
  1151       to.getValue() = 
static_cast<long long>( value );
  1154     static inline bool equals( 
const TypedObject<long long> & o1,
  1155                                const GenericObject & o2 )
  1157       return o2.isScalar() && o1.getValue() == o2.getScalar();
  1171     static inline bool isScalar( 
const TypedObject<unsigned long long> & )
  1176     static inline double getScalar( 
const TypedObject<unsigned long long> &to )
  1178       return to.getValue();
  1181     static inline void setScalar( TypedObject<unsigned long long> &to,
  1184       to.getValue() = 
static_cast<unsigned long long>( value );
  1187     static inline bool equals( 
const TypedObject<unsigned long long> & o1,
  1188                                const GenericObject & o2 )
  1190       return o2.isScalar() && o1.getValue() == o2.getScalar();
  1204     static inline bool isScalar( 
const TypedObject<float> & )
  1209     static inline double getScalar( 
const TypedObject<float> &to )
  1211       return to.getValue();
  1214     static inline void setScalar( TypedObject<float> &to, 
double value )
  1216       to.getValue() = 
static_cast<float>( value );
  1219     static inline bool equals( 
const TypedObject<float> & o1,
  1220                                const GenericObject & o2 )
  1222       return o2.isScalar() && o1.getValue() == o2.getScalar();
  1235     static inline bool isScalar( 
const TypedObject<double> & )
  1240     static inline double getScalar( 
const TypedObject<double> &to )
  1242       return to.getValue();
  1245     static inline void setScalar( TypedObject<double> &to, 
double value )
  1247       to.getValue() = value;
  1250     static inline bool equals( 
const TypedObject<double> & o1,
  1251                                const GenericObject & o2 )
  1253       return o2.isScalar() && o1.getValue() == o2.getScalar();
  1267     static inline bool isScalar( 
const TypedObject<std::string> & )
  1272     static inline double getScalar( 
const TypedObject<std::string> &to )
  1279     static inline void setScalar( TypedObject<std::string> &to, 
double value )
  1284     static inline bool equals( 
const TypedObject<std::string> & o1,
  1285                                const GenericObject & o2 )
  1287       return o2.isString() && o1.getValue() == o2.getString();
  1301     static inline bool isString( 
const TypedObject< std::string> & )
  1306     static inline std::string 
getString( 
const TypedObject<std::string> &to )
  1308       return to.getValue();
  1312                                   const std::string &value )
  1314       to.getValue() = value;
  1317     static inline bool equals( 
const TypedObject<std::string> & o1,
  1318                                const GenericObject & o2 )
  1320       return o2.isString() && o1.getValue() == o2.getString();
  1335                                         const std::string &value )
  1351                                                const std::string &value )
  1359                                                  TypedObject<unsigned char> 
  1369                                                  const std::string &value )
  1384                                         const std::string &value )
  1392                                                   TypedObject<unsigned short> 
  1402                                                   const std::string &value )
  1417                                        const std::string &value )
  1432                                             const std::string &value )
  1447                                        const std::string &value )
  1455                                                  TypedObject<unsigned long> &
  1465                                                  const std::string &value )
  1480                                          const std::string &value )
  1495                                           const std::string &value )
  1508   template <
typename T>
  1512     static inline size_t   1513     size( 
const TypedObject<std::vector<T> > &
object )
  1515       return object.getValue().size();
  1522   template <
typename T>
  1527     static inline bool isArray( 
const TypedObject< std::vector<T> > & )
  1532     static inline Object 
  1537       return Object::reference( const_cast<T &>
  1538                                 ( 
object.getValue()[ index ] ) );
  1542                                      int index, Object value )
  1544       object.getValue()[ index ] = value->GenericObject::value<T>();
  1552   template <
typename T>
  1556     static inline bool isDynArray( 
const TypedObject< std::vector<T> > & )
  1565       object.getValue().reserve( size ); 
  1572       object.getValue().resize( size ); 
  1579       object.getValue().erase( 
object.getValue().begin() + index ); 
  1585                      int index, Object value )
  1588         object.getValue().insert( 
object.getValue().begin() + index,
  1589                                   value->GenericObject::value<T>() ); 
  1591         object.getValue().insert( 
object.getValue().end() + ( index + 1 ),
  1592                                   value->GenericObject::value<T>() );
  1599   template <
typename T>
  1603     static inline bool isIterable( 
const TypedObject< std::vector<T> > & )
  1608     static inline Object 
  1609     objectIterator( 
const TypedObject<std::vector<T> > & 
object );
  1611     static inline bool equals( 
const TypedObject< std::vector<T> > & o1,
  1612                                const GenericObject & o2 )
  1614       if( !o2.isIterable() )
  1616       const std::vector<T> & 
self = o1.getValue();
  1617       if( 
self.size() != o2.size() )
  1620       for( it=o1.objectIterator(), it2=o2.objectIterator();
  1621            it->isValid(); it->next(), it2->next() )
  1623         if( !it2->isValid() || it->currentValue() != it2->currentValue() )
  1632   template <
typename V>
  1638     bool isValid() 
const;
  1639     Object currentValue() 
const;
  1644                     const typename V::const_iterator &end ) :
  1654 template <
typename V>
  1663   template <
typename V>
  1666     return _iterator != _end;
  1669   template <
typename V>
  1673     return Object::reference( const_cast<typename V::reference>( *_iterator ) );
  1682   template <
typename V>
  1688   template <
typename T>
  1690   ( 
const TypedObject<std::vector<T> > & 
object )
  1693                           ( 
object.getValue().begin(), 
  1694                             object.getValue().end() ) );
  1707              false >::getArrayItem( 
const TypedObject<std::vector<Object> > &
  1710     return object.getValue()[ index ];
  1715   ArrayImpl< std::vector<Object>, 
  1716              false >::setArrayItem( TypedObject<std::vector<Object> > &
  1717                                     object, 
int index, Object value )
  1719     object.getValue()[ index ] = value;
  1728   insertArrayItem( TypedObject< std::vector<Object> > &
object,
  1729                    int index, Object value )
  1732       object.getValue().insert( 
object.getValue().begin() + index, value );
  1734       object.getValue().insert( 
object.getValue().end() + (index + 1), value );
  1747   template <
typename T>
  1751     static inline size_t   1752     size( 
const TypedObject<std::set<T> > &
object )
  1754       return object.getValue().size();
  1761   template <
typename S>
  1768       return _iterator != _end;
  1772       return Object::reference( *_iterator );
  1781                   const typename S::const_iterator &end )
  1782      : IteratorInterface(), _iterator( begin ), _end( end ) {}
  1791 template <
typename T>
  1800   template <
typename T>
  1805     static inline bool isIterable( 
const TypedObject< std::set<T> > & )
  1810     static inline Object 
  1811     objectIterator( 
const TypedObject<std::set<T> > & 
object );
  1814       const TypedObject< std::set<T> > & o1,
  1815       const GenericObject & o2 )
  1817       if( !o2.isIterable() )
  1819       const std::set<T> & 
self = o1.getValue();
  1820       if( 
self.size() != o2.size() )
  1823       for( it2=o2.objectIterator(); it2->isValid(); it2->next() )
  1825         value = it2->currentValue();
  1830           const T & tval = value->value<T>();
  1831           if( 
self.find( tval ) == 
self.end() )
  1845   template <
typename T> 
inline  1848   ( 
const TypedObject<std::set<T> > & 
object )
  1850     return Object::value( 
SetIterator< std::set<T> >( 
object.getValue().begin(), 
  1851                                                       object.getValue().end() ) );
  1865       return _iterator != _end;
  1878                  const std::set<Object>::const_iterator &end )
  1879      : IteratorInterface(), _iterator( begin ), _end( end ) {}
  1883     std::set<Object>::const_iterator 
_end; 
  1894   template <
typename T, 
typename U>
  1898     static inline size_t   1899     size( 
const TypedObject<std::map<T, U> > &
object )
  1901       return object.getValue().size();
  1908   template <
typename T, 
typename U>
  1914                                    TypedObject< std::map<T, U> > & )
  1919     static inline Object 
  1920     objectIterator( 
const TypedObject<std::map<T, U> > & 
object );
  1923       const TypedObject< std::map<T, U> > & o1,
  1924       const GenericObject & o2 )
  1926       if( !o2.isDictionary() )
  1928       const std::map<T, U> & 
self = o1.getValue();
  1929       if( 
self.size() != o2.size() )
  1932       for( it=o1.objectIterator(); it->isValid(); it->next() )
  1936           value = o2.getProperty( it->key() );
  1937           if( it->currentValue() != value )
  1950   template <
typename M>
  1957       return _iterator != _end;
  1961       return Object::reference( _iterator->second );
  1971                   const typename M::const_iterator 
  1972                   &end ) : IteratorInterface(), 
  1973       _iterator( begin ), _end( end )
  1982 template <
typename T,
typename U>
  1990   template <
typename T, 
typename U> 
inline  1992   IterableImpl<std::map<T, U>, 
false>::objectIterator
  1993   ( 
const TypedObject<std::map<T, U> > & 
object )
  1995     return Object::value( 
MapIterator< std::map<T, U> >
  1996                           ( 
object.getValue().begin(), 
  1997                             object.getValue().end() ) );
  2005   template <
typename T>
  2011                                    TypedObject< std::map<T, Object> > & )
  2016     static inline Object 
  2017     objectIterator( 
const TypedObject<std::map<T, Object> > & 
object );
  2020       const TypedObject< std::map<T, Object> > & o1,
  2021       const GenericObject & o2 )
  2023       if( !o2.isIterable() )
  2025       const std::map<T, Object> & 
self = o1.getValue();
  2026       if( 
self.size() != o2.size() )
  2028       typename std::map<T, Object>::const_iterator it;
  2033       for( it=
self.begin(), it2=o2.objectIterator(); it!=
self.end();
  2036         if( it->second != it2->currentValue() )
  2044   template <
typename T>
  2051       return _iterator != _end;
  2055       return _iterator->second;
  2063     MapIterator( 
const typename std::map< T, Object >::const_iterator &begin,
  2064                   const typename std::map< T, Object >::const_iterator &end ) :
  2065      IteratorInterface(), 
  2070     typename std::map< T, Object >::const_iterator 
_end; 
  2074   template <
typename T> 
inline  2077   ( 
const TypedObject<std::map<T, Object> > & 
object )
  2079     return Object::value( 
MapIterator<std::map<T, Object> >( 
object.getValue().begin(), 
  2080                                        object.getValue().end() ) );
  2091   template <
typename T>
  2097                                      TypedObject< std::map<std::string, T> > &)
  2104                  const std::string & key, Object & result )
  2106       typename std::map<std::string, T>::const_iterator 
  2107         i = 
object.getValue().find( key );
  2108       if( i == 
object.getValue().end() )
  2111       result = Object::reference( const_cast<T &>( i->second ) );
  2117                        const std::string & key, Object value )
  2119       T & val = value->GenericObject::value<T>();
  2120       object.getValue()[ key ] = val;
  2125                     const std::string & key )
  2127       return object.getValue().erase( key );
  2133       object.getValue().clear();
  2138                       object, 
const std::string & key )
  2140       return object.getValue().find( key ) != 
object.getValue().end();
  2143     static bool equals( 
const TypedObject<std::map<std::string, T> > &
  2144                         object, 
const GenericObject & other )
  2146       if( !other.isDictionary() )
  2148       const std::map<std::string, T> & 
self = 
object.getValue();
  2149       if( 
self.size() != other.size() )
  2151       Object it, other_value;
  2152       for( it=
object.objectIterator(); it->isValid(); it->next() )
  2156           other_value = other.getProperty( it->key() );
  2157           if( it->currentValue() != other_value )
  2172   template <
typename T>
  2174     public DictionaryIteratorInterface
  2181       return _iterator != _end;
  2186       return Object::reference( _iterator->second );
  2196       return _iterator->first;
  2201                  std::map< std::string, T >::const_iterator &begin,
  2203                  std::map< std::string, T >::const_iterator &end ) :
  2204      IteratorInterface(), 
  2208     typename std::map< std::string, T >::const_iterator 
_iterator; 
  2209     typename std::map< std::string, T >::const_iterator 
_end; 
  2212   template <
typename T>
  2218                                    TypedObject< std::map<std::string, T> > & )
  2223     static inline Object 
  2224     objectIterator( 
const TypedObject<std::map<std::string, T> > & 
object );
  2227       const TypedObject< std::map<std::string, T> > & o1,
  2228       const GenericObject & o2 )
  2230       if( !o2.isDictionary() )
  2232       const std::map<std::string, T> & 
self = o1.getValue();
  2233       if( 
self.size() != o2.size() )
  2236       for( it=o1.objectIterator(); it->isValid(); it->next() )
  2240           value = o2.getProperty( it->key() );
  2241           if( it->currentValue() != value )
  2255   template <
typename T> 
inline  2258   ( 
const TypedObject<std::map<std::string, T> > & 
object )
  2260     return Object::value( 
MapIterator<std::map<std::string, T> >
  2261                           ( 
object.getValue().begin(), 
  2262                             object.getValue().end() ) );
  2275     public DictionaryIteratorInterface
  2282       return _iterator != _end;
  2287       return _iterator->second;
  2297       return _iterator->first;
  2301     MapIterator( 
const std::map< std::string, Object >::const_iterator &begin,
  2302                  const std::map< std::string, Object >::const_iterator &end ) :
  2303       IteratorInterface(), DictionaryIteratorInterface(),
  2308     std::map< std::string, Object >::const_iterator 
_end; 
  2318                                    TypedObject< std::map<std::string, 
  2324     static inline Object 
  2325     objectIterator( 
const   2326                     TypedObject<std::map<std::string, Object> > & 
object );
  2329       const TypedObject< std::map<std::string, Object> > & o1,
  2330       const GenericObject & o2 )
  2332       if( !o2.isDictionary() )
  2334       const std::map<std::string, Object> & 
self = o1.getValue();
  2335       if( 
self.size() != o2.size() )
  2337       std::map<std::string, Object>::const_iterator it;
  2339       for( it=
self.begin(); it!=
self.end(); ++it )
  2343           value = o2.getProperty( it->first );
  2344           if( it->second != value )
  2361   ( 
const TypedObject<std::map<std::string, Object> > & 
object )
  2363     return Object::value( 
MapIterator<std::map<std::string, Object> >
  2364                           ( 
object.getValue().begin(), 
  2365                             object.getValue().end() ) );
  2375   ( 
const TypedObject<std::map<std::string, Object> > & 
object, 
  2376     const std::string & key, Object & result )
  2378     std::map<std::string, Object>::const_iterator 
  2379       i = 
object.getValue().find( key );
  2380     if( i == 
object.getValue().end() )
  2388   DictionaryImpl<std::map<std::string, Object>, 
false>::setProperty
  2389   ( TypedObject<std::map<std::string, Object> > & 
object,
  2390     const std::string & key, Object value )
  2392     object.getValue()[ key ] = value;
  2403   template <
typename T>
  2408     static inline bool isArray( 
const TypedObject< std::map<int,T> > & )
  2413     static inline Object 
  2417       const std::map<int,T>     & val = 
object.getValue();
  2418       typename std::map<int,T>::const_iterator  i = val.find( index );
  2419       if( i == val.end() )
  2422       return Object::reference( const_cast<T &>( i->second ) );
  2426                                      int index, Object value )
  2428       object.getValue()[ index ] = value->GenericObject::value<T>();
  2436   template <
typename T>
  2440     static inline bool isDynArray( 
const TypedObject< std::map<int,T> > & )
  2459       object.getValue().erase( index ); 
  2465                      int index, Object value )
  2467       object.getValue()[ index ] = value->GenericObject::value<T>();
  2481              false >::getArrayItem( 
const TypedObject<std::map<int,Object> > &
  2484     const std::map<int,Object>  & val = 
object.getValue();
  2485     std::map<int,Object>::const_iterator        i = val.find( index );
  2486     if( i == val.end() )
  2493   ArrayImpl< std::map<int,Object>, 
  2494              false >::setArrayItem( TypedObject<std::map<int,Object> > &
  2495                                     object, 
int index, Object value )
  2497     object.getValue()[ index ] = value;
  2506   insertArrayItem( TypedObject< std::map<int,Object> > &
object,
  2507                    int index, Object value )
  2509     object.getValue()[ index ] = value;
  2518     public IntKeyIteratorInterface
  2525       return _iterator != _end;
  2530       return _iterator->second;
  2540       return _iterator->first;
  2545                  const std::map< int, Object >::const_iterator &end ) :
  2546       IteratorInterface(), IntKeyIteratorInterface(),
  2551     std::map< int, Object >::const_iterator 
_end;
  2561                                    TypedObject< std::map<
int,
  2567     static inline Object
  2568     objectIterator( 
const  2569                     TypedObject<std::map<int, Object> > & 
object );
  2572       const TypedObject< std::map<int, Object> > & o1,
  2573       const GenericObject & o2 )
  2575       const std::map<int, Object> & 
self = o1.getValue();
  2576       if( 
self.size() != o2.size() )
  2578       std::map<int, Object>::const_iterator it;
  2579       Object o2it = o2.objectIterator();
  2580       if( !o2it || !o2it->isValid() || !o2it->isIntKeyIterator() )
  2582       for( it=
self.begin(); it!=
self.end(); ++it, o2it->next() )
  2584         if( !o2it || !o2it->isValid() )
  2588           if( it->first != o2it->intKey() )
  2590           if( it->second != o2it->currentValue() )
  2607   ( 
const TypedObject<std::map<int, Object> > & 
object )
  2609     return Object::value( 
MapIterator<std::map<int, Object> >
  2610                           ( 
object.getValue().begin(),
  2611                             object.getValue().end() ) );
  2690 #endif // DOXYGEN_HIDE_INTERNAL_CLASSES  2695 #endif // ifndef CARTOBASE_OBJECT_OBJECT_INTERNALS_H 
static std::string key(const TypedObject< T > &object)
static Object getArrayItem(const TypedObject< T > &, int)
static size_t size(const TypedObject< T > &object)
static Object keyObject(const TypedObject< T > &object)
std::map< std::string, Object >::const_iterator _iterator
static bool isScalar(const TypedObject< char > &)
static long intKey(const TypedObject< T > &object)
static bool isString(const TypedObject< T > &)
static void insertArrayItem(TypedObject< std::map< int, T > > &object, int index, Object value)
static std::string getString(const TypedObject< std::string > &to)
static void removeArrayItem(TypedObject< T > &, int)
static void removeArrayItem(TypedObject< std::map< int, T > > &object, int index)
static void setArrayItem(TypedObject< std::vector< T > > &object, int index, Object value)
static double getScalar(const TypedObject< int > &to)
static bool equals(const TypedObject< signed char > &o1, const GenericObject &o2)
static bool equals(const TypedObject< T > &, const GenericObject &)
static void setScalar(TypedObject< unsigned long long > &to, double value)
static void setScalar(TypedObject< T > &object, double value)
static bool equals(const TypedObject< float > &o1, const GenericObject &o2)
static std::string key(const TypedObject< T > &)
static bool removeProperty(TypedObject< std::map< std::string, T > > &object, const std::string &key)
static Object objectIterator(const TypedObject< T > &object)
static double getScalar(const TypedObject< T > &object)
static bool isValid(const TypedObject< T > &object)
static double getScalar(const TypedObject< unsigned char > &to)
static bool isIterator(const TypedObject< T > &)
static size_t size(const TypedObject< std::map< T, U > > &object)
static void setProperty(TypedObject< T > &object, const std::string &key, Object value)
static void setProperty(TypedObject< T > &, const std::string &, Object)
std::map< int, Object >::const_iterator _end
static bool equals(const TypedObject< unsigned char > &o1, const GenericObject &o2)
static std::string getString(const TypedObject< T > &)
std::set< Object >::const_iterator _end
static void setArrayItem(TypedObject< std::map< int, T > > &object, int index, Object value)
static void clearProperties(TypedObject< std::map< std::string, T > > &object)
Object currentValue() const
static void setScalar(TypedObject< unsigned short > &to, double value)
static void reserveArray(TypedObject< std::vector< T > > &object, size_t size)
static bool isNone(const TypedObject< T > &)
static void setScalar(TypedObject< char > &to, double value)
static bool isScalar(const TypedObject< short > &)
static bool equals(const TypedObject< std::string > &o1, const GenericObject &o2)
M::const_iterator _iterator
static void setArrayItem(TypedObject< T > &, int, Object)
static double getScalar(const TypedObject< unsigned long long > &to)
static double getScalar(const TypedObject< bool > &to)
static bool isDictionary(const TypedObject< std::map< std::string, T > > &)
static void setScalar(TypedObject< int > &to, double value)
SetIterator(const std::set< Object >::const_iterator &begin, const std::set< Object >::const_iterator &end)
static bool isIterable(const TypedObject< std::set< T > > &)
static double getScalar(const TypedObject< double > &to)
static void setScalar(TypedObject< std::string > &to, double value)
std::map< T, Object >::const_iterator _end
VectorIterator(const typename V::const_iterator &begin, const typename V::const_iterator &end)
static bool isScalar(const TypedObject< float > &)
static void removeArrayItem(TypedObject< T > &object, int index)
static bool equals(const TypedObject< std::string > &o1, const GenericObject &o2)
static bool equals(const TypedObject< unsigned short > &o1, const GenericObject &o2)
static bool equals(const TypedObject< T > &, const GenericObject &)
static bool equals(const TypedObject< unsigned long > &o1, const GenericObject &o2)
static bool isScalar(const TypedObject< long long > &)
static void resizeArray(TypedObject< std::vector< T > > &object, size_t size)
static void setScalar(TypedObject< long long > &to, double value)
static bool equals(const TypedObject< std::map< int, Object > > &o1, const GenericObject &o2)
static void setScalar(TypedObject< unsigned char > &to, double value)
S::const_iterator _iterator
static bool equals(const TypedObject< long > &o1, const GenericObject &o2)
static bool isIterable(const TypedObject< std::vector< T > > &)
static bool isScalar(const TypedObject< unsigned > &)
static bool equals(const TypedObject< std::set< T > > &o1, const GenericObject &o2)
static bool getProperty(const TypedObject< T > &, const std::string &, Object &)
static void clearProperties(TypedObject< T > &)
static bool equals(const TypedObject< bool > &o1, const GenericObject &o2)
static bool isScalar(const TypedObject< unsigned short > &)
static bool isIterable(const TypedObject< T > &)
static bool isArray(const TypedObject< T > &)
static bool equals(const TypedObject< std::map< T, U > > &o1, const GenericObject &o2)
static void setScalar(TypedObject< short > &to, double value)
static bool equals(const TypedObject< std::map< std::string, Object > > &o1, const GenericObject &o2)
static long intKey(const TypedObject< T > &)
static bool isKeyIterator(const TypedObject< T > &)
static bool isDynArray(const TypedObject< std::map< int, T > > &)
static bool isKeyIterator(const TypedObject< T > &object)
static bool isDictionary(const TypedObject< T > &)
static void next(TypedObject< T > &object)
MapIterator(const typename std::map< T, Object >::const_iterator &begin, const typename std::map< T, Object >::const_iterator &end)
static bool equals(const TypedObject< int > &o1, const GenericObject &o2)
static bool hasProperty(const TypedObject< T > &, const std::string &)
Object currentValue() const
static bool equals(const TypedObject< T > &o1, const GenericObject &o2)
static bool isDictionaryIterator(const TypedObject< T > &object)
static Object getArrayItem(const TypedObject< std::vector< T > > &object, int index)
static void setScalar(TypedObject< signed char > &to, double value)
static size_t size(const TypedObject< std::set< T > > &object)
SetIterator(const typename S::const_iterator &begin, const typename S::const_iterator &end)
static void setScalar(TypedObject< unsigned > &to, double value)
static bool equals(const TypedObject< unsigned long long > &o1, const GenericObject &o2)
static void setScalar(TypedObject< long > &to, double value)
static bool isArray(const TypedObject< T > &object)
static bool getProperty(const TypedObject< T > &object, const std::string &key, Object &result)
void stringTo(const std::string &value, T &result)
V::const_iterator _iterator
static bool isScalar(const TypedObject< long > &)
static bool equals(const TypedObject< T > &, const GenericObject &)
static bool removeProperty(TypedObject< T > &object, const std::string &key)
static double getScalar(const TypedObject< std::string > &to)
static bool isValid(const TypedObject< T > &)
static bool isScalar(const TypedObject< T > &object)
static bool isIntKeyIterator(const TypedObject< T > &object)
static void setScalar(TypedObject< bool > &to, double value)
static bool isIterable(const TypedObject< std::map< std::string, T > > &)
std::map< T, Object >::const_iterator _iterator
static size_t size(const TypedObject< T > &)
static bool isDictionaryIterator(const TypedObject< T > &)
static bool isDynArray(const TypedObject< T > &object)
Object currentValue() const
Object currentValue() const
static void reserveArray(TypedObject< T > &, size_t)
static bool isScalar(const TypedObject< unsigned char > &)
static bool equals(const TypedObject< T > &o1, const GenericObject &o2)
MapIterator(const std::map< int, Object >::const_iterator &begin, const std::map< int, Object >::const_iterator &end)
static void insertArrayItem(TypedObject< T > &object, int index, Object value)
static bool isScalar(const TypedObject< signed char > &)
static bool equals(const TypedObject< T > &o1, const GenericObject &o2)
static double getScalar(const TypedObject< short > &to)
static bool isScalar(const TypedObject< T > &)
std::set< Object >::const_iterator _iterator
static double getScalar(const TypedObject< unsigned > &to)
static bool equals(const TypedObject< std::map< T, Object > > &o1, const GenericObject &o2)
static bool isIntKeyIterator(const TypedObject< T > &)
static void setScalar(TypedObject< float > &to, double value)
static void resizeArray(TypedObject< std::map< int, T > > &, size_t)
static bool removeProperty(TypedObject< T > &, const std::string &)
static void setString(TypedObject< std::string > &to, const std::string &value)
static void setScalar(TypedObject< double > &to, double value)
std::map< int, Object >::const_iterator _iterator
static bool isString(const TypedObject< std::string > &)
static void resizeArray(TypedObject< T > &object, size_t size)
static bool hasProperty(const TypedObject< std::map< std::string, T > > &object, const std::string &key)
static double getScalar(const TypedObject< float > &to)
static bool isScalar(const TypedObject< double > &)
static bool equals(const TypedObject< std::map< std::string, T > > &o1, const GenericObject &o2)
static bool isIterable(const TypedObject< std::map< T, U > > &)
Object currentValue() const
static Object getArrayItem(const TypedObject< T > &object, int index)
Object currentValue() const
static void setProperty(TypedObject< std::map< std::string, T > > &object, const std::string &key, Object value)
static bool isArray(const TypedObject< std::map< int, T > > &)
static bool isIterable(const TypedObject< std::map< std::string, Object > > &)
static void reserveArray(TypedObject< T > &object, size_t size)
static bool isDynArray(const TypedObject< std::vector< T > > &)
static bool equals(const TypedObject< char > &o1, const GenericObject &o2)
static bool equals(const TypedObject< std::map< std::string, T > > &object, const GenericObject &other)
std::map< std::string, Object >::const_iterator _end
Object currentValue() const
static bool isDynArray(const TypedObject< T > &)
static bool equals(const TypedObject< long long > &o1, const GenericObject &o2)
static void setString(TypedObject< T > &object, const std::string &value)
static void removeArrayItem(TypedObject< std::vector< T > > &object, int index)
static double getScalar(const TypedObject< long long > &to)
static bool isIterable(const TypedObject< std::map< int, Object > > &)
static void clearProperties(TypedObject< T > &object)
static double getScalar(const TypedObject< unsigned short > &to)
static bool isScalar(const TypedObject< std::string > &)
MapIterator(const typename std::map< std::string, T >::const_iterator &begin, const typename std::map< std::string, T >::const_iterator &end)
static Object object(const T &)
static bool isIterator(const TypedObject< T > &object)
static void insertArrayItem(TypedObject< T > &, int, Object)
static bool equals(const TypedObject< double > &o1, const GenericObject &o2)
static Object keyObject(const TypedObject< T > &)
static bool isScalar(const TypedObject< unsigned long long > &)
MapIterator(const typename M::const_iterator &begin, const typename M::const_iterator &end)
static bool isIterable(const TypedObject< std::map< T, Object > > &)
Object currentValue() const
static bool hasProperty(const TypedObject< T > &object, const std::string &key)
static bool equals(const TypedObject< short > &o1, const GenericObject &o2)
static bool isArray(const TypedObject< std::vector< T > > &)
static bool isScalar(const TypedObject< int > &)
static double getScalar(const TypedObject< unsigned long > &to)
static double getScalar(const TypedObject< T > &)
std::string toString(const T &object)
MapIterator(const std::map< std::string, Object >::const_iterator &begin, const std::map< std::string, Object >::const_iterator &end)
Object none()
An empty singleton object (holds a null pointer) 
static void setString(TypedObject< T > &, const std::string &)
static void setArrayItem(TypedObject< T > &object, int index, Object value)
static void setScalar(TypedObject< T > &, double)
static bool equals(const TypedObject< T > &, const GenericObject &)
static double getScalar(const TypedObject< signed char > &to)
static Object objectIterator(const TypedObject< T > &)
static void insertArrayItem(TypedObject< std::vector< T > > &object, int index, Object value)
static void next(TypedObject< T > &)
static bool getProperty(const TypedObject< std::map< std::string, T > > &object, const std::string &key, Object &result)
static double getScalar(const TypedObject< char > &to)
static size_t size(const TypedObject< std::vector< T > > &object)
static bool equals(const TypedObject< std::vector< T > > &o1, const GenericObject &o2)
static std::string getString(const TypedObject< T > &object)
static Object currentValue(const TypedObject< T > &)
static void resizeArray(TypedObject< T > &, size_t)
static bool isDictionary(const TypedObject< T > &object)
static void setScalar(TypedObject< unsigned long > &to, double value)
static double getScalar(const TypedObject< long > &to)
static bool isIterable(const TypedObject< T > &object)
static Object getArrayItem(const TypedObject< std::map< int, T > > &object, int index)
static bool equals(const TypedObject< unsigned > &o1, const GenericObject &o2)
std::map< std::string, T >::const_iterator _iterator
static bool isScalar(const TypedObject< unsigned long > &)
static bool isScalar(const TypedObject< bool > &)
static void reserveArray(TypedObject< std::map< int, T > > &, size_t)
std::map< std::string, T >::const_iterator _end
static bool equals(const TypedObject< T > &o1, const GenericObject &o2)
static bool isString(const TypedObject< T > &object)
static Object currentValue(const TypedObject< T > &object)