cartobase  5.0.5
object_internal.h
Go to the documentation of this file.
1 /* This software and supporting documentation are distributed by
2  * Institut Federatif de Recherche 49
3  * CEA/NeuroSpin, Batiment 145,
4  * 91191 Gif-sur-Yvette cedex
5  * France
6  *
7  * This software is governed by the CeCILL-B license under
8  * French law and abiding by the rules of distribution of free software.
9  * You can use, modify and/or redistribute the software under the
10  * terms of the CeCILL-B license as circulated by CEA, CNRS
11  * and INRIA at the following URL "http://www.cecill.info".
12  *
13  * As a counterpart to the access to the source code and rights to copy,
14  * modify and redistribute granted by the license, users are provided only
15  * with a limited warranty and the software's author, the holder of the
16  * economic rights, and the successive licensors have only limited
17  * liability.
18  *
19  * In this respect, the user's attention is drawn to the risks associated
20  * with loading, using, modifying and/or developing or reproducing the
21  * software by the user in light of its specific status of free software,
22  * that may mean that it is complicated to manipulate, and that also
23  * therefore means that it is reserved for developers and experienced
24  * professionals having in-depth computer knowledge. Users are therefore
25  * encouraged to load and test the software's suitability as regards their
26  * requirements in conditions enabling the security of their systems and/or
27  * data to be ensured and, more generally, to use and operate it in the
28  * same conditions as regards security.
29  *
30  * The fact that you are presently reading this means that you have had
31  * knowledge of the CeCILL-B license and that you accept its terms.
32  */
33 
34 #ifndef CARTOBASE_OBJECT_OBJECT_D_H
35 #error This header file must not be included directly, use <cartobase/object/object_d.h> instead.
36 #endif
37 
38 #ifndef CARTOBASE_OBJECT_OBJECT_INTERNALS_H
39 #define CARTOBASE_OBJECT_OBJECT_INTERNALS_H
40 
41 
42 #ifndef DOXYGEN_HIDE_INTERNAL_CLASSES
43 
45 {
46  //---------------------------------------------------------------------------
47  template <typename T, bool B>
49  static inline Interface *get( TypedObject<T> & );
50  };
51 
52 
53  //---------------------------------------------------------------------------
54  template <typename T>
55  struct GenericInterface<T,true> {
56  static inline Interface *get( TypedObject<T> &to )
57  {
58  return static_cast< Interface * >( &to.getValue() );
59  }
60  };
61 
62  //---------------------------------------------------------------------------
63  template <typename T>
64  struct GenericInterface<T,false> {
65  static inline Interface *get( TypedObject<T> &to )
66  {
67  return &to;
68  }
69  };
70 
71 
72  //---------------------------------------------------------------------------
73  // ScalarInterface default implementation
74  //---------------------------------------------------------------------------
75 
76 
77  template <typename T, bool B>
78  class ScalarImpl
79  {
80  public:
81 
82  static inline bool isScalar( const TypedObject<T> & )
83  {
84  return false;
85  }
86 
87  static inline double getScalar( const TypedObject<T> & )
88  {
89  throw std::runtime_error( std::string( "Cannot convert object of "
90  "type " )
91  + DataTypeCode<T>::name() + " to scalar" );
92  return 0.0;
93  }
94 
95  static inline void setScalar( TypedObject<T> &, double )
96  {
97  throw std::runtime_error( std::string( "Cannot convert scalar to "
98  "object of type " ) +
99  DataTypeCode<T>::name() );
100  }
101 
102  static inline bool equals( const TypedObject<T> & /* o1 */,
103  const GenericObject & /* o2 */ )
104  {
105  throw std::runtime_error( std::string( "Cannot convert scalar to "
106  "object of type " ) +
107  DataTypeCode<T>::name() );
108  }
109  };
110 
111  template <typename T>
112  class ScalarImpl< T, true >
113  {
114  public:
115 
116  static inline bool isScalar( const TypedObject<T> & object )
117  {
118  return object.getValue().isScalar();
119  }
120 
121  static inline double getScalar( const TypedObject<T> &object )
122  {
123  return object.getValue().getScalar();
124  }
125 
126  static inline void setScalar( TypedObject<T> &object, double value )
127  {
128  object.getValue().setScalar( value );
129  }
130 
131  static inline bool equals( const TypedObject<T> & o1,
132  const GenericObject & o2 )
133  {
134  return o2.isScalar() && o1.getValue().getScalar() == o2.getScalar();
135  }
136  };
137 
138 
139  //---------------------------------------------------------------------------
140  // StringInterface default implementation
141  //---------------------------------------------------------------------------
142 
143 
144  template <typename T, bool B>
146  {
147  public:
148 
149  static inline bool isString( const TypedObject<T> & )
150  {
151  return false;
152  }
153 
154  static inline std::string getString( const TypedObject<T> & )
155  {
156  throw std::runtime_error( std::string( "Cannot convert object of type " )
157  + DataTypeCode<T>::name() + " to string" );
158  return std::string();
159  }
160 
161  static inline void setString( TypedObject<T> &, const std::string & )
162  {
163  throw std::runtime_error( std::string( "Cannot convert string to "
164  "object of type " ) +
165  DataTypeCode<T>::name() );
166  }
167 
168  static inline bool equals( const TypedObject<T> & /* o1 */,
169  const GenericObject & /* o2 */ )
170  {
171  throw std::runtime_error( std::string( "Cannot convert string to "
172  "object of type " ) +
173  DataTypeCode<T>::name() );
174  }
175  };
176 
177  template <typename T>
178  class StringImpl< T, true >
179  {
180  public:
181 
182  static inline bool isString( const TypedObject<T> & object )
183  {
184  return object.getValue().isString();
185  }
186 
187  static inline std::string getString( const TypedObject<T> &object )
188  {
189  return object.getValue().getString();
190  }
191 
192  static inline void setString( TypedObject<T> &object,
193  const std::string &value )
194  {
195  object.getValue().setString( value );
196  }
197 
198  static inline bool equals( const TypedObject<T> & o1,
199  const GenericObject & o2 )
200  {
201  return o2.isString() && o1.getValue().getString() == o2.getString();
202  }
203  };
204 
205 
206  //---------------------------------------------------------------------------
207  // SizeInterface default implementation
208  //---------------------------------------------------------------------------
209 
210 
211  template <typename T, bool B>
212  class SizeImpl
213  {
214  public:
215  static inline size_t size( const TypedObject<T> & )
216  {
217  throw std::runtime_error( std::string( "cannot get size of object of "
218  "type "
219  ) + DataTypeCode<T>::name() );
220  return 0;
221  }
222  };
223 
224  template <typename T>
225  class SizeImpl<T,true>
226  {
227  public:
228  static inline size_t size( const TypedObject<T> &object )
229  {
230  return object.getValue().size();
231  }
232  };
233 
234 
235  //---------------------------------------------------------------------------
236  // ArrayInterface default implementation
237  //---------------------------------------------------------------------------
238 
239 
240  template <typename T, bool B>
241  class ArrayImpl
242  {
243  public:
244 
245  static inline bool isArray( const TypedObject<T> & )
246  {
247  return false;
248  }
249 
250  static inline Object getArrayItem( const TypedObject<T> &, int )
251  {
252  throw std::runtime_error( std::string( "object of type " ) +
253  DataTypeCode<T>::name() + " is not an Array" );
254  return Object();
255  }
256 
257  static inline void setArrayItem( TypedObject<T> &, int, Object )
258  {
259  throw std::runtime_error( std::string( "object of type " ) +
260  DataTypeCode<T>::name() + " is not an Array" );
261  }
262  };
263 
264  template <typename T>
265  class ArrayImpl< T, true >
266  {
267  public:
268 
269  static inline bool isArray( const TypedObject<T> & object )
270  {
271  return object.getValue().isArray();
272  }
273 
274  static inline Object getArrayItem( const TypedObject<T> &object,
275  int index )
276  {
277  return object.getValue().getArrayItem( index );
278  }
279 
280  static inline void setArrayItem( TypedObject<T> &object, int index,
281  Object value )
282  {
283  object.getValue().setArrayItem( index, value );
284  }
285  };
286 
287 
288 
289  //---------------------------------------------------------------------------
290  // DynArrayInterface default implementation
291  //---------------------------------------------------------------------------
292 
293 
294  template <typename T, bool B>
296  {
297  public:
298 
299  static inline bool isDynArray( const TypedObject<T> & )
300  {
301  return false;
302  }
303 
304  static inline void reserveArray( TypedObject<T> &, size_t )
305  {
306  throw std::runtime_error( std::string( "object of type " ) +
307  DataTypeCode<T>::name() +
308  " is not a DynArray" );
309  }
310 
311  static inline void resizeArray( TypedObject<T> &, size_t )
312  {
313  throw std::runtime_error( std::string( "object of type " ) +
314  DataTypeCode<T>::name() +
315  " is not a DynArray" );
316  }
317 
318 
319  static inline void removeArrayItem( TypedObject<T> &, int )
320  {
321  throw std::runtime_error( std::string( "object of type " ) +
322  DataTypeCode<T>::name() +
323  " is not a DynArray" );
324  }
325 
326 
327  static inline void insertArrayItem( TypedObject<T> &,
328  int, Object )
329  {
330  throw std::runtime_error( std::string( "object of type " ) +
331  DataTypeCode<T>::name() +
332  " is not a DynArray" );
333  }
334  };
335 
336  template <typename T>
337  class DynArrayImpl< T, true >
338  {
339  public:
340 
341  static inline bool isDynArray( const TypedObject<T> & object )
342  {
343  return object.getValue().isDynArray();
344  }
345 
346  static inline void reserveArray( TypedObject<T> &object,
347  size_t size )
348  {
349  object.getValue().reserveArray( size );
350  }
351 
352  static inline void resizeArray( TypedObject<T> &object,
353  size_t size )
354  {
355  object.getValue().resizeArray( size );
356  }
357 
358 
359  static inline void removeArrayItem( TypedObject<T> &object,
360  int index )
361  {
362  object.getValue().removeArrayItem( index );
363  }
364 
365 
366  static inline void insertArrayItem( TypedObject<T> &object,
367  int index, Object value )
368  {
369  object.getValue().insertArrayItem( index, value );
370  }
371  };
372 
373 
374 
375 
376  //---------------------------------------------------------------------------
377  // DictionaryInterface default implementation
378  //---------------------------------------------------------------------------
379 
380 
381  template <typename T, bool B>
383  {
384  public:
385 
386  static inline bool isDictionary( const TypedObject<T> & )
387  {
388  return false;
389  }
390 
391  static inline bool getProperty( const TypedObject<T> &,
392  const std::string &, Object & )
393  {
394  throw std::runtime_error( std::string( "object of type " ) +
395  DataTypeCode<T>::name() + " is not a "
396  "Dictionary" );
397  return false;
398  }
399 
400  static inline void setProperty( TypedObject<T> &,
401  const std::string &, Object )
402  {
403  throw std::runtime_error( std::string( "object of type " ) +
404  DataTypeCode<T>::name() + " is not a "
405  "Dictionary" );
406  }
407 
408  static inline bool removeProperty( TypedObject<T> &, const std::string & )
409  {
410  throw std::runtime_error( std::string( "object of type " ) +
411  DataTypeCode<T>::name() + " is not a "
412  "Dictionary" );
413  return false;
414  }
415 
416  static inline bool hasProperty( const TypedObject<T> &, const std::string & )
417  {
418  throw std::runtime_error( std::string( "object of type " ) +
419  DataTypeCode<T>::name() + " is not a "
420  "Dictionary" );
421  return false;
422  }
423 
424  static inline void clearProperties( TypedObject<T> & )
425  {
426  throw std::runtime_error( std::string( "object of type " ) +
427  DataTypeCode<T>::name() + " is not a "
428  "Dictionary" );
429  }
430 
431  static inline bool equals( const TypedObject<T> & /* o1 */,
432  const GenericObject & /* o2 */ )
433  {
434  throw std::runtime_error( std::string( "object of type " ) +
435  DataTypeCode<T>::name() + " is not a "
436  "Dictionary" );
437  }
438 
439  };
440 
441  template <typename T>
442  class DictionaryImpl< T, true >
443  {
444  public:
445 
446  static inline bool isDictionary( const TypedObject<T> & object )
447  {
448  return object.getValue().isDictionary();
449  }
450 
451  static inline bool getProperty( const TypedObject<T> &object,
452  const std::string &key, Object & result )
453  {
454  return object.getValue().getProperty( key, result );
455  }
456 
457  static inline void setProperty( TypedObject<T> &object,
458  const std::string &key,
459  Object value )
460  {
461  object.getValue().setProperty( key, value );
462  }
463 
464  static inline bool removeProperty( TypedObject<T> &object,
465  const std::string &key )
466  {
467  return object.getValue().removeProperty( key );
468  }
469 
470  static inline bool hasProperty( const TypedObject<T> & object,
471  const std::string & key )
472  {
473  return object.getValue().hasProperty( key );
474  }
475 
476  static inline void clearProperties( TypedObject<T> &object )
477  {
478  object.getValue().clearProperties();
479  }
480 
481  static inline bool equals( const TypedObject<T> & o1,
482  const GenericObject & o2 )
483  {
484  if( !o2.isDictionary() )
485  return false;
486  const T & self = o1.getValue();
487  if( self.size() != o2.size() )
488  return false;
489  Object it, other_value;
490  for( it=self.objectIterator(); it->isValid(); it->next() )
491  {
492  try
493  {
494  other_value = o2.getProperty( it->key() );
495  if( it->currentValue() != other_value )
496  return false;
497  }
498  catch( ... )
499  {
500  return false;
501  }
502  }
503  return true;
504  }
505 
506  };
507 
508 
509 
510  //---------------------------------------------------------------------------
511  // IterableInterface default implementation
512  //---------------------------------------------------------------------------
513 
514 
515  template <typename T, bool B>
517  {
518  public:
519 
520  static inline bool isIterable( const TypedObject<T> & )
521  {
522  return false;
523  }
524 
525  static inline Object objectIterator( const TypedObject<T> & )
526  {
527  throw std::runtime_error( std::string( "object of type " ) +
528  DataTypeCode<T>::name() +
529  " is not iterable" );
530  return Object();
531  }
532 
533  static inline bool equals( const TypedObject<T> & /* o1 */,
534  const GenericObject & /* o2 */ )
535  {
536  throw std::runtime_error( std::string( "object of type " ) +
537  DataTypeCode<T>::name() +
538  " is not iterable" );
539  }
540  };
541 
542  template <typename T>
543  class IterableImpl< T, true >
544  {
545  public:
546 
547  static inline bool isIterable( const TypedObject<T> & object )
548  {
549  return object.getValue().isIterable();
550  }
551 
552  static inline Object objectIterator( const TypedObject<T> &object )
553  {
554  return object.getValue().objectIterator();
555  }
556 
557  static inline bool equals( const TypedObject<T> & o1,
558  const GenericObject & o2 )
559  {
560  if( !o2.isIterable() )
561  return false;
562  const T & self = o1.getValue();
563  if( o1.size() != o2.size() )
564  return false;
565  Object it, it2;
566  for( it=self.objectIterator(), it2=o2.objectIterator();
567  it->isValid(); it->next(), it2->next() )
568  {
569  if( !it2->isValid() || it->currentValue() != it2->currentValue() )
570  return false;
571  }
572  return true;
573  }
574 
575  };
576 
577 
578 
579  //---------------------------------------------------------------------------
580  // IteratorInterface default implementation
581  //---------------------------------------------------------------------------
582 
583 
584  template <typename T, bool B>
586  {
587  public:
588 
589  static inline bool isIterator( const TypedObject<T> & )
590  {
591  return false;
592  }
593 
594  static inline bool isValid( const TypedObject<T> & )
595  {
596  throw std::runtime_error( std::string( "object of type " ) +
597  DataTypeCode<T>::name() +
598  " is not an iterator" );
599  return false;
600  }
601 
602  static inline Object currentValue( const TypedObject<T> & )
603  {
604  throw std::runtime_error( std::string( "object of type " ) +
605  DataTypeCode<T>::name() +
606  " is not an iterator" );
607  return Object();
608  }
609 
610  static inline void next( TypedObject<T> & )
611  {
612  throw std::runtime_error( std::string( "object of type " ) +
613  DataTypeCode<T>::name() +
614  " is not an iterator" );
615  }
616  };
617 
618 
619  template <typename T>
620  class IteratorImpl< T, true >
621  {
622  public:
623 
624  static inline bool isIterator( const TypedObject<T> & object )
625  {
626  return object.getValue().isIterator();
627  }
628 
629  static inline bool isValid( const TypedObject<T> &object )
630  {
631  return object.getValue().isValid();
632  }
633 
634  static inline Object currentValue( const TypedObject<T> &object )
635  {
636  return object.getValue().currentValue();
637  }
638 
639  static inline void next( TypedObject<T> &object )
640  {
641  return object.getValue().next();
642  }
643  };
644 
645 
646  //---------------------------------------------------------------------------
647  // KeyIteratorInterface default implementation
648  //---------------------------------------------------------------------------
649  template <typename T, bool B>
651  {
652  public:
653 
654  static inline bool isKeyIterator( const TypedObject<T> & )
655  {
656  return false;
657  }
658 
659  static inline Object keyObject( const TypedObject<T> & )
660  {
661  throw std::runtime_error( std::string( "object of type " ) +
662  DataTypeCode<T>::name() +
663  " is not a key iterator" );
664  return Object();
665  }
666  };
667 
668  template <typename T>
669  class KeyIteratorImpl< T, true >
670  {
671  public:
672 
673  static inline bool isKeyIterator( const TypedObject<T> & object )
674  {
675  return object.getValue().isKeyIterator();
676  }
677 
678  static inline Object keyObject( const TypedObject<T> &object )
679  {
680  return object.getValue().keyObject();
681  }
682  };
683 
684 
685  //---------------------------------------------------------------------------
686  // DictionaryIteratorInterface default implementation
687  //---------------------------------------------------------------------------
688  template <typename T, bool B>
690  {
691  public:
692 
693  static inline bool isDictionaryIterator( const TypedObject<T> & )
694  {
695  return false;
696  }
697 
698  static inline std::string key( const TypedObject<T> & )
699  {
700  throw std::runtime_error( std::string( "object of type " ) +
701  DataTypeCode<T>::name() +
702  " is not a dictionary iterator" );
703  return std::string();
704  }
705  };
706 
707  template <typename T>
708  class DictionaryIteratorImpl< T, true >
709  {
710  public:
711 
712  static inline bool isDictionaryIterator( const TypedObject<T> & object )
713  {
714  return object.getValue().isDictionaryIterator();
715  }
716 
717  static inline std::string key( const TypedObject<T> &object )
718  {
719  return object.getValue().key();
720  }
721  };
722 
723 
724  //---------------------------------------------------------------------------
725  // IntKeyIteratorInterface default implementation
726  //---------------------------------------------------------------------------
727  template <typename T, bool B>
729  {
730  public:
731 
732  static inline bool isIntKeyIterator( const TypedObject<T> & )
733  {
734  return false;
735  }
736 
737  static inline long intKey( const TypedObject<T> & )
738  {
739  throw std::runtime_error( std::string( "object of type " ) +
740  DataTypeCode<T>::name() +
741  " is not an int dictionary iterator" );
742  return 0;
743  }
744  };
745 
746  template <typename T>
747  class IntDictionaryIteratorImpl< T, true >
748  {
749  public:
750 
751  static inline bool isIntKeyIterator( const TypedObject<T> & object )
752  {
753  return object.getValue().isIntKeyIterator();
754  }
755 
756  static inline long intKey( const TypedObject<T> &object )
757  {
758  return object.getValue().intKey();
759  }
760  };
761 
762 
763  //---------------------------------------------------------------------------
764  // NoneInterface default implementation
765  //---------------------------------------------------------------------------
766 
767 
768  template <typename T, bool B>
769  class NoneImpl
770  {
771  public:
772  static inline bool isNone( const TypedObject<T> & )
773  {
774  return false;
775  }
776  };
777 
778 
779  //-----------------------------------------------//
780  // Build a ValueObject if T is not a pointer to //
781  // a subclass of GenericObject //
782  //-----------------------------------------------//
783 
784  template <typename T, bool B>
786  {
787  static Object object( const T & );
788  };
789 
790  template <typename T, bool B>
791  Object ValueObjectImpl<T,B>::object( const T & x )
792  {
793  return Object( static_cast<GenericObject *>( new ValueObject<T>( x ) ) );
794  }
795 
796  template <typename T>
797  struct ValueObjectImpl<T,true>
798  {
799  static Object object( const T & );
800  };
801 
802  template <typename T>
803  Object ValueObjectImpl<T,true>::object( const T & x )
804  {
805  return Object( static_cast<GenericObject *> ( x ) );
806  }
807 
808 
809 
810  //--------//
811  // char //
812  //--------//
813 
814  //---------------------------------------------------------------------------
815  template <>
816  class ScalarImpl< char, false >
817  {
818  public:
819  static inline bool isScalar( const TypedObject<char> & )
820  {
821  return true;
822  }
823 
824  static inline double getScalar( const TypedObject<char> &to )
825  {
826  return to.getValue();
827  }
828 
829  static inline void setScalar( TypedObject<char> &to, double value )
830  {
831  to.getValue() = static_cast<char>( value );
832  }
833 
834  static inline bool equals( const TypedObject<char> & o1,
835  const GenericObject & o2 )
836  {
837  return o2.isScalar() && o1.getValue() == o2.getScalar();
838  }
839  };
840 
841 
842  //-----------------//
843  // unsigned char //
844  //-----------------//
845 
846  //---------------------------------------------------------------------------
847  template <>
848  class ScalarImpl< unsigned char, false >
849  {
850  public:
851  static inline bool isScalar( const TypedObject<unsigned char> & )
852  {
853  return true;
854  }
855 
856  static inline double getScalar( const TypedObject<unsigned char> &to )
857  {
858  return to.getValue();
859  }
860 
861  static inline void setScalar( TypedObject<unsigned char> &to,
862  double value )
863  {
864  to.getValue() = static_cast<unsigned char>( value );
865  }
866 
867  static inline bool equals( const TypedObject<unsigned char> & o1,
868  const GenericObject & o2 )
869  {
870  return o2.isScalar() && o1.getValue() == o2.getScalar();
871  }
872  };
873 
874 
875  //---------------//
876  // signed char //
877  //---------------//
878 
879  //---------------------------------------------------------------------------
880  template <>
881  class ScalarImpl< signed char, false >
882  {
883  public:
884  static inline bool isScalar( const TypedObject<signed char> & )
885  {
886  return true;
887  }
888 
889  static inline double getScalar( const TypedObject<signed char> &to )
890  {
891  return to.getValue();
892  }
893 
894  static inline void setScalar( TypedObject<signed char> &to, double value )
895  {
896  to.getValue() = static_cast<signed char>( value );
897  }
898 
899  static inline bool equals( const TypedObject<signed char> & o1,
900  const GenericObject & o2 )
901  {
902  return o2.isScalar() && o1.getValue() == o2.getScalar();
903  }
904  };
905 
906  //--------//
907  // bool //
908  //--------//
909 
910  //---------------------------------------------------------------------------
911  template <>
912  class ScalarImpl< bool, false >
913  {
914  public:
915  static inline bool isScalar( const TypedObject<bool> & )
916  {
917  return true;
918  }
919 
920  static inline double getScalar( const TypedObject<bool> &to )
921  {
922  return to.getValue();
923  }
924 
925  static inline void setScalar( TypedObject<bool> &to, double value )
926  {
927  to.getValue() = static_cast<bool>( value );
928  }
929 
930  static inline bool equals( const TypedObject<bool> & o1,
931  const GenericObject & o2 )
932  {
933  return o2.isScalar() && o1.getValue() == o2.getScalar();
934  }
935  };
936 
937 
938  //------------------//
939  // unsigned short //
940  //------------------//
941 
942  //---------------------------------------------------------------------------
943  template <>
944  class ScalarImpl< unsigned short, false >
945  {
946  public:
947  static inline bool isScalar( const TypedObject<unsigned short> & )
948  {
949  return true;
950  }
951 
952  static inline double getScalar( const TypedObject<unsigned short> &to )
953  {
954  return to.getValue();
955  }
956 
957  static inline void setScalar( TypedObject<unsigned short> &to, double value )
958  {
959  to.getValue() = static_cast<unsigned short>( value );
960  }
961 
962  static inline bool equals( const TypedObject<unsigned short> & o1,
963  const GenericObject & o2 )
964  {
965  return o2.isScalar() && o1.getValue() == o2.getScalar();
966  }
967  };
968 
969 
970  //---------//
971  // short //
972  //---------//
973 
974  //---------------------------------------------------------------------------
975  template <>
976  class ScalarImpl< short, false >
977  {
978  public:
979  static inline bool isScalar( const TypedObject<short> & )
980  {
981  return true;
982  }
983 
984  static inline double getScalar( const TypedObject<short> &to )
985  {
986  return to.getValue();
987  }
988 
989  static inline void setScalar( TypedObject<short> &to, double value )
990  {
991  to.getValue() = static_cast<short>( value );
992  }
993 
994  static inline bool equals( const TypedObject<short> & o1,
995  const GenericObject & o2 )
996  {
997  return o2.isScalar() && o1.getValue() == o2.getScalar();
998  }
999  };
1000 
1001  //------------//
1002  // unsigned //
1003  //------------//
1004 
1005  //---------------------------------------------------------------------------
1006  template <>
1007  class ScalarImpl< unsigned, false >
1008  {
1009  public:
1010  static inline bool isScalar( const TypedObject<unsigned> & )
1011  {
1012  return true;
1013  }
1014 
1015  static inline double getScalar( const TypedObject<unsigned> &to )
1016  {
1017  return to.getValue();
1018  }
1019 
1020  static inline void setScalar( TypedObject<unsigned> &to, double value )
1021  {
1022  to.getValue() = static_cast<unsigned>( value );
1023  }
1024 
1025  static inline bool equals( const TypedObject<unsigned> & o1,
1026  const GenericObject & o2 )
1027  {
1028  return o2.isScalar() && o1.getValue() == o2.getScalar();
1029  }
1030  };
1031 
1032 
1033  //-------//
1034  // int //
1035  //-------//
1036 
1037  //---------------------------------------------------------------------------
1038  template <>
1039  class ScalarImpl< int, false >
1040  {
1041  public:
1042  static inline bool isScalar( const TypedObject<int> & )
1043  {
1044  return true;
1045  }
1046 
1047  static inline double getScalar( const TypedObject<int> &to )
1048  {
1049  return to.getValue();
1050  }
1051 
1052  static inline void setScalar( TypedObject<int> &to, double value )
1053  {
1054  to.getValue() = static_cast<int>( value );
1055  }
1056 
1057  static inline bool equals( const TypedObject<int> & o1,
1058  const GenericObject & o2 )
1059  {
1060  return o2.isScalar() && o1.getValue() == o2.getScalar();
1061  }
1062  };
1063 
1064 
1065  //--------//
1066  // long //
1067  //--------//
1068 
1069  //---------------------------------------------------------------------------
1070  template <>
1071  class ScalarImpl< long, false >
1072  {
1073  public:
1074  static inline bool isScalar( const TypedObject<long> & )
1075  {
1076  return true;
1077  }
1078 
1079  static inline double getScalar( const TypedObject<long> &to )
1080  {
1081  return to.getValue();
1082  }
1083 
1084  static inline void setScalar( TypedObject<long> &to, double value )
1085  {
1086  to.getValue() = static_cast<long>( value );
1087  }
1088 
1089  static inline bool equals( const TypedObject<long> & o1,
1090  const GenericObject & o2 )
1091  {
1092  return o2.isScalar() && o1.getValue() == o2.getScalar();
1093  }
1094  };
1095 
1096 
1097  //-----------------//
1098  // unsigned long //
1099  //-----------------//
1100 
1101  //---------------------------------------------------------------------------
1102  template <>
1103  class ScalarImpl< unsigned long, false >
1104  {
1105  public:
1106  static inline bool isScalar( const TypedObject<unsigned long> & )
1107  {
1108  return true;
1109  }
1110 
1111  static inline double getScalar( const TypedObject<unsigned long> &to )
1112  {
1113  return to.getValue();
1114  }
1115 
1116  static inline void setScalar( TypedObject<unsigned long> &to,
1117  double value )
1118  {
1119  to.getValue() = static_cast<unsigned long>( value );
1120  }
1121 
1122  static inline bool equals( const TypedObject<unsigned long> & o1,
1123  const GenericObject & o2 )
1124  {
1125  return o2.isScalar() && o1.getValue() == o2.getScalar();
1126  }
1127  };
1128 
1129 
1130  //------------//
1131  // long long //
1132  //------------//
1133 
1134  //---------------------------------------------------------------------------
1135  template <>
1136  class ScalarImpl< long long, false >
1137  {
1138  public:
1139  static inline bool isScalar( const TypedObject<long long> & )
1140  {
1141  return true;
1142  }
1143 
1144  static inline double getScalar( const TypedObject<long long> &to )
1145  {
1146  return to.getValue();
1147  }
1148 
1149  static inline void setScalar( TypedObject<long long> &to, double value )
1150  {
1151  to.getValue() = static_cast<long long>( value );
1152  }
1153 
1154  static inline bool equals( const TypedObject<long long> & o1,
1155  const GenericObject & o2 )
1156  {
1157  return o2.isScalar() && o1.getValue() == o2.getScalar();
1158  }
1159  };
1160 
1161 
1162  //---------------------//
1163  // unsigned long long //
1164  //---------------------//
1165 
1166  //---------------------------------------------------------------------------
1167  template <>
1168  class ScalarImpl< unsigned long long, false >
1169  {
1170  public:
1171  static inline bool isScalar( const TypedObject<unsigned long long> & )
1172  {
1173  return true;
1174  }
1175 
1176  static inline double getScalar( const TypedObject<unsigned long long> &to )
1177  {
1178  return to.getValue();
1179  }
1180 
1181  static inline void setScalar( TypedObject<unsigned long long> &to,
1182  double value )
1183  {
1184  to.getValue() = static_cast<unsigned long long>( value );
1185  }
1186 
1187  static inline bool equals( const TypedObject<unsigned long long> & o1,
1188  const GenericObject & o2 )
1189  {
1190  return o2.isScalar() && o1.getValue() == o2.getScalar();
1191  }
1192  };
1193 
1194 
1195  //---------//
1196  // float //
1197  //---------//
1198 
1199  //---------------------------------------------------------------------------
1200  template <>
1201  class ScalarImpl< float, false >
1202  {
1203  public:
1204  static inline bool isScalar( const TypedObject<float> & )
1205  {
1206  return true;
1207  }
1208 
1209  static inline double getScalar( const TypedObject<float> &to )
1210  {
1211  return to.getValue();
1212  }
1213 
1214  static inline void setScalar( TypedObject<float> &to, double value )
1215  {
1216  to.getValue() = static_cast<float>( value );
1217  }
1218 
1219  static inline bool equals( const TypedObject<float> & o1,
1220  const GenericObject & o2 )
1221  {
1222  return o2.isScalar() && o1.getValue() == o2.getScalar();
1223  }
1224  };
1225 
1226  //----------//
1227  // double //
1228  //----------//
1229 
1230  //---------------------------------------------------------------------------
1231  template <>
1232  class ScalarImpl< double, false >
1233  {
1234  public:
1235  static inline bool isScalar( const TypedObject<double> & )
1236  {
1237  return true;
1238  }
1239 
1240  static inline double getScalar( const TypedObject<double> &to )
1241  {
1242  return to.getValue();
1243  }
1244 
1245  static inline void setScalar( TypedObject<double> &to, double value )
1246  {
1247  to.getValue() = value;
1248  }
1249 
1250  static inline bool equals( const TypedObject<double> & o1,
1251  const GenericObject & o2 )
1252  {
1253  return o2.isScalar() && o1.getValue() == o2.getScalar();
1254  }
1255  };
1256 
1257 
1258  //----------//
1259  // string //
1260  //----------//
1261 
1262  //---------------------------------------------------------------------------
1263  template <>
1264  class ScalarImpl< std::string, false >
1265  {
1266  public:
1267  static inline bool isScalar( const TypedObject<std::string> & )
1268  {
1269  return false;
1270  }
1271 
1272  static inline double getScalar( const TypedObject<std::string> &to )
1273  {
1274  double x;
1275  stringTo( to.getValue(), x );
1276  return x;
1277  }
1278 
1279  static inline void setScalar( TypedObject<std::string> &to, double value )
1280  {
1281  to.getValue() = toString( value );
1282  }
1283 
1284  static inline bool equals( const TypedObject<std::string> & o1,
1285  const GenericObject & o2 )
1286  {
1287  return o2.isString() && o1.getValue() == o2.getString();
1288  }
1289  };
1290 
1291 
1292  //----------//
1293  // string //
1294  //----------//
1295 
1296  //---------------------------------------------------------------------------
1297  template <>
1298  class StringImpl< std::string, false >
1299  {
1300  public:
1301  static inline bool isString( const TypedObject< std::string> & )
1302  {
1303  return true;
1304  }
1305 
1306  static inline std::string getString( const TypedObject<std::string> &to )
1307  {
1308  return to.getValue();
1309  }
1310 
1311  static inline void setString( TypedObject<std::string> &to,
1312  const std::string &value )
1313  {
1314  to.getValue() = value;
1315  }
1316 
1317  static inline bool equals( const TypedObject<std::string> & o1,
1318  const GenericObject & o2 )
1319  {
1320  return o2.isString() && o1.getValue() == o2.getString();
1321  }
1322  };
1323 
1324  //---------------------------------------------------------------------------
1325  template <>
1326  inline std::string
1327  StringImpl< char, false >::getString( const TypedObject<char> &to )
1328  {
1329  return toString( to.getValue() );
1330  }
1331 
1332  template <>
1333  inline void
1335  const std::string &value )
1336  {
1337  stringTo( value, to.getValue() );
1338  }
1339 
1340  template <>
1341  inline std::string
1342  StringImpl< signed char, false >::getString( const TypedObject<signed char>
1343  &to )
1344  {
1345  return toString( to.getValue() );
1346  }
1347 
1348  template <>
1349  inline void
1350  StringImpl< signed char, false >::setString( TypedObject<signed char> &to,
1351  const std::string &value )
1352  {
1353  stringTo( value, to.getValue() );
1354  }
1355 
1356  template <>
1357  inline std::string
1359  TypedObject<unsigned char>
1360  &to )
1361  {
1362  return toString( to.getValue() );
1363  }
1364 
1365  template <>
1366  inline void
1368  &to,
1369  const std::string &value )
1370  {
1371  stringTo( value, to.getValue() );
1372  }
1373 
1374  template <>
1375  inline std::string
1376  StringImpl< short, false >::getString( const TypedObject<short> &to )
1377  {
1378  return toString( to.getValue() );
1379  }
1380 
1381  template <>
1382  inline void
1383  StringImpl< short, false >::setString( TypedObject<short> &to,
1384  const std::string &value )
1385  {
1386  stringTo( value, to.getValue() );
1387  }
1388 
1389  template <>
1390  inline std::string
1392  TypedObject<unsigned short>
1393  &to )
1394  {
1395  return toString( to.getValue() );
1396  }
1397 
1398  template <>
1399  inline void
1400  StringImpl< unsigned short, false >::setString( TypedObject<unsigned short> &
1401  to,
1402  const std::string &value )
1403  {
1404  stringTo( value, to.getValue() );
1405  }
1406 
1407  template <>
1408  inline std::string
1409  StringImpl< int, false >::getString( const TypedObject<int> &to )
1410  {
1411  return toString( to.getValue() );
1412  }
1413 
1414  template <>
1415  inline void
1417  const std::string &value )
1418  {
1419  stringTo( value, to.getValue() );
1420  }
1421 
1422  template <>
1423  inline std::string
1424  StringImpl< unsigned, false >::getString( const TypedObject<unsigned> &to )
1425  {
1426  return toString( to.getValue() );
1427  }
1428 
1429  template <>
1430  inline void
1431  StringImpl< unsigned, false >::setString( TypedObject<unsigned> &to,
1432  const std::string &value )
1433  {
1434  stringTo( value, to.getValue() );
1435  }
1436 
1437  template <>
1438  inline std::string
1439  StringImpl< long, false >::getString( const TypedObject<long> &to )
1440  {
1441  return toString( to.getValue() );
1442  }
1443 
1444  template <>
1445  inline void
1447  const std::string &value )
1448  {
1449  stringTo( value, to.getValue() );
1450  }
1451 
1452  template <>
1453  inline std::string
1455  TypedObject<unsigned long> &
1456  to )
1457  {
1458  return toString( to.getValue() );
1459  }
1460 
1461  template <>
1462  inline void
1463  StringImpl< unsigned long, false >::setString( TypedObject<unsigned long> &
1464  to,
1465  const std::string &value )
1466  {
1467  stringTo( value, to.getValue() );
1468  }
1469 
1470  template <>
1471  inline std::string
1472  StringImpl< float, false >::getString( const TypedObject<float> &to )
1473  {
1474  return toString( to.getValue() );
1475  }
1476 
1477  template <>
1478  inline void
1479  StringImpl< float, false >::setString( TypedObject<float> &to,
1480  const std::string &value )
1481  {
1482  stringTo( value, to.getValue() );
1483  }
1484 
1485  template <>
1486  inline std::string
1487  StringImpl< double, false >::getString( const TypedObject<double> &to )
1488  {
1489  return toString( to.getValue() );
1490  }
1491 
1492  template <>
1493  inline void
1494  StringImpl< double, false >::setString( TypedObject<double> &to,
1495  const std::string &value )
1496  {
1497  stringTo( value, to.getValue() );
1498  }
1499 
1500 
1501  //-------------//
1502  // vector<T> //
1503  //-------------//
1504 
1505 
1506  // SizeInterface
1507  //---------------------------------------------------------------------------
1508  template <typename T>
1509  class SizeImpl<std::vector<T>,false>
1510  {
1511  public:
1512  static inline size_t
1513  size( const TypedObject<std::vector<T> > &object )
1514  {
1515  return object.getValue().size();
1516  }
1517  };
1518 
1519 
1520  // ArrayInterface
1521  //---------------------------------------------------------------------------
1522  template <typename T>
1523  class ArrayImpl< std::vector<T>, false >
1524  {
1525  public:
1526 
1527  static inline bool isArray( const TypedObject< std::vector<T> > & )
1528  {
1529  return true;
1530  }
1531 
1532  static inline Object
1533  getArrayItem( const TypedObject<std::vector<T> > &object,
1534  int index )
1535  {
1536  // WARNING: const_cast is dangerous here !
1537  return Object::reference( const_cast<T &>
1538  ( object.getValue()[ index ] ) );
1539  }
1540 
1541  static inline void setArrayItem( TypedObject<std::vector<T> > &object,
1542  int index, Object value )
1543  {
1544  object.getValue()[ index ] = value->GenericObject::value<T>();
1545  }
1546 
1547  };
1548 
1549 
1550  // DynArrayInterface
1551  //---------------------------------------------------------------------------
1552  template <typename T>
1553  class DynArrayImpl< std::vector<T>, false >
1554  {
1555  public:
1556  static inline bool isDynArray( const TypedObject< std::vector<T> > & )
1557  {
1558  return true;
1559  }
1560 
1561  static inline void
1562  reserveArray( TypedObject< std::vector<T> > &object,
1563  size_t size )
1564  {
1565  object.getValue().reserve( size );
1566  }
1567 
1568  static inline void
1569  resizeArray( TypedObject< std::vector<T> > &object,
1570  size_t size )
1571  {
1572  object.getValue().resize( size );
1573  }
1574 
1575  static inline void
1576  removeArrayItem( TypedObject< std::vector<T> > &object,
1577  int index )
1578  {
1579  object.getValue().erase( object.getValue().begin() + index );
1580  }
1581 
1582 
1583  static inline void
1584  insertArrayItem( TypedObject< std::vector<T> > &object,
1585  int index, Object value )
1586  {
1587  if( index >= 0 )
1588  object.getValue().insert( object.getValue().begin() + index,
1589  value->GenericObject::value<T>() );
1590  else
1591  object.getValue().insert( object.getValue().end() + ( index + 1 ),
1592  value->GenericObject::value<T>() );
1593  }
1594  };
1595 
1596 
1597  // IterableInterface
1598  //---------------------------------------------------------------------------
1599  template <typename T>
1600  class IterableImpl<std::vector<T>, false>
1601  {
1602  public:
1603  static inline bool isIterable( const TypedObject< std::vector<T> > & )
1604  {
1605  return true;
1606  }
1607 
1608  static inline Object
1609  objectIterator( const TypedObject<std::vector<T> > & object );
1610 
1611  static inline bool equals( const TypedObject< std::vector<T> > & o1,
1612  const GenericObject & o2 )
1613  {
1614  if( !o2.isIterable() )
1615  return false;
1616  const std::vector<T> & self = o1.getValue();
1617  if( self.size() != o2.size() )
1618  return false;
1619  Object it, it2;
1620  for( it=o1.objectIterator(), it2=o2.objectIterator();
1621  it->isValid(); it->next(), it2->next() )
1622  {
1623  if( !it2->isValid() || it->currentValue() != it2->currentValue() )
1624  return false;
1625  }
1626  return true;
1627  }
1628 
1629  };
1630 
1631 
1632  template <typename V>
1633  class VectorIterator : public IteratorInterface
1634  {
1635  public:
1636  inline VectorIterator() {};
1637  // DictionaryIteratorInterface methods
1638  bool isValid() const;
1639  Object currentValue() const;
1640  void next();
1641 
1642  inline
1643  VectorIterator( const typename V::const_iterator &begin,
1644  const typename V::const_iterator &end ) :
1645  _iterator( begin ),
1646  _end( end ) {}
1647 
1648  typename V::const_iterator _iterator;
1649  typename V::const_iterator _end;
1650  };
1651 
1652 } // namespace interface_internal
1653 
1654 template <typename V>
1655 struct GenericObjectTypeDeclared< typename interface_internal::VectorIterator< V > >
1656 {
1657  static inline void check() {};
1658 };
1659 
1660 namespace interface_internal {
1661 
1662 
1663  template <typename V>
1665  {
1666  return _iterator != _end;
1667  }
1668 
1669  template <typename V>
1671  {
1672  // WARNING: const_cast is dangerous here !
1673  return Object::reference( const_cast<typename V::reference>( *_iterator ) );
1674  }
1675 
1676  template <>
1677  inline Object VectorIterator<std::vector<Object> >::currentValue() const
1678  {
1679  return *_iterator;
1680  }
1681 
1682  template <typename V>
1684  {
1685  ++_iterator;
1686  }
1687 
1688  template <typename T>
1689  inline Object IterableImpl<std::vector<T>, false>::objectIterator
1690  ( const TypedObject<std::vector<T> > & object )
1691  {
1692  return Object::value( VectorIterator<std::vector< T > >
1693  ( object.getValue().begin(),
1694  object.getValue().end() ) );
1695  }
1696 
1697 
1698  //------------------//
1699  // vector<Object> //
1700  //------------------//
1701 
1702  // ArrayInterface
1703  //---------------------------------------------------------------------------
1704  template<>
1705  inline Object
1707  false >::getArrayItem( const TypedObject<std::vector<Object> > &
1708  object, int index )
1709  {
1710  return object.getValue()[ index ];
1711  }
1712 
1713  template<>
1714  inline void
1715  ArrayImpl< std::vector<Object>,
1716  false >::setArrayItem( TypedObject<std::vector<Object> > &
1717  object, int index, Object value )
1718  {
1719  object.getValue()[ index ] = value;
1720  }
1721 
1722 
1723  // DynArrayInterface
1724  //---------------------------------------------------------------------------
1725  template<>
1726  inline void
1728  insertArrayItem( TypedObject< std::vector<Object> > &object,
1729  int index, Object value )
1730  {
1731  if( index >= 0 )
1732  object.getValue().insert( object.getValue().begin() + index, value );
1733  else
1734  object.getValue().insert( object.getValue().end() + (index + 1), value );
1735  }
1736 
1737 
1738 
1739 
1740  //----------//
1741  // set<T> //
1742  //----------//
1743 
1744 
1745  // SizeInterface
1746  //---------------------------------------------------------------------------
1747  template <typename T>
1748  class SizeImpl<std::set<T>,false>
1749  {
1750  public:
1751  static inline size_t
1752  size( const TypedObject<std::set<T> > &object )
1753  {
1754  return object.getValue().size();
1755  }
1756  };
1757 
1758 
1759  // IterableInterface
1760  //---------------------------------------------------------------------------
1761  template <typename S>
1762  class SetIterator : public IteratorInterface
1763  {
1764  public:
1765  inline SetIterator(): IteratorInterface() {};
1766  inline bool isValid() const
1767  {
1768  return _iterator != _end;
1769  };
1770  inline Object currentValue() const
1771  {
1772  return Object::reference( *_iterator );
1773  }
1774  inline void next()
1775  {
1776  ++_iterator;
1777  }
1778 
1779  inline
1780  SetIterator( const typename S::const_iterator &begin,
1781  const typename S::const_iterator &end )
1782  : IteratorInterface(), _iterator( begin ), _end( end ) {}
1783 
1784 
1785  typename S::const_iterator _iterator;
1786  typename S::const_iterator _end;
1787  };
1788 
1789 } // namespace interface_internal
1790 
1791 template <typename T>
1792 struct GenericObjectTypeDeclared< typename interface_internal::SetIterator<std::set<T> > >
1793 {
1794  static inline void check() {};
1795 };
1796 
1797 namespace interface_internal {
1798 
1799 
1800  template <typename T>
1801  class IterableImpl<std::set<T>, false>
1802  {
1803  public:
1804 
1805  static inline bool isIterable( const TypedObject< std::set<T> > & )
1806  {
1807  return true;
1808  }
1809 
1810  static inline Object
1811  objectIterator( const TypedObject<std::set<T> > & object );
1812 
1813  static inline bool equals(
1814  const TypedObject< std::set<T> > & o1,
1815  const GenericObject & o2 )
1816  {
1817  if( !o2.isIterable() )
1818  return false;
1819  const std::set<T> & self = o1.getValue();
1820  if( self.size() != o2.size() )
1821  return false;
1822  Object it2, value;
1823  for( it2=o2.objectIterator(); it2->isValid(); it2->next() )
1824  {
1825  value = it2->currentValue();
1826  if( !value.get() )
1827  return false;
1828  try
1829  {
1830  const T & tval = value->value<T>();
1831  if( self.find( tval ) == self.end() )
1832  return false;
1833  }
1834  catch( ... )
1835  {
1836  return false;
1837  }
1838  }
1839  return true;
1840  }
1841 
1842  };
1843 
1844 
1845  template <typename T> inline
1846  Object
1847  IterableImpl<std::set<T>, false>::objectIterator
1848  ( const TypedObject<std::set<T> > & object )
1849  {
1850  return Object::value( SetIterator< std::set<T> >( object.getValue().begin(),
1851  object.getValue().end() ) );
1852  }
1853 
1854  //---------------//
1855  // set<Object> //
1856  //---------------//
1857 
1858  template <>
1859  class SetIterator< std::set<Object> > : public IteratorInterface
1860  {
1861  public:
1862  inline SetIterator(): IteratorInterface() {};
1863  inline bool isValid() const
1864  {
1865  return _iterator != _end;
1866  };
1867  inline Object currentValue() const
1868  {
1869  return *_iterator;
1870  }
1871  inline void next()
1872  {
1873  ++_iterator;
1874  }
1875 
1876  inline
1877  SetIterator( const std::set<Object>::const_iterator &begin,
1878  const std::set<Object>::const_iterator &end )
1879  : IteratorInterface(), _iterator( begin ), _end( end ) {}
1880 
1881 
1882  std::set<Object>::const_iterator _iterator;
1883  std::set<Object>::const_iterator _end;
1884  };
1885 
1886 
1887  //------------//
1888  // map<T,U> //
1889  //------------//
1890 
1891 
1892  // SizeInterface
1893  //---------------------------------------------------------------------------
1894  template <typename T, typename U>
1895  class SizeImpl<std::map<T, U>,false>
1896  {
1897  public:
1898  static inline size_t
1899  size( const TypedObject<std::map<T, U> > &object )
1900  {
1901  return object.getValue().size();
1902  }
1903  };
1904 
1905 
1906  // IterableInterface
1907  //---------------------------------------------------------------------------
1908  template <typename T, typename U>
1909  class IterableImpl<std::map<T, U>, false>
1910  {
1911  public:
1912 
1913  static inline bool isIterable( const
1914  TypedObject< std::map<T, U> > & )
1915  {
1916  return true;
1917  }
1918 
1919  static inline Object
1920  objectIterator( const TypedObject<std::map<T, U> > & object );
1921 
1922  static inline bool equals(
1923  const TypedObject< std::map<T, U> > & o1,
1924  const GenericObject & o2 )
1925  {
1926  if( !o2.isDictionary() )
1927  return false;
1928  const std::map<T, U> & self = o1.getValue();
1929  if( self.size() != o2.size() )
1930  return false;
1931  Object it, value;
1932  for( it=o1.objectIterator(); it->isValid(); it->next() )
1933  {
1934  try
1935  {
1936  value = o2.getProperty( it->key() );
1937  if( it->currentValue() != value )
1938  return false;
1939  }
1940  catch( ... )
1941  {
1942  return false;
1943  }
1944  }
1945  return true;
1946  }
1947 
1948  };
1949 
1950  template <typename M>
1951  class MapIterator : public IteratorInterface
1952  {
1953  public:
1954  inline MapIterator() {_iterator = _end; };
1955  bool isValid() const
1956  {
1957  return _iterator != _end;
1958  }
1959  Object currentValue() const
1960  {
1961  return Object::reference( _iterator->second );
1962  }
1963  void next()
1964  {
1965  ++_iterator;
1966  }
1967 
1968  inline
1969  MapIterator( const typename M::const_iterator
1970  &begin,
1971  const typename M::const_iterator
1972  &end ) : IteratorInterface(),
1973  _iterator( begin ), _end( end )
1974  {
1975  }
1976 
1977  typename M::const_iterator _iterator;
1978  typename M::const_iterator _end;
1979  };
1980 } // namespace interface_internal
1981 
1982 template <typename T,typename U>
1983 struct GenericObjectTypeDeclared< typename interface_internal::MapIterator<std::map<T,U> > >
1984 {
1985  static inline void check() {};
1986 };
1987 
1988 namespace interface_internal {
1989 
1990  template <typename T, typename U> inline
1991  Object
1992  IterableImpl<std::map<T, U>, false>::objectIterator
1993  ( const TypedObject<std::map<T, U> > & object )
1994  {
1995  return Object::value( MapIterator< std::map<T, U> >
1996  ( object.getValue().begin(),
1997  object.getValue().end() ) );
1998  }
1999 
2000 
2001  //-----------------//
2002  // map<T,Object> //
2003  //-----------------//
2004 
2005  template <typename T>
2006  class IterableImpl<std::map<T, Object>, false>
2007  {
2008  public:
2009 
2010  static inline bool isIterable( const
2011  TypedObject< std::map<T, Object> > & )
2012  {
2013  return true;
2014  }
2015 
2016  static inline Object
2017  objectIterator( const TypedObject<std::map<T, Object> > & object );
2018 
2019  static inline bool equals(
2020  const TypedObject< std::map<T, Object> > & o1,
2021  const GenericObject & o2 )
2022  {
2023  if( !o2.isIterable() )
2024  return false;
2025  const std::map<T, Object> & self = o1.getValue();
2026  if( self.size() != o2.size() )
2027  return false;
2028  typename std::map<T, Object>::const_iterator it;
2029  Object it2, value;
2030  // the key T cannot be checked in o2. The only thing we can do here is
2031  // to check values in same order.
2032  // this is incomplete, agreed.
2033  for( it=self.begin(), it2=o2.objectIterator(); it!=self.end();
2034  ++it, it2->next() )
2035  {
2036  if( it->second != it2->currentValue() )
2037  return false;
2038  }
2039  return true;
2040  }
2041  };
2042 
2043 
2044  template <typename T>
2045  class MapIterator< std::map< T, Object > > : public IteratorInterface
2046  {
2047  public:
2048  inline MapIterator() { _iterator = _end; }
2049  bool isValid() const
2050  {
2051  return _iterator != _end;
2052  }
2053  Object currentValue() const
2054  {
2055  return _iterator->second;
2056  }
2057  void next()
2058  {
2059  ++_iterator;
2060  }
2061 
2062  inline
2063  MapIterator( const typename std::map< T, Object >::const_iterator &begin,
2064  const typename std::map< T, Object >::const_iterator &end ) :
2065  IteratorInterface(),
2066  _iterator( begin ),
2067  _end( end ) {}
2068 
2069  typename std::map< T, Object >::const_iterator _iterator;
2070  typename std::map< T, Object >::const_iterator _end;
2071  };
2072 
2073 
2074  template <typename T> inline
2075  Object
2076  IterableImpl<std::map<T, Object>, false>::objectIterator
2077  ( const TypedObject<std::map<T, Object> > & object )
2078  {
2079  return Object::value( MapIterator<std::map<T, Object> >( object.getValue().begin(),
2080  object.getValue().end() ) );
2081  }
2082 
2083 
2084  //-----------------//
2085  // map<string,U> //
2086  //-----------------//
2087 
2088 
2089  // DictionaryInterface
2090  //---------------------------------------------------------------------------
2091  template <typename T>
2092  class DictionaryImpl<std::map<std::string, T>, false>
2093  {
2094  public:
2095 
2096  static inline bool isDictionary( const
2097  TypedObject< std::map<std::string, T> > &)
2098  {
2099  return true;
2100  }
2101 
2102  static inline bool
2103  getProperty( const TypedObject<std::map<std::string, T> > & object,
2104  const std::string & key, Object & result )
2105  {
2106  typename std::map<std::string, T>::const_iterator
2107  i = object.getValue().find( key );
2108  if( i == object.getValue().end() )
2109  return false;
2110  // WARNING: const_cast is dangerous here !
2111  result = Object::reference( const_cast<T &>( i->second ) );
2112  return true;
2113  }
2114 
2115  static inline void
2116  setProperty( TypedObject<std::map<std::string, T> > & object,
2117  const std::string & key, Object value )
2118  {
2119  T & val = value->GenericObject::value<T>();
2120  object.getValue()[ key ] = val;
2121  }
2122 
2123  static inline bool
2124  removeProperty( TypedObject<std::map<std::string, T> > & object,
2125  const std::string & key )
2126  {
2127  return object.getValue().erase( key );
2128  }
2129 
2130  static inline void clearProperties( TypedObject<std::map<std::string, T> >
2131  & object )
2132  {
2133  object.getValue().clear();
2134  }
2135 
2136  static inline
2137  bool hasProperty( const TypedObject<std::map<std::string, T> > &
2138  object, const std::string & key )
2139  {
2140  return object.getValue().find( key ) != object.getValue().end();
2141  }
2142 
2143  static bool equals( const TypedObject<std::map<std::string, T> > &
2144  object, const GenericObject & other )
2145  {
2146  if( !other.isDictionary() )
2147  return false;
2148  const std::map<std::string, T> & self = object.getValue();
2149  if( self.size() != other.size() )
2150  return false;
2151  Object it, other_value;
2152  for( it=object.objectIterator(); it->isValid(); it->next() )
2153  {
2154  try
2155  {
2156  other_value = other.getProperty( it->key() );
2157  if( it->currentValue() != other_value )
2158  return false;
2159  }
2160  catch( ... )
2161  {
2162  return false;
2163  }
2164  }
2165  return true;
2166  }
2167  };
2168 
2169 
2170  // IterableInterface
2171  //---------------------------------------------------------------------------
2172  template <typename T>
2173  class MapIterator< std::map<std::string, T > > :
2174  public DictionaryIteratorInterface
2175  {
2176  public:
2177  inline MapIterator() { _iterator = _end; }
2178 
2179  bool isValid() const
2180  {
2181  return _iterator != _end;
2182  }
2183 
2184  Object currentValue() const
2185  {
2186  return Object::reference( _iterator->second );
2187  }
2188 
2189  void next()
2190  {
2191  ++_iterator;
2192  }
2193 
2194  std::string key() const
2195  {
2196  return _iterator->first;
2197  }
2198 
2199  inline
2200  MapIterator( const typename
2201  std::map< std::string, T >::const_iterator &begin,
2202  const typename
2203  std::map< std::string, T >::const_iterator &end ) :
2204  IteratorInterface(),
2205  _iterator( begin ),
2206  _end( end ) {}
2207 
2208  typename std::map< std::string, T >::const_iterator _iterator;
2209  typename std::map< std::string, T >::const_iterator _end;
2210  };
2211 
2212  template <typename T>
2213  class IterableImpl<std::map<std::string, T>, false>
2214  {
2215  public:
2216 
2217  static inline bool isIterable( const
2218  TypedObject< std::map<std::string, T> > & )
2219  {
2220  return true;
2221  }
2222 
2223  static inline Object
2224  objectIterator( const TypedObject<std::map<std::string, T> > & object );
2225 
2226  static inline bool equals(
2227  const TypedObject< std::map<std::string, T> > & o1,
2228  const GenericObject & o2 )
2229  {
2230  if( !o2.isDictionary() )
2231  return false;
2232  const std::map<std::string, T> & self = o1.getValue();
2233  if( self.size() != o2.size() )
2234  return false;
2235  Object it, value;
2236  for( it=o1.objectIterator(); it->isValid(); it->next() )
2237  {
2238  try
2239  {
2240  value = o2.getProperty( it->key() );
2241  if( it->currentValue() != value )
2242  return false;
2243  }
2244  catch( ... )
2245  {
2246  return false;
2247  }
2248  }
2249  return true;
2250  }
2251 
2252  };
2253 
2254 
2255  template <typename T> inline
2256  Object
2257  IterableImpl<std::map<std::string, T>, false>::objectIterator
2258  ( const TypedObject<std::map<std::string, T> > & object )
2259  {
2260  return Object::value( MapIterator<std::map<std::string, T> >
2261  ( object.getValue().begin(),
2262  object.getValue().end() ) );
2263  }
2264 
2265 
2266  //----------------------//
2267  // map<string,Object> //
2268  //----------------------//
2269 
2270  // IterableInterface
2271  //---------------------------------------------------------------------------
2272 
2273  template <>
2274  class MapIterator< std::map<std::string, Object > > :
2275  public DictionaryIteratorInterface
2276  {
2277  public:
2278  inline MapIterator() { _iterator = _end; }
2279 
2280  bool isValid() const
2281  {
2282  return _iterator != _end;
2283  }
2284 
2285  Object currentValue() const
2286  {
2287  return _iterator->second;
2288  }
2289 
2290  void next()
2291  {
2292  ++_iterator;
2293  }
2294 
2295  std::string key() const
2296  {
2297  return _iterator->first;
2298  }
2299 
2300  inline
2301  MapIterator( const std::map< std::string, Object >::const_iterator &begin,
2302  const std::map< std::string, Object >::const_iterator &end ) :
2303  IteratorInterface(), DictionaryIteratorInterface(),
2304  _iterator( begin ),
2305  _end( end ) {}
2306 
2307  std::map< std::string, Object >::const_iterator _iterator;
2308  std::map< std::string, Object >::const_iterator _end;
2309  };
2310 
2311  template <>
2312  class IterableImpl<std::map<std::string, Object>, false>
2313  {
2314  public:
2315 
2316 
2317  static inline bool isIterable( const
2318  TypedObject< std::map<std::string,
2319  Object> > & )
2320  {
2321  return true;
2322  }
2323 
2324  static inline Object
2325  objectIterator( const
2326  TypedObject<std::map<std::string, Object> > & object );
2327 
2328  static inline bool equals(
2329  const TypedObject< std::map<std::string, Object> > & o1,
2330  const GenericObject & o2 )
2331  {
2332  if( !o2.isDictionary() )
2333  return false;
2334  const std::map<std::string, Object> & self = o1.getValue();
2335  if( self.size() != o2.size() )
2336  return false;
2337  std::map<std::string, Object>::const_iterator it;
2338  Object value;
2339  for( it=self.begin(); it!=self.end(); ++it )
2340  {
2341  try
2342  {
2343  value = o2.getProperty( it->first );
2344  if( it->second != value )
2345  return false;
2346  }
2347  catch( ... )
2348  {
2349  return false;
2350  }
2351  }
2352  return true;
2353  }
2354 
2355  };
2356 
2357 
2358  inline
2359  Object
2360  IterableImpl<std::map<std::string, Object>, false>::objectIterator
2361  ( const TypedObject<std::map<std::string, Object> > & object )
2362  {
2363  return Object::value( MapIterator<std::map<std::string, Object> >
2364  ( object.getValue().begin(),
2365  object.getValue().end() ) );
2366  }
2367 
2368 
2369  // DictionaryInterface
2370  //---------------------------------------------------------------------------
2371 
2372  template<>
2373  inline bool
2375  ( const TypedObject<std::map<std::string, Object> > & object,
2376  const std::string & key, Object & result )
2377  {
2378  std::map<std::string, Object>::const_iterator
2379  i = object.getValue().find( key );
2380  if( i == object.getValue().end() )
2381  return false;
2382  result = i->second;
2383  return true;
2384  }
2385 
2386  template<>
2387  inline void
2388  DictionaryImpl<std::map<std::string, Object>, false>::setProperty
2389  ( TypedObject<std::map<std::string, Object> > & object,
2390  const std::string & key, Object value )
2391  {
2392  object.getValue()[ key ] = value;
2393  }
2394 
2395 
2396  //--------------//
2397  // map<int,T> //
2398  //--------------//
2399 
2400 
2401  // ArrayInterface
2402  //---------------------------------------------------------------------------
2403  template <typename T>
2404  class ArrayImpl< std::map<int,T>, false >
2405  {
2406  public:
2407 
2408  static inline bool isArray( const TypedObject< std::map<int,T> > & )
2409  {
2410  return true;
2411  }
2412 
2413  static inline Object
2414  getArrayItem( const TypedObject<std::map<int,T> > &object,
2415  int index )
2416  {
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() )
2420  return none(); // or throw ?
2421  // WARNING: const_cast is dangerous here !
2422  return Object::reference( const_cast<T &>( i->second ) );
2423  }
2424 
2425  static inline void setArrayItem( TypedObject<std::map<int,T> > &object,
2426  int index, Object value )
2427  {
2428  object.getValue()[ index ] = value->GenericObject::value<T>();
2429  }
2430 
2431  };
2432 
2433 
2434  // DynArrayInterface
2435  //---------------------------------------------------------------------------
2436  template <typename T>
2437  class DynArrayImpl< std::map<int,T>, false >
2438  {
2439  public:
2440  static inline bool isDynArray( const TypedObject< std::map<int,T> > & )
2441  {
2442  return true;
2443  }
2444 
2445  static inline void
2446  reserveArray( TypedObject< std::map<int,T> > &, size_t )
2447  {
2448  }
2449 
2450  static inline void
2451  resizeArray( TypedObject< std::map<int,T> > &, size_t )
2452  {
2453  }
2454 
2455  static inline void
2456  removeArrayItem( TypedObject< std::map<int,T> > &object,
2457  int index )
2458  {
2459  object.getValue().erase( index );
2460  }
2461 
2462 
2463  static inline void
2464  insertArrayItem( TypedObject< std::map<int,T> > &object,
2465  int index, Object value )
2466  {
2467  object.getValue()[ index ] = value->GenericObject::value<T>();
2468  }
2469  };
2470 
2471 
2472  //------------------//
2473  // map<int,Object> //
2474  //------------------//
2475 
2476  // ArrayInterface
2477  //---------------------------------------------------------------------------
2478  template<>
2479  inline Object
2481  false >::getArrayItem( const TypedObject<std::map<int,Object> > &
2482  object, int index )
2483  {
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() )
2487  return none(); // or throw ?
2488  return i->second;
2489  }
2490 
2491  template<>
2492  inline void
2493  ArrayImpl< std::map<int,Object>,
2494  false >::setArrayItem( TypedObject<std::map<int,Object> > &
2495  object, int index, Object value )
2496  {
2497  object.getValue()[ index ] = value;
2498  }
2499 
2500 
2501  // DynArrayInterface
2502  //---------------------------------------------------------------------------
2503  template<>
2504  inline void
2506  insertArrayItem( TypedObject< std::map<int,Object> > &object,
2507  int index, Object value )
2508  {
2509  object.getValue()[ index ] = value;
2510  }
2511 
2512 
2513  // IterableInterface
2514  //---------------------------------------------------------------------------
2515 
2516  template <>
2517  class MapIterator< std::map<int, Object > > :
2518  public IntKeyIteratorInterface
2519  {
2520  public:
2521  inline MapIterator() { _iterator = _end; }
2522 
2523  bool isValid() const
2524  {
2525  return _iterator != _end;
2526  }
2527 
2528  Object currentValue() const
2529  {
2530  return _iterator->second;
2531  }
2532 
2533  void next()
2534  {
2535  ++_iterator;
2536  }
2537 
2538  long intKey() const
2539  {
2540  return _iterator->first;
2541  }
2542 
2543  inline
2544  MapIterator( const std::map< int, Object >::const_iterator &begin,
2545  const std::map< int, Object >::const_iterator &end ) :
2546  IteratorInterface(), IntKeyIteratorInterface(),
2547  _iterator( begin ),
2548  _end( end ) {}
2549 
2550  std::map< int, Object >::const_iterator _iterator;
2551  std::map< int, Object >::const_iterator _end;
2552  };
2553 
2554  template <>
2555  class IterableImpl<std::map<int, Object>, false>
2556  {
2557  public:
2558 
2559 
2560  static inline bool isIterable( const
2561  TypedObject< std::map<int,
2562  Object> > & )
2563  {
2564  return true;
2565  }
2566 
2567  static inline Object
2568  objectIterator( const
2569  TypedObject<std::map<int, Object> > & object );
2570 
2571  static inline bool equals(
2572  const TypedObject< std::map<int, Object> > & o1,
2573  const GenericObject & o2 )
2574  {
2575  const std::map<int, Object> & self = o1.getValue();
2576  if( self.size() != o2.size() )
2577  return false;
2578  std::map<int, Object>::const_iterator it;
2579  Object o2it = o2.objectIterator();
2580  if( !o2it || !o2it->isValid() || !o2it->isIntKeyIterator() )
2581  return false;
2582  for( it=self.begin(); it!=self.end(); ++it, o2it->next() )
2583  {
2584  if( !o2it || !o2it->isValid() )
2585  return false;
2586  try
2587  {
2588  if( it->first != o2it->intKey() )
2589  return false;
2590  if( it->second != o2it->currentValue() )
2591  return false;
2592  }
2593  catch( ... )
2594  {
2595  return false;
2596  }
2597  }
2598  return true;
2599  }
2600 
2601  };
2602 
2603 
2604  inline
2605  Object
2606  IterableImpl<std::map<int, Object>, false>::objectIterator
2607  ( const TypedObject<std::map<int, Object> > & object )
2608  {
2609  return Object::value( MapIterator<std::map<int, Object> >
2610  ( object.getValue().begin(),
2611  object.getValue().end() ) );
2612  }
2613 
2614 /*
2615 
2616  template <typename T>
2617  class DictionaryImpl<std::map<int, T>, false>
2618  {
2619  public:
2620 
2621  static inline bool
2622  getProperty( const TypedObject<std::map<int, T> > & object,
2623  const std::string & key, Object & result )
2624  {
2625  int kval;
2626  stringTo( key, kval );
2627  typename std::map<int, T>::const_iterator
2628  i = object.getValue().find( kval );
2629  if( i == object.getValue().end() )
2630  return false;
2631  result = Object::reference( i->second );
2632  return true;
2633  }
2634 
2635  static inline void
2636  setProperty( TypedObject<std::map<int, T> > & object,
2637  const std::string & key, Object value )
2638  {
2639  T & val = value->GenericObject::value<T>();
2640  int kval;
2641  stringTo( key, kval );
2642  object.getValue()[ kval ] = val;
2643  }
2644 
2645  static inline bool
2646  removeProperty( TypedObject<std::map<int, T> > & object,
2647  const std::string & key )
2648  {
2649  int kval;
2650  stringTo( key, kval );
2651  return object.getValue().erase( kval );
2652  }
2653 
2654  static inline
2655  bool hasProperty( const TypedObject<std::map<int, T> > & object,
2656  const std::string & key )
2657  {
2658  int kval;
2659  stringTo( key, kval );
2660  return object.getValue().find( kval ) != object.getValue().end();
2661  }
2662 
2663  static inline
2664  void clearProperties( TypedObject<std::map<int, T> > & object )
2665  {
2666  object.getValue().clear();
2667  }
2668  };
2669 
2670 
2671  //-------------------//
2672  // map<int,Object> //
2673  //-------------------//
2674 
2675 
2676  template<>
2677  inline void
2678  DictionaryImpl<std::map<int, Object>, false>::setProperty
2679  ( TypedObject<std::map<int, Object> > & object,
2680  const std::string & key, Object value )
2681  {
2682  int kval;
2683  stringTo( key, kval );
2684  object.getValue()[ kval ] = value;
2685  }
2686 
2687 */
2688 } // namespace interface_internal
2689 
2690 #endif // DOXYGEN_HIDE_INTERNAL_CLASSES
2691 
2692 
2693 
2694 
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)
static bool equals(const TypedObject< unsigned char > &o1, const GenericObject &o2)
static std::string getString(const TypedObject< T > &)
static void setArrayItem(TypedObject< std::map< int, T > > &object, int index, Object value)
static void clearProperties(TypedObject< std::map< std::string, T > > &object)
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)
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)
STL namespace.
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)
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 &)
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)
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 > > &)
static size_t size(const TypedObject< T > &)
static bool isDictionaryIterator(const TypedObject< T > &)
static bool isDynArray(const TypedObject< T > &object)
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 > &)
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 > > &)
static Object getArrayItem(const TypedObject< T > &object, int index)
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
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 > > &)
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)
static bool equals(const TypedObject< T > &o1, const GenericObject &o2)
static bool isString(const TypedObject< T > &object)
static Object currentValue(const TypedObject< T > &object)