cartobase
5.0.5
|
Interface for dictionary-like objects. More...
#include <cartobase/object/object.h>
Public Member Functions | |
virtual | ~DictionaryInterface () |
virtual bool | isDictionary () const |
Returns false if the stored object doesn't actually implement the DictionaryInterface API (needed since all GenericObject inherit this interface whatever they actually contain) More... | |
virtual bool | getProperty (const std::string &key, Object &value) const =0 |
Access the element ok key key . More... | |
Object | getProperty (const std::string &) const |
same as the other getProperty() functions except that the value object is returned. More... | |
Object | getProperty (Object key) const |
same as the other getProperty() functions except that the key is contained in the key argument (which must implement the StringInterface). More... | |
template<typename T > | |
bool | getProperty (const std::string &key, T &value) const |
same as the other getProperty() functions except that the value object must be of exact type T and is copied to the value argument. More... | |
virtual void | setProperty (const std::string &key, Object value)=0 |
Set (insert or replace) the element of key key with the value object. More... | |
void | setProperty (const std::string &, const char *) |
specific specialization: C strings are stored as std::string objects More... | |
template<typename T > | |
void | setProperty (const std::string &, const T &) |
same as the other setProperty() functions except that the value to be set is of the arbitrary type T and will possibly be stored in an Object. More... | |
virtual bool | removeProperty (const std::string &)=0 |
remove an element. More... | |
virtual bool | hasProperty (const std::string &key) const =0 |
check if an element exists under the key key More... | |
virtual void | clearProperties () |
clear the dictionary More... | |
virtual void | copyProperties (Object source) |
copy all properties of the source object to this object. More... | |
virtual bool | operator== (const DictionaryInterface &other) const |
equality test More... | |
virtual bool | operator!= (const DictionaryInterface &other) const |
template<> | |
void | setProperty (const std::string &key, Object const &value) |
template<> | |
bool | getProperty (const std::string &key, Object &value) const |
Public Member Functions inherited from carto::SizeInterface | |
virtual | ~SizeInterface () |
virtual size_t | size () const =0 |
Number of sub-elements. More... | |
Public Member Functions inherited from carto::Interface | |
virtual | ~Interface () |
Public Member Functions inherited from carto::IterableInterface | |
virtual | ~IterableInterface () |
virtual bool | isIterable () const |
Returns false if the stored object doesn't actually implement the IterableInterface API (needed since all GenericObject inherit this interface whatever they actually contain) More... | |
virtual Object | objectIterator () const =0 |
returns an object implementing the IteratorIntrerface More... | |
virtual bool | operator== (const IterableInterface &other) const |
equality test More... | |
virtual bool | operator!= (const IterableInterface &other) const |
Interface for dictionary-like objects.
DictionaryInterface is the generic interface for dictionary-like objects. This includes wrappers to STL maps with a string key, or the more specialized PropertySet.
Dictionary items are called "properties" and are stored using a string key.
|
virtual |
|
virtual |
clear the dictionary
Reimplemented in carto::TypedObject< T >, carto::TypedObject< SyntaxedInterfaceType< T > >, and carto::PropertySet.
Referenced by carto::TypedObject< SyntaxedInterfaceType< T > >::clearProperties().
|
virtual |
copy all properties of the source
object to this
object.
source
must implement DictionaryInterface
|
pure virtual |
Access the element ok key key
.
value
is filled with a wrapper to the selected element. If it fails (key not found for instance), an exception is thrown.
Implemented in carto::TypedObject< T >, carto::TypedObject< SyntaxedInterfaceType< T > >, and carto::PropertySet.
Referenced by carto::GenericObjectTypeDeclared< Object >::check(), carto::interface_internal::DictionaryImpl< T, true >::clearProperties(), and carto::Object::operator!=().
Object carto::DictionaryInterface::getProperty | ( | const std::string & | ) | const |
same as the other getProperty() functions except that the value object is returned.
An exception is thrown in case of failure.
same as the other getProperty() functions except that the key is contained in the key
argument (which must implement the StringInterface).
The value object is returned. An exception is thrown in case of failure.
bool carto::DictionaryInterface::getProperty | ( | const std::string & | key, |
T & | value | ||
) | const |
same as the other getProperty() functions except that the value object must be of exact type T
and is copied to the value
argument.
No exception is thrown if the key is not found or the selected element is not of type T
, but the return value is false
if it fails. An exception is still thrown if this function is called on an object that doesn't actually implement the DictionaryInterface API.
bool carto::DictionaryInterface::getProperty | ( | const std::string & | key, |
Object & | value | ||
) | const |
|
pure virtual |
check if an element exists under the key key
Implemented in carto::TypedObject< T >, carto::TypedObject< SyntaxedInterfaceType< T > >, and carto::PropertySet.
|
virtual |
Returns false if the stored object doesn't actually implement the DictionaryInterface API (needed since all GenericObject inherit this interface whatever they actually contain)
Reimplemented in carto::TypedObject< T >, and carto::TypedObject< SyntaxedInterfaceType< T > >.
Referenced by carto::interface_internal::DictionaryImpl< T, true >::removeProperty().
|
inlinevirtual |
Definition at line 470 of file object.h.
References operator==().
|
virtual |
equality test
|
pure virtual |
remove an element.
Note that on some dictionary implementations (PropertySet with builtin properties for instance), some properties cannot be removed.
Implemented in carto::TypedObject< T >, carto::TypedObject< SyntaxedInterfaceType< T > >, and carto::PropertySet.
Referenced by carto::TypedObject< SyntaxedInterfaceType< T > >::removeProperty().
|
pure virtual |
Set (insert or replace) the element of key key
with the value
object.
On some specific dictionary implementations (such as PropertySet with builtin properties, or maps of specific, typed values), an existing property cannot change type. In this case value
must hold an object of the correct type, otherwise an exception will be thrown.
Implemented in carto::TypedObject< T >, carto::TypedObject< SyntaxedInterfaceType< T > >, and carto::PropertySet.
Referenced by carto::GenericObjectTypeDeclared< Object >::check(), carto::Object::operator!=(), and carto::TypedObject< SyntaxedInterfaceType< T > >::setProperty().
void carto::DictionaryInterface::setProperty | ( | const std::string & | , |
const char * | |||
) |
specific specialization: C strings are stored as std::string objects
void carto::DictionaryInterface::setProperty | ( | const std::string & | , |
const T & | value | ||
) |
same as the other setProperty() functions except that the value to be set is of the arbitrary type T
and will possibly be stored in an Object.
The same type restrictions apply as for the other setProperty() functions
void carto::DictionaryInterface::setProperty | ( | const std::string & | key, |
Object const & | value | ||
) |