cartobase  4.5.0
object.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_H
35 #define CARTOBASE_OBJECT_OBJECT_H
36 
38 #include <cartobase/type/types.h>
41 #include <cartobase/smart/rcptr.h>
43 #include <stdexcept>
44 #include <string>
45 #include <set>
46 #include <vector>
47 #include <typeinfo>
48 #ifdef CARTO_DEBUG
50 #include <iostream>
51 #endif // #ifdef CARTO_DEBUG
53 
54 
55 #define DECLARE_GENERIC_OBJECT_TYPE( T ) \
56 template <> \
57 struct GenericObjectTypeDeclared< T > \
58 { \
59  static inline void check() {}; \
60 }; \
61 template <> \
62 void DictionaryInterface::setProperty( const std::string &key, \
63  T const &value ); \
64 template <> \
65 bool DictionaryInterface::getProperty( const std::string &key, T &value ) const; \
66 extern template class TypedObject< T >; \
67 extern template class ValueObject< T >; \
68 extern template class ReferenceObject< T >; \
69 extern template class PointerObject< T >; \
70 extern template \
71 T const &GenericObject::value< T >() const; \
72 extern template \
73 T &GenericObject::value< T >(); \
74 extern template \
75 bool GenericObject::value( T &dest ) const; \
76 extern template \
77 void GenericObject::setValue( T const & x ); \
78 extern template bool DictionaryInterface:: \
79 getProperty( const std::string &, T & ) const; \
80 extern template void DictionaryInterface:: \
81 setProperty( const std::string &, T const & ); \
82 
83 
84 namespace carto
85 {
86 class GenericObject;
87 template <typename T> class TypedObject;
88 class Object;
89 
90 
91  //-------------//
92  // Interface //
93  //-------------//
94 
95  class Interface
96  {
97  public:
98  virtual ~Interface();
99  };
100 
101 
102  //-------------------//
103  // ScalarInterface //
104  //-------------------//
105 
108  class ScalarInterface : public virtual Interface
109  {
110  public:
111 
112  virtual ~ScalarInterface();
113 
118  virtual bool isScalar() const;
123  virtual double getScalar() const = 0;
129  virtual void setScalar( double ) = 0;
131  virtual bool operator == ( const ScalarInterface & other ) const;
132  virtual bool operator != ( const ScalarInterface & other ) const
133  { return ! operator == ( other ); }
134  };
135 
136 
137  //-------------------//
138  // StringInterface //
139  //-------------------//
140 
142  class StringInterface : public virtual Interface
143  {
144  public:
145 
146  virtual ~StringInterface();
147 
152  virtual bool isString() const;
157  virtual std::string getString() const = 0;
163  virtual void setString( const std::string & ) = 0;
165  virtual bool operator == ( const StringInterface & other ) const;
166  virtual bool operator != ( const StringInterface & other ) const
167  { return ! operator == ( other ); }
168  };
169 
170 
171  //------------------//
172  // SizeInterface //
173  //------------------//
174 
176  class SizeInterface : public virtual Interface
177  {
178  public:
179 
180  virtual ~SizeInterface();
181 
186  virtual size_t size() const = 0;
187  };
188 
189 
190  //----------------------//
191  // IterableInterface //
192  //----------------------//
193 
195  class IterableInterface : public virtual Interface
196  {
197  public:
198 
199  virtual ~IterableInterface();
200 
205  virtual bool isIterable() const;
207  virtual Object objectIterator() const = 0;
209  virtual bool operator == ( const IterableInterface & other ) const;
210  virtual bool operator != ( const IterableInterface & other ) const
211  { return ! operator == ( other ); }
212  };
213 
214 
215  //----------------------//
216  // IteratorInterface //
217  //----------------------//
218 
234  class IteratorInterface : public virtual Interface
235  {
236  public:
237 
238  virtual ~IteratorInterface();
239 
244  virtual bool isIterator() const;
247  virtual bool isValid() const = 0;
249  virtual Object currentValue() const = 0;
251  virtual void next() = 0;
252  };
253 
254 
255  //--------------------------------//
256  // DictionaryIteratorInterface //
257  //--------------------------------//
258 
264  {
265  public:
266 
268 
273  virtual bool isDictionaryIterator() const;
275  virtual std::string key() const = 0;
276  };
277 
278 
279  //------------------//
280  // ArrayInterface //
281  //------------------//
282 
285  class ArrayInterface : public virtual SizeInterface,
286  public virtual IterableInterface
287  {
288  public:
289 
290  virtual ~ArrayInterface();
291 
296  virtual bool isArray() const;
304  virtual Object getArrayItem( int index ) const = 0;
305  virtual void setArrayItem( int, Object ) = 0;
306  virtual size_t size() const = 0;
307  };
308 
309 
310  //---------------------//
311  // DynArrayInterface //
312  //---------------------//
313 
315  class DynArrayInterface : public virtual ArrayInterface
316  {
317  public:
318 
319  virtual ~DynArrayInterface();
320 
325  virtual bool isDynArray() const;
328  virtual void reserveArray( size_t ) = 0;
332  virtual void resizeArray( size_t ) = 0;
335  virtual void removeArrayItem( int ) = 0;
338  virtual void insertArrayItem( int, Object ) = 0;
339  };
340 
341 
342  //------------------------//
343  // DictionaryInterface //
344  //------------------------//
345 
354  class DictionaryInterface : public virtual SizeInterface,
355  public virtual IterableInterface
356  {
357  public:
358 
359  virtual ~DictionaryInterface();
360 
365  virtual bool isDictionary() const;
370  virtual bool getProperty( const std::string & key,
371  Object & value ) const = 0;
374  Object getProperty( const std::string & ) const;
379  Object getProperty( Object key ) const;
387  template <typename T> bool getProperty( const std::string & key,
388  T & value ) const;
389 
397  virtual void setProperty( const std::string & key, Object value ) = 0;
399  void setProperty( const std::string &, const char * );
404  template <typename T> void setProperty( const std::string &, const T & );
405 
410  virtual bool removeProperty( const std::string & ) = 0;
411 
413  virtual bool hasProperty( const std::string & key ) const = 0;
415  virtual void clearProperties();
418  virtual void copyProperties( Object source );
420  virtual bool operator == ( const DictionaryInterface & other ) const;
421  virtual bool operator != ( const DictionaryInterface & other ) const
422  { return ! operator == ( other ); }
423  };
424 
425 
426  //----------------------//
427  // SyntaxedInterface //
428  //----------------------//
429 
435  class SyntaxedInterface : public virtual Interface
436  {
437  public:
438 
439  virtual ~SyntaxedInterface();
440 
441  virtual std::string getSyntax() const = 0;
442  virtual bool hasSyntax() const = 0;
443  virtual void setSyntax( const std::string& syntactic ) = 0;
445  virtual bool operator == ( const SyntaxedInterface & other ) const;
446  virtual bool operator != ( const SyntaxedInterface & other ) const
447  { return ! operator == ( other ); }
448  };
449 
450 
451  //------------------//
452  // NoneInterface //
453  //------------------//
454 
457  class NoneInterface : public virtual Interface
458  {
459  public:
460 
461  virtual ~NoneInterface();
462 
467  virtual bool isNone() const = 0;
468  };
469 
470 
471  //-----------------//
472  // GenericObject //
473 //-----------------//
474 
476  public virtual RCObject,
477  public virtual StringInterface,
478  public virtual ScalarInterface,
479  public virtual DynArrayInterface,
480  public virtual DictionaryInterface,
481  public virtual IterableInterface,
482  public virtual IteratorInterface,
483  public virtual DictionaryIteratorInterface,
484  public virtual NoneInterface
485 {
486 public:
487  virtual ~GenericObject();
488 
490  virtual Object clone() const = 0;
492  virtual std::string type() const = 0;
493 
497  template<typename T> const T & value() const;
501  template<typename T> T & value();
505  template <typename T> bool value( T & ) const;
509  template<typename T> void setValue( const T &val );
510  virtual void setValue( Object val ) = 0;
511 
512  virtual size_t size() const = 0;
513 
533  template <typename T>
534  T *getInterface();
536  template <typename T>
537  const T *getInterface() const;
538  virtual bool operator == ( const GenericObject & other ) const;
539  virtual bool operator != ( const GenericObject & other ) const
540  { return ! operator == ( other ); }
541 
542 protected:
543  friend class Object;
544 
545  virtual Interface *_getGenericInterface() = 0;
546  virtual const void *_getAddressOfValue() const = 0;
547 };
548 
549 
550  //----------//
551  // Object //
552 //----------//
553 
554 class Object : public rc_ptr<GenericObject>
555 {
556 public:
557  inline Object();
558  inline Object( const Object & );
559  inline Object( GenericObject* data, bool externalowner = false );
560  inline ~Object();
562  inline Object & operator = ( const Object & );
563 
565  template <typename T>
566  static inline Object value();
567 
570  template <typename T>
571  static inline Object value( const T & );
572 
577  template <typename T>
578  static inline Object reference( T & value );
579 
583  template <typename T>
584  static inline Object reference( const T & value );
585 
587  bool isSameObject( const Object & ) const;
598  bool isNone() const;
599  inline bool operator == ( const Object & other ) const;
600  inline bool operator != ( const Object & other ) const
601  { return ! operator == ( other ); }
602 };
603 
604 
605  //------------------//
606  // TypedObject<T> //
607 //------------------//
608 
609 template <typename T>
610 class TypedObject : public GenericObject
611 {
612 public:
613  TypedObject();
614  virtual ~TypedObject();
615 
616  // This function should be pure virtual but it is mandatory to
617  // do explicit instanciation of TypedObject and it is not possible
618  // with pure virtual classes.
619  virtual T &getValue();
620  inline const T &getValue() const;
621  virtual void setValue( Object val );
622 
623  // This function should be pure virtual but it is mandatory to
624  // do explicit instanciation of TypedObject and it is not possible
625  // with pure virtual classes.
626  virtual Object clone() const;
627 
628  virtual std::string type() const;
629 
630  // ScalarInterface methods
631  virtual bool isScalar() const;
632  virtual double getScalar() const;
633  virtual void setScalar( double );
634 
635  // StringInterface methods
636  virtual bool isString() const;
637  virtual std::string getString() const;
638  virtual void setString( const std::string & );
639 
640  // ArrayInterface methods
641  virtual bool isArray() const;
642  virtual Object getArrayItem( int index ) const;
643  virtual void setArrayItem( int, Object );
644  virtual size_t size() const;
645 
646  // DynArrayInterface methods
647  virtual bool isDynArray() const;
648  virtual void reserveArray( size_t );
649  virtual void resizeArray( size_t );
650  virtual void removeArrayItem( int );
651  virtual void insertArrayItem( int, Object );
652 
653  // DictionaryInterface methods
654  virtual bool getProperty( const std::string &, Object & ) const;
655  virtual bool isDictionary() const;
657 
658  virtual void setProperty( const std::string &, Object );
660 
661  virtual bool removeProperty( const std::string & );
662  virtual bool hasProperty( const std::string & ) const;
663  virtual void clearProperties();
664 
665  // IterableInterface methods
666  virtual bool isIterable() const;
667  virtual Object objectIterator() const;
668 
669  // IteratorInterface methods
670  virtual bool isIterator() const;
671  virtual bool isValid() const;
672  virtual Object currentValue() const;
673  virtual void next();
674 
675  // DictionaryIteratorInterface methods
676  virtual bool isDictionaryIterator() const;
677  virtual std::string key() const;
678 
679  // NoneInterface methods
680  virtual bool isNone() const;
681 
682  virtual bool operator == ( const GenericObject & other ) const;
683 
684 private:
685  Interface *_getGenericInterface();
686  const void *_getAddressOfValue() const;
687 #ifdef CARTO_DEBUG
688  static bool _debugInstantiation;
689 #endif // ifdef CARTO_DEBUG
690 };
691 
692 
693 //-----------------------------------------------------------------------------
695 // is automatically instanitiated on a non declared type.
696 template <typename T>
698 {
699  static inline void check( T *x = NULL )
700  {
701  you_must_use_DECLARE_GENERIC_OBJECT_TYPE( x );
702  }
703 };
704 
705 
706 //-----------------------------------------------------------------------------
707 template <typename T>
708 class TypedObject<const T> : public GenericObject
709 {
710 private:
711  // Forbid TypedObject on constant type
712  inline TypedObject() {};
713 };
714 
715 
716 
717 #ifdef CARTO_DEBUG
718 template <typename T>
719 class PrintInstantiation
720 {
721 public:
722 
723  static bool doIt( bool * );
724 };
725 
726 
727 template <typename T>
728 class PrintInstantiation<const T>
729 {
730 public:
731 
732  static bool doIt( bool * );
733 };
734 #endif // ifdef CARTO_DEBUG
735 
736 
737 
738 
739  #if 0
740  //--------------------------//
741  // ForbidInheritance<T,U> //
742 //--------------------------//
743 template <typename T, bool B>
744 class CompileErrorIfFalse
745 {
746  static inline void check() {}
747 };
748 
749 template <typename T>
750 class CompileErrorIfFalse<T,false>
751 {
752  static inline void check()
753  {
754  T::cannot_compile_this_code();
755  }
756 };
757 
758 template <typename T, typename U>
759 class ForbidInheritance : CompileErrorIfFalse< T, SUPERSUBCLASS( T, U ) >
760 {
761 };
762 #endif
763 
764 
765  //------------------//
766  // ValueObject<T> //
767 //------------------//
768 
769 template <typename T>
770 class ValueObject : public TypedObject<T>
771 {
772 public:
773  inline ValueObject();
774  inline ValueObject( const T & x );
775  virtual ~ValueObject();
776 
777  virtual T &getValue();
778 
779  virtual Object clone() const;
780 
781 private:
782 
783  // class _Test : ForbidInheritance< GenericObject, T > {};
784  mutable T _value;
785 };
786 
787 
788  //-----------------------//
789  // Useful common types //
790 //-----------------------//
791 
796 typedef std::map<std::string, Object> Dictionary;
797 typedef std::map<int, Object> IntDictionary;
798 typedef std::map<Object, Object> ObjectDictionary;
800 typedef std::vector<Object> ObjectVector;
801 
802 
803  //----------------------//
804  // ReferenceObject<T> //
805 //----------------------//
806 
807 template <typename T>
808 class ReferenceObject : public TypedObject<T>
809 {
810 public:
811  inline ReferenceObject( T &x );
812  virtual ~ReferenceObject();
813  virtual T &getValue();
814 
815  virtual Object clone() const;
816 
817 private:
818 
819  // class _Test : ForbidInheritance< GenericObject, T > {};
820  T &_value;
821 };
822 
823 
824  //--------------------//
825  // PointerObject<T> //
826 //--------------------//
827 
828 template <typename T>
829 class PointerObject : public TypedObject<T>
830 {
831 public:
832  inline PointerObject( T &x, bool owner );
833  virtual ~PointerObject();
834  virtual T &getValue();
835 
836  virtual Object clone() const;
837 
838 private:
839 
840  mutable T *_pvalue;
841  bool _owner;
842 };
843 
844 
845  //--------//
846  // none //
847 //--------//
848 
850 extern Object none();
851 
852 
853  //----------------//
854  // object_to<T> //
855 //----------------//
856 
857 //-----------------------------------------------------------------------------
858 template <typename T>
859 inline void object_to( Object o, T & r );
860 
861 //-----------------------------------------------------------------------------
862 /* This specialization is a workaaround to avoid a bug in gcc 3.4.3 (at least).
863  This function needs to be compiled and I really really don't know why.
864  Otherwise it seems not to be called at all (hopefully)
865 */
866 template <typename T>
867 inline void object_to( Object, const T & );
868 
869 
870  //------------------//
871  // instantiations //
872 //------------------//
873 
875 DECLARE_GENERIC_OBJECT_TYPE( unsigned )
877 DECLARE_GENERIC_OBJECT_TYPE( signed char )
878 DECLARE_GENERIC_OBJECT_TYPE( unsigned char )
880 DECLARE_GENERIC_OBJECT_TYPE( unsigned short )
882 DECLARE_GENERIC_OBJECT_TYPE( unsigned long )
883 DECLARE_GENERIC_OBJECT_TYPE( long long )
884 DECLARE_GENERIC_OBJECT_TYPE( unsigned long long )
888 DECLARE_GENERIC_OBJECT_TYPE( std::string )
891 
892 // DECLARE_GENERIC_OBJECT_TYPE cannot be used for Object because it refers to
893 // extern explicit template instantiations of
894 // DictionaryInterface::getProperty<Object> and
895 // DictionaryInterface::setProperty<Object>, which conflict with the (pure
896 // virtual) overload of these methods.
897 template <>
899 {
900  static inline void check() {};
901 };
902 template <>
903 void DictionaryInterface::setProperty( const std::string &key,
904  Object const &value );
905 template <>
906 bool DictionaryInterface::getProperty( const std::string &key, Object &value ) const;
907 extern template class TypedObject< Object >;
908 extern template class ValueObject< Object >;
909 extern template class ReferenceObject< Object >;
910 extern template class PointerObject< Object >;
911 extern template
912 Object const &GenericObject::value< Object >() const;
913 extern template
914 Object &GenericObject::value< Object >();
915 extern template
916 bool GenericObject::value( Object &dest ) const;
917 extern template
918 void GenericObject::setValue( Object const & x );
919 
920 
921 template <>
923 {
924  static inline void check() {};
925 };
926 extern template class TypedObject< GenericObject >;
927 extern template class ReferenceObject< GenericObject >;
928 extern template class PointerObject< GenericObject >;
929 
930 
931 DECLARE_GENERIC_OBJECT_TYPE( std::vector<int> )
932 DECLARE_GENERIC_OBJECT_TYPE( std::vector<unsigned> )
933 DECLARE_GENERIC_OBJECT_TYPE( std::vector<char> )
934 DECLARE_GENERIC_OBJECT_TYPE( std::vector<signed char> )
935 DECLARE_GENERIC_OBJECT_TYPE( std::vector<unsigned char> )
936 DECLARE_GENERIC_OBJECT_TYPE( std::vector<short> )
937 DECLARE_GENERIC_OBJECT_TYPE( std::vector<unsigned short> )
938 DECLARE_GENERIC_OBJECT_TYPE( std::vector<long> )
939 DECLARE_GENERIC_OBJECT_TYPE( std::vector<unsigned long> )
940 DECLARE_GENERIC_OBJECT_TYPE( std::vector<long long> )
941 DECLARE_GENERIC_OBJECT_TYPE( std::vector<unsigned long long> )
942 DECLARE_GENERIC_OBJECT_TYPE( std::vector<float> )
943 DECLARE_GENERIC_OBJECT_TYPE( std::vector<double> )
944 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::string> )
945 DECLARE_GENERIC_OBJECT_TYPE( std::vector<Object> )
946 DECLARE_GENERIC_OBJECT_TYPE( std::vector<Void> )
947 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::string> * )
948 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::vector<int> > )
949 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::vector<unsigned> > )
950 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::vector<char> > )
951 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::vector<signed char> > )
952 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::vector<unsigned char> > )
953 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::vector<short> > )
954 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::vector<unsigned short> > )
955 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::vector<long> > )
956 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::vector<unsigned long> > )
957 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::vector<long long> > )
958 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::vector<unsigned long long> > )
959 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::vector<float> > )
960 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::vector<double> > )
961 DECLARE_GENERIC_OBJECT_TYPE( std::vector<std::set<unsigned> > )
962 
963 DECLARE_GENERIC_OBJECT_TYPE( std::set<int> )
964 DECLARE_GENERIC_OBJECT_TYPE( std::set<unsigned> )
965 DECLARE_GENERIC_OBJECT_TYPE( std::set<char> )
966 DECLARE_GENERIC_OBJECT_TYPE( std::set<signed char> )
967 DECLARE_GENERIC_OBJECT_TYPE( std::set<unsigned char> )
968 DECLARE_GENERIC_OBJECT_TYPE( std::set<short> )
969 DECLARE_GENERIC_OBJECT_TYPE( std::set<unsigned short> )
970 DECLARE_GENERIC_OBJECT_TYPE( std::set<long> )
971 DECLARE_GENERIC_OBJECT_TYPE( std::set<unsigned long> )
972 DECLARE_GENERIC_OBJECT_TYPE( std::set<long long> )
973 DECLARE_GENERIC_OBJECT_TYPE( std::set<unsigned long long> )
974 DECLARE_GENERIC_OBJECT_TYPE( std::set<float> )
975 DECLARE_GENERIC_OBJECT_TYPE( std::set<double> )
976 DECLARE_GENERIC_OBJECT_TYPE( std::set<std::string> )
977 DECLARE_GENERIC_OBJECT_TYPE( std::set<Object> )
978 
979 #define _TMP_ std::map< std::string, int >
981 #undef _TMP_
982 #define _TMP_ std::map< std::string, unsigned >
984 #undef _TMP_
985 #define _TMP_ std::map< std::string, char >
987 #undef _TMP_
988 #define _TMP_ std::map< std::string, signed char >
990 #undef _TMP_
991 #define _TMP_ std::map< std::string, unsigned char >
993 #undef _TMP_
994 #define _TMP_ std::map< std::string, short >
996 #undef _TMP_
997 #define _TMP_ std::map< std::string, unsigned short >
999 #undef _TMP_
1000 #define _TMP_ std::map< std::string, long >
1002 #undef _TMP_
1003 #define _TMP_ std::map< std::string, unsigned long >
1005 #undef _TMP_
1006 #define _TMP_ std::map< std::string, long long >
1008 #undef _TMP_
1009 #define _TMP_ std::map< std::string, unsigned long long >
1011 #undef _TMP_
1012 #define _TMP_ std::map< std::string, float >
1014 #undef _TMP_
1015 #define _TMP_ std::map< std::string, double >
1017 #undef _TMP_
1018 #define _TMP_ std::map< std::string, bool >
1020 #undef _TMP_
1021 #define _TMP_ std::map< std::string, std::string >
1023 #undef _TMP_
1024 #define _TMP_ std::map< std::string, Object >
1026 #undef _TMP_
1027 #define TMP std::map< int, Object >
1029 #undef TMP
1030 #define TMP std::map< float, Object >
1032 #undef TMP
1033 #define TMP std::map< Object, Object >
1035 #undef TMP
1036 
1037 #define _TMP_ std::map< std::string, std::vector<int> >
1039 #undef _TMP_
1040 #define _TMP_ std::map< std::string, std::vector<unsigned> >
1042 #undef _TMP_
1043 #define _TMP_ std::map< std::string, std::vector<char> >
1045 #undef _TMP_
1046 #define _TMP_ std::map< std::string, std::vector<signed char> >
1048 #undef _TMP_
1049 #define _TMP_ std::map< std::string, std::vector<unsigned char> >
1051 #undef _TMP_
1052 #define _TMP_ std::map< std::string, std::vector<short> >
1054 #undef _TMP_
1055 #define _TMP_ std::map< std::string, std::vector<unsigned short> >
1057 #undef _TMP_
1058 #define _TMP_ std::map< std::string, std::vector<long> >
1060 #undef _TMP_
1061 #define _TMP_ std::map< std::string, std::vector<unsigned long> >
1063 #undef _TMP_
1064 #define _TMP_ std::map< std::string, std::vector<long long> >
1066 #undef _TMP_
1067 #define _TMP_ std::map< std::string, std::vector<unsigned long long> >
1069 #undef _TMP_
1070 #define _TMP_ std::map< std::string, std::vector<float> >
1072 #undef _TMP_
1073 #define _TMP_ std::map< std::string, std::vector<double> >
1075 #undef _TMP_
1076 #define _TMP_ std::map< std::string, std::vector<std::string> >
1078 #undef _TMP_
1079 #define _TMP_ std::map< std::string, std::vector<Object> >
1081 #undef _TMP_
1082 
1083 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<int> > )
1084 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<unsigned> > )
1085 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<char> > )
1086 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<signed char> > )
1087 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<unsigned char> > )
1088 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<short> > )
1089 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<unsigned short> > )
1090 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<long> > )
1091 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<unsigned long> > )
1092 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<long long> > )
1093 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<unsigned long long> > )
1094 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<float> > )
1095 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<double> > )
1096 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<Object> > )
1097 DECLARE_GENERIC_OBJECT_TYPE( rc_ptr< std::vector<std::string> > )
1098 
1099 #define _TMP_ rc_ptr< std::map< std::string, int > >
1101 #undef _TMP_
1102 #define _TMP_ rc_ptr< std::map< std::string, unsigned > >
1104 #undef _TMP_
1105 #define _TMP_ rc_ptr< std::map< std::string, char > >
1107 #undef _TMP_
1108 #define _TMP_ rc_ptr< std::map< std::string, signed char > >
1110 #undef _TMP_
1111 #define _TMP_ rc_ptr< std::map< std::string, unsigned char > >
1113 #undef _TMP_
1114 #define _TMP_ rc_ptr< std::map< std::string, short > >
1116 #undef _TMP_
1117 #define _TMP_ rc_ptr< std::map< std::string, unsigned short > >
1119 #undef _TMP_
1120 #define _TMP_ rc_ptr< std::map< std::string, long > >
1122 #undef _TMP_
1123 #define _TMP_ rc_ptr< std::map< std::string, unsigned long > >
1125 #undef _TMP_
1126 #define _TMP_ rc_ptr< std::map< std::string, long long > >
1128 #undef _TMP_
1129 #define _TMP_ rc_ptr< std::map< std::string, unsigned long long > >
1131 #undef _TMP_
1132 #define _TMP_ rc_ptr< std::map< std::string, float > >
1134 #undef _TMP_
1135 #define _TMP_ rc_ptr< std::map< std::string, double > >
1137 #undef _TMP_
1138 #define _TMP_ rc_ptr< std::map< std::string, bool > >
1140 #undef _TMP_
1141 #define _TMP_ rc_ptr< std::map< std::string, std::string > >
1143 #undef _TMP_
1144 #define _TMP_ rc_ptr< std::map< std::string, Object > >
1146 #undef _TMP_
1147 #define _TMP_ rc_ptr< std::map< int, Object > >
1149 #undef _TMP_
1150 #define _TMP_ rc_ptr< std::map< float, Object > >
1152 #undef _TMP_
1153 #define TMP rc_ptr< std::map< Object, Object > >
1155 #undef TMP
1156 
1157 #define _TMP_ rc_ptr< std::map< std::string, std::vector<int> > >
1159 #undef _TMP_
1160 #define _TMP_ rc_ptr< std::map< std::string, std::vector<unsigned> > >
1162 #undef _TMP_
1163 #define _TMP_ rc_ptr< std::map< std::string, std::vector<char> > >
1165 #undef _TMP_
1166 #define _TMP_ rc_ptr< std::map< std::string, std::vector<signed char> > >
1168 #undef _TMP_
1169 #define _TMP_ rc_ptr< std::map< std::string, std::vector<unsigned char> > >
1171 #undef _TMP_
1172 #define _TMP_ rc_ptr< std::map< std::string, std::vector<short> > >
1174 #undef _TMP_
1175 #define _TMP_ rc_ptr< std::map< std::string, std::vector<unsigned short> > >
1177 #undef _TMP_
1178 #define _TMP_ rc_ptr< std::map< std::string, std::vector<long> > >
1180 #undef _TMP_
1181 #define _TMP_ rc_ptr< std::map< std::string, std::vector<unsigned long> > >
1183 #undef _TMP_
1184 #define _TMP_ rc_ptr< std::map< std::string, std::vector<long long> > >
1186 #undef _TMP_
1187 #define _TMP_ rc_ptr< std::map< std::string, std::vector<unsigned long long> > >
1189 #undef _TMP_
1190 #define _TMP_ rc_ptr< std::map< std::string, std::vector<float> > >
1192 #undef _TMP_
1193 #define _TMP_ rc_ptr< std::map< std::string, std::vector<double> > >
1195 #undef _TMP_
1196 #define _TMP_ rc_ptr< std::map< std::string, std::vector<std::string> > >
1198 #undef _TMP_
1199 #define _TMP_ rc_ptr< std::map< std::string, std::vector<Object> > >
1201 #undef _TMP_
1202 
1204 DECLARE_GENERIC_OBJECT_TYPE( Semantic )
1207 
1208 template <typename T>
1209 inline void object_to( Object o, T & r );
1210 template <>
1211 void object_to( Object o, bool &r );
1212 template <>
1213 void object_to( Object o, unsigned char &r );
1214 template <>
1215 void object_to( Object o, signed char &r );
1216 template <>
1217 inline void object_to( Object o, char &r );
1218 template <>
1219 void object_to( Object o, unsigned short &r );
1220 template <>
1221 void object_to( Object o, short &r );
1222 template <>
1223 void object_to( Object o, unsigned &r );
1224 template <>
1225 void object_to( Object o, int &r );
1226 template <>
1227 void object_to( Object o, float &r );
1228 template <>
1229 inline void object_to( Object o, double &r );
1230 template <>
1231 void object_to( Object o, std::string &r );
1232 template <>
1233 inline void object_to( Object o, Object & r );
1234 
1235 
1236 
1237  //----------------//
1238  // object_to<T> //
1239 //----------------//
1240 
1241 //-----------------------------------------------------------------------------
1242 template <typename T>
1243 inline void object_to( Object o, T & r )
1244 {
1245  r = o->GenericObject::value<T>();
1246 }
1247 
1248 //-----------------------------------------------------------------------------
1249 /* This specialization is a workaaround to avoid a bug in gcc 3.4.3 (at least).
1250  This function needs to be compiled and I really really don't know why.
1251  Otherwise it seems not to be called at all (hopefully)
1252 */
1253 template <typename T>
1254 inline void object_to( Object, const T & )
1255 {
1256  throw std::runtime_error( std::string( "cannot convert object to const " ) +
1257  DataTypeCode<T>::name() + " (this is probably a "
1258  "bug)" );
1259 }
1260 
1261 //-----------------------------------------------------------------------------
1262 template <>
1263 inline void object_to( Object o, Object & r )
1264 {
1265  r = o;
1266 }
1267 
1268 
1269 //-----------------------------------------------------------------------------
1270 template <>
1271 inline void object_to( Object o, char &r )
1272 {
1273 #ifdef __CHAR_UNSIGNED__
1274  object_to<unsigned char>( o, reinterpret_cast<unsigned char &>( r ) );
1275 #else
1276  object_to<signed char>( o, reinterpret_cast<signed char &>( r ) );
1277 #endif
1278 }
1279 
1280 
1281 
1282 
1283 //-----------------------------------------------------------------------------
1284 template <>
1285 inline void object_to( Object o, double &r )
1286 {
1287  r = o->getScalar();
1288 }
1289 
1290 
1291  //------------------------//
1292  // DictionaryInterface //
1293 //------------------------//
1294 
1295 
1296 //---------------------------------------------------------------------------
1297 template <typename T>
1298 void DictionaryInterface::setProperty( const std::string &,
1299  const T &value )
1300 {
1301  you_must_use_DECLARE_GENERIC_OBJECT_TYPE( value );
1302 }
1303 
1304 
1305 //---------------------------------------------------------------------------
1306 template <typename T>
1307 bool DictionaryInterface::getProperty( const std::string &, T &value ) const
1308 {
1309  return you_must_use_DECLARE_GENERIC_OBJECT_TYPE( value );
1310 }
1311 
1312 
1313  //-----------------//
1314  // GenericObject //
1315 //-----------------//
1316 
1317 //-----------------------------------------------------------------------------
1318 template <class T>
1320 {
1321  return dynamic_cast<T *>( _getGenericInterface() );
1322 }
1323 
1324 //-----------------------------------------------------------------------------
1325 template <class T>
1326 inline const T *GenericObject::getInterface() const
1327 {
1328  /* using const_cast is ugly, OK, right.
1329  But it avoids redefining a const version of _getGenericInterface() with
1330  exactly the same contents. I'm lazy today.
1331  */
1332  return dynamic_cast<T *>( const_cast<GenericObject *>( this )
1333  ->_getGenericInterface() );
1334 }
1335 
1336 
1337  //----------//
1338  // Object //
1339 //----------//
1340 
1341 
1342 //-----------------------------------------------------------------------------
1344 {
1345 }
1346 
1347 //-----------------------------------------------------------------------------
1348 inline Object::Object( const Object &x ) : rc_ptr<GenericObject>( x )
1349 {
1350 }
1351 
1352 //-----------------------------------------------------------------------------
1353 inline Object::Object( GenericObject *x, bool externalowner )
1354  : rc_ptr<GenericObject>( x, externalowner )
1355 {
1356 }
1357 
1358 //-----------------------------------------------------------------------------
1360 {
1361 }
1362 
1363 
1364 //-----------------------------------------------------------------------------
1365 inline Object & Object::operator = ( const Object &other )
1366 {
1367  if ( this != &other ) {
1369  ( static_cast< const rc_ptr<GenericObject> & >( other ) );
1370  }
1371  return *this;
1372 }
1373 
1374 
1375 //-----------------------------------------------------------------------------
1376 inline bool Object::operator == ( const Object &other ) const
1377 {
1378  if ( this == &other || ( !get() && !other.get() ) )
1379  return true;
1380  if( !get() || !other.get() )
1381  return false;
1382  return *get() == *other.get();
1383 }
1384 
1385 
1386 #if 0
1387 //-----------------------------------------------------------------------------
1388 template <typename T, bool>
1389 class ObjectValueTrait
1390 {
1391 public:
1392  static inline Object value()
1393  {
1394  return Object( static_cast<GenericObject *>( new ValueObject<T>() ) );
1395  }
1396  static inline Object value( const T &v )
1397  {
1398  return Object( static_cast<GenericObject *>( new ValueObject<T>( v ) ) );
1399  }
1400 };
1401 
1402 //-----------------------------------------------------------------------------
1403 template <typename T>
1404 class ObjectValueTrait<T,true>
1405 {
1406 public:
1407  static inline Object value()
1408  {
1409  return Object( (GenericObject *) new T );
1410  }
1411  static inline Object value( const T &v )
1412  {
1413  return v.clone();
1414  }
1415 };
1416 #endif
1417 
1418 //-----------------------------------------------------------------------------
1419 template <typename T>
1421 {
1422  return Object( static_cast<GenericObject *>( new ValueObject<T>() ) );
1423  // return ObjectValueTrait< T, SUPERSUBCLASS(GenericObject,T) >::value();
1424 }
1425 
1426 
1427 //-----------------------------------------------------------------------------
1428 template <typename T>
1429 inline Object Object::value( const T &v )
1430 {
1431  return Object( static_cast<GenericObject *>( new ValueObject<T>( v ) ) );
1432  // return ObjectValueTrait< T, SUPERSUBCLASS(GenericObject,T) >::value( v );
1433 }
1434 
1435 
1436 //-----------------------------------------------------------------------------
1437 template <>
1438 inline Object Object::value( const Object &value )
1439 {
1440  return value;
1441 }
1442 
1443 
1444 #if 0
1445 //-----------------------------------------------------------------------------
1446 template <typename T, bool>
1447 class ObjectReferenceTrait
1448 {
1449 public:
1450  static inline Object reference( T &v )
1451  {
1452  return Object( static_cast< GenericObject *>( new ReferenceObject<T>( v ) ) );
1453  }
1454 };
1455 
1456 //-----------------------------------------------------------------------------
1457 template <typename T>
1458 class ObjectReferenceTrait<T,true>
1459 {
1460 public:
1461  static inline Object reference( T &v )
1462  {
1463  return Object( &v );
1464  }
1465 };
1466 #endif
1467 
1468 //-----------------------------------------------------------------------------
1469 template <typename T>
1470 inline Object Object::reference( T &value )
1471 {
1472  return Object( static_cast< GenericObject *>( new ReferenceObject<T>( value ) ) );
1473  // return ObjectReferenceTrait< T, SUPERSUBCLASS( GenericObject, T ) >::reference( value );
1474 }
1475 
1476 
1477 //-----------------------------------------------------------------------------
1478 template <typename T>
1479 inline Object Object::reference( const T &value )
1480 {
1481  return Object::reference( const_cast< T & >( value ) );
1482 }
1483 
1484 
1485 //-----------------------------------------------------------------------------
1486 inline bool Object::isNone() const
1487 {
1488  // may be replaced by a comparison to the global none object
1489  return get() == 0;
1490 }
1491 
1492 
1493  //--------------------------------//
1494  // DataTypeCode<ValueObject<T>> //
1495 //--------------------------------//
1496 
1497 #ifndef DOXYGEN_HIDE_INTERNAL_CLASSES
1498 
1499 template<typename T> class DataTypeCode< ValueObject<T> >
1500 {
1501  public:
1502  static inline std::string objectType()
1503  { return "ValueObject"; }
1504  static inline std::string dataType()
1505  { return DataTypeCode<T>::name(); }
1506  static inline std::string name()
1507  {
1508  return std::string("ValueObject of ") + DataTypeCode< T >::name();
1509  }
1510 };
1511 
1512 #endif
1513 
1514 
1515  //------------------//
1516  // ValueObject<T> //
1517 //------------------//
1518 
1519 //-----------------------------------------------------------------------------
1520 template <typename T>
1522 {
1523 }
1524 
1525 
1526 
1527 //-----------------------------------------------------------------------------
1528 template <typename T>
1529 inline ValueObject<T>::ValueObject( const T &x )
1530 {
1531  _value = x;
1532 }
1533 
1534 
1535  //----------------------//
1536  // ReferenceObject<T> //
1537 //----------------------//
1538 
1539 //-----------------------------------------------------------------------------
1540 template <typename T>
1542  : _value( x )
1543 {
1544 }
1545 
1546  //--------------------//
1547  // PointerObject<T> //
1548 //--------------------//
1549 
1550 //-----------------------------------------------------------------------------
1551 template <typename T>
1552 inline PointerObject<T>::PointerObject( T &x, bool owner )
1553  : _pvalue( &x ), _owner( owner )
1554 {
1555 }
1556 
1557 
1558  //------------------------//
1559  // DataTypeCode<Object> //
1560 //------------------------//
1561 
1562 //-----------------------------------------------------------------------------
1563 template<> inline std::string DataTypeCode<Object>::dataType()
1564 {
1565  return "object";
1566 }
1567 
1568 
1569 //-----------------------------------------------------------------------------
1570 template<> inline std::string DataTypeCode<Object>::objectType()
1571 {
1572  return "object";
1573 }
1574 
1575 
1576 //-----------------------------------------------------------------------------
1577 template<> inline std::string DataTypeCode<Object>::name()
1578 {
1579  return "object";
1580 }
1581 
1582 
1583  //-------------------------------//
1584  // DataTypeCode<GenericObject> //
1585 //-------------------------------//
1586 
1587 //-----------------------------------------------------------------------------
1588 template<> inline std::string DataTypeCode<GenericObject>::dataType()
1589 {
1590  return "any";
1591 }
1592 
1593 
1594 //-----------------------------------------------------------------------------
1595 template<> inline std::string DataTypeCode<GenericObject>::objectType()
1596 {
1597  return "genericobject";
1598 }
1599 
1600 
1601 //-----------------------------------------------------------------------------
1602 template<> inline std::string DataTypeCode<GenericObject>::name()
1603 {
1604  return "genericobject";
1605 }
1606 
1607 
1608 
1609  //------------------------------------//
1610  // DataTypeCode<ReferenceObject<T>> //
1611 //------------------------------------//
1612 
1613 #ifndef DOXYGEN_HIDE_INTERNAL_CLASSES
1614 
1615 template<typename T> class DataTypeCode< ReferenceObject<T> >
1616 {
1617  public:
1618  static inline std::string objectType()
1619  { return "ReferenceObject"; }
1620  static inline std::string dataType()
1621  { return DataTypeCode<T>::name(); }
1622  static inline std::string name()
1623  {
1624  return std::string("ReferenceObject of ") + DataTypeCode< T >::name();
1625  }
1626 };
1627 
1628 #endif
1629 
1630 
1631 //-----------------------------------------------------------------------------
1632 
1633 
1634 } // namespace carto
1635 
1636 
1637 #endif
virtual ~ValueObject()
Definition: object_d.h:671
virtual bool operator==(const ScalarInterface &other) const
equality test
#define DECLARE_GENERIC_OBJECT_TYPE(T)
Definition: object.h:55
virtual bool isNone() const
Returns false if the stored object doesn't actually implement the NoneInterface API (needed since all...
Definition: object_d.h:631
Objects whose value may be represented as a character string.
Definition: object.h:142
virtual void setArrayItem(int, Object)=0
std::map< Object, Object > ObjectDictionary
Definition: object.h:798
virtual Object getArrayItem(int index) const
Get the element of index index.
Definition: object_d.h:378
virtual ~Interface()
virtual bool isDictionary() const
Returns false if the stored object doesn't actually implement the DictionaryInterface API (needed sin...
Definition: object_d.h:472
virtual bool getProperty(const std::string &key, Object &value) const =0
Access the element ok key key.
virtual std::string key() const
Access the key of the current dictionary element.
Definition: object_d.h:616
T * getInterface()
Obtain a specific Interface subclass.
Definition: object.h:1319
base abstract generic object class.
Definition: object.h:475
virtual bool hasSyntax() const =0
virtual size_t size() const
Number of sub-elements.
Definition: object_d.h:458
virtual Object getArrayItem(int index) const =0
Get the element of index index.
virtual ~SizeInterface()
std::map< int, Object > IntDictionary
Definition: object.h:797
virtual bool isIterator() const
Returns false if the stored object doesn't actually implement the IteratorInterface API (needed since...
virtual bool isValid() const
true if the iterator points to a valid value, false when the end of the iterable container has been r...
Definition: object_d.h:571
virtual bool isNone() const =0
Returns false if the stored object doesn't actually implement the NoneInterface API (needed since all...
virtual void setSyntax(const std::string &syntactic)=0
virtual size_t size() const =0
Number of sub-elements.
Specialized NoneInterface for empty objects (null, None).
Definition: object.h:457
virtual void setScalar(double)=0
The double value will be converted to the actual storage type before it is set in the contained objec...
virtual void reserveArray(size_t)
like the STL vector::reserve(), memory is reserved but no element is stored
Definition: object_d.h:412
virtual bool operator==(const IterableInterface &other) const
equality test
ArrayInterface represents any container whose elements can be accessed via an integer index...
Definition: object.h:285
virtual bool hasProperty(const std::string &) const
check if an element exists under the key key
Definition: object_d.h:523
virtual void insertArrayItem(int, Object)=0
inserts an element into the array.
virtual T & getValue()
Definition: object_d.h:678
virtual void reserveArray(size_t)=0
like the STL vector::reserve(), memory is reserved but no element is stored
This class is just a hint to convert an actual data type to an identifier string used in input/output...
Definition: types.h:110
virtual T & getValue()
Definition: object_d.h:248
virtual bool isScalar() const
Returns false if the stored object doesn't actually implement the ScalarInterface API (needed since a...
virtual ~NoneInterface()
Base class for reference counted objects (intrusive)
Definition: rcptr.h:105
virtual bool isString() const
Returns false if the stored object doesn't actually implement the StringInterface API (needed since a...
#define _TMP_
Definition: object.h:1199
Container objects which can be iterated.
Definition: object.h:195
virtual void next()
Point to the next element of the iterable container.
Definition: object_d.h:591
virtual ~PointerObject()
Definition: object_d.h:724
virtual void clearProperties()
clear the dictionary
storage wrapper, derived and instanciable template class
Definition: object.h:770
virtual Object clone() const
cloning copy
Definition: object_d.h:256
virtual bool hasProperty(const std::string &key) const =0
check if an element exists under the key key
static void check(T *x=NULL)
Definition: object.h:699
virtual Object clone() const
cloning copy
Definition: object_d.h:712
static Object reference(T &value)
factory function: builds an Object by referencing the value from a ReferenceObject storage wrapper...
Definition: object.h:1470
virtual bool operator!=(const DictionaryInterface &other) const
Definition: object.h:421
const T & value() const
Retreive value in object, const reference.
Definition: object_d.h:130
virtual Object currentValue() const
Access the value of the element pointed to by the iterator.
Definition: object_d.h:581
bool operator==(const carto::block< T, N > &b1, const carto::block< T, N > &b2)
Definition: block.h:252
virtual bool removeProperty(const std::string &)
remove an element.
Definition: object_d.h:503
virtual void insertArrayItem(int, Object)
inserts an element into the array.
Definition: object_d.h:442
bool isSameObject(const Object &) const
compares the addresses of the underlying GenericObjects
virtual Object clone() const
cloning copy
Definition: object_d.h:686
virtual ~TypedObject()
Definition: object_d.h:201
virtual std::string type() const
type() returns the DataTypeCode::name() of the underlying object type
Definition: object_d.h:224
virtual bool operator!=(const StringInterface &other) const
Definition: object.h:166
storage wrapper, derived but still abstract template class
Definition: object.h:87
virtual void resizeArray(size_t)
resize the array.
Definition: object_d.h:422
std::map< std::string, Syntax > SyntaxSet
This lookup table associates a syntactic attribute with its syntax.
Definition: syntax.h:83
virtual double getScalar() const =0
Obtain a scalar value, possibly after a conversion.
virtual bool isDynArray() const
Returns false if the stored object doesn't actually implement the DynArrayInterface API (needed since...
friend class Object
Definition: object.h:543
virtual double getScalar() const
Obtain a scalar value, possibly after a conversion.
Definition: object_d.h:314
Reference-counting pointer.
Definition: rcptr.h:606
virtual void setScalar(double)
The double value will be converted to the actual storage type before it is set in the contained objec...
Definition: object_d.h:323
static std::string objectType()
Definition: object.h:1502
All scalar numbers implement the ScalarInterface (all ints, float, double...)
Definition: object.h:108
void object_to(Object o, T &r)
Definition: object.h:1243
virtual void resizeArray(size_t)=0
resize the array.
Specialized IteratorInterface for dictionaries.
Definition: object.h:263
T * get() const
Definition: rcptr.h:625
virtual std::string getString() const
Obtain a string value, possibly after a conversion.
Definition: object_d.h:346
virtual bool isIterator() const
Returns false if the stored object doesn't actually implement the IteratorInterface API (needed since...
Definition: object_d.h:562
virtual bool operator==(const StringInterface &other) const
equality test
virtual void clearProperties()
clear the dictionary
Definition: object_d.h:513
static std::string name()
Definition: types.h:243
virtual void removeArrayItem(int)=0
removes an element from the array.
#define CARTOBASE_API
bool operator!=(const Object &other) const
Definition: object.h:600
A Syntaxed object is an object containing an additional character string giving it a kind of type (a ...
Definition: object.h:435
void setValue(const T &val)
Store value in object by copying it.
Definition: object_d.h:171
static std::string objectType()
Definition: types.h:223
virtual Object objectIterator() const =0
returns an object implementing the IteratorIntrerface
std::vector< Object > ObjectVector
Common type used for ArrayInterface implementation.
Definition: object.h:800
#define TMP
Definition: object.h:1153
Class to force a compilation error when a generic object.
Definition: object.h:697
virtual void next()=0
Point to the next element of the iterable container.
virtual size_t size() const =0
Number of sub-elements.
SemanticSet Syntax
Specify syntax for syntactic attributes.
Definition: syntax.h:78
virtual bool isDynArray() const
Returns false if the stored object doesn't actually implement the DynArrayInterface API (needed since...
Definition: object_d.h:403
virtual bool operator!=(const IterableInterface &other) const
Definition: object.h:210
virtual Object clone() const
cloning copy
Definition: object_d.h:739
virtual bool isDictionary() const
Returns false if the stored object doesn't actually implement the DictionaryInterface API (needed sin...
virtual void setProperty(const std::string &key, Object value)=0
Set (insert or replace) the element of key key with the value object.
All container objects inherit the SizeInterface.
Definition: object.h:176
virtual Interface * _getGenericInterface()=0
virtual bool operator==(const SyntaxedInterface &other) const
equality test
storage wrapper, derived and instanciable template class
Definition: object.h:808
virtual T & getValue()
Definition: object_d.h:732
static Object value()
factory function: builds an Object by using the default constructor
Definition: object.h:1420
virtual ~ReferenceObject()
Definition: object_d.h:698
virtual bool isArray() const
Returns false if the stored object doesn't actually implement the ArrayInterface API (needed since al...
virtual bool isDictionaryIterator() const
Returns false if the stored object doesn't actually implement the DictionaryIteratorInterface API (ne...
virtual bool operator!=(const ScalarInterface &other) const
Definition: object.h:132
virtual bool getProperty(const std::string &, Object &) const
Access the element ok key key.
Definition: object_d.h:482
virtual bool operator!=(const SyntaxedInterface &other) const
Definition: object.h:446
virtual Object currentValue() const =0
Access the value of the element pointed to by the iterator.
virtual bool isDictionaryIterator() const
Returns false if the stored object doesn't actually implement the DictionaryIteratorInterface API (ne...
Definition: object_d.h:606
std::map< std::string, Object > Dictionary
Common type used for DictionaryInterface implementation.
Definition: object.h:796
bool isNone() const
check if we hold a "none" object.
Definition: object.h:1486
static std::string dataType()
Definition: types.h:230
virtual void setValue(Object val)
Definition: object_d.h:216
virtual bool isArray() const
Returns false if the stored object doesn't actually implement the ArrayInterface API (needed since al...
Definition: object_d.h:369
virtual void setString(const std::string &)=0
The string value may be converted to the actual storage type before it is set in the contained object...
virtual std::string getString() const =0
Obtain a string value, possibly after a conversion.
virtual void setProperty(const std::string &, Object)
Set (insert or replace) the element of key key with the value object.
Definition: object_d.h:493
virtual bool isIterable() const
Returns false if the stored object doesn't actually implement the IterableInterface API (needed since...
Definition: object_d.h:538
virtual bool removeProperty(const std::string &)=0
remove an element.
virtual bool operator==(const DictionaryInterface &other) const
equality test
Void does not contain anything.
Definition: types.h:60
virtual void copyProperties(Object source)
copy all properties of the source object to this object.
Object none()
An empty singleton object (holds a null pointer)
virtual bool isIterable() const
Returns false if the stored object doesn't actually implement the IterableInterface API (needed since...
virtual bool operator==(const GenericObject &other) const
Definition: object_d.h:641
A dynamic array has resize and insertion capabilities (like a STL vector)
Definition: object.h:315
virtual Object objectIterator() const
returns an object implementing the IteratorIntrerface
Definition: object_d.h:547
virtual bool isString() const
Returns false if the stored object doesn't actually implement the StringInterface API (needed since a...
Definition: object_d.h:337
virtual void removeArrayItem(int)
removes an element from the array.
Definition: object_d.h:432
bool operator==(const Object &other) const
Definition: object.h:1376
virtual T & getValue()
Definition: object_d.h:705
Object & operator=(const Object &)
uses the reference-counting so the underlying GenericObject is shared
Definition: object.h:1365
PointerObject(T &x, bool owner)
Definition: object.h:1552
virtual bool isValid() const =0
true if the iterator points to a valid value, false when the end of the iterable container has been r...
virtual bool isScalar() const
Returns false if the stored object doesn't actually implement the ScalarInterface API (needed since a...
Definition: object_d.h:305
virtual std::string key() const =0
Access the key of the current dictionary element.
An iterator object is a reference to another object.
Definition: object.h:234
virtual std::string getSyntax() const =0
Interface for dictionary-like objects.
Definition: object.h:354
virtual void setString(const std::string &)
The string value may be converted to the actual storage type before it is set in the contained object...
Definition: object_d.h:355
virtual void setArrayItem(int, Object)
Definition: object_d.h:388