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