![]() |
OpenMS
|
A Type-Name-Value tuple class. More...
#include <OpenMS/METADATA/MetaInfo.h>
Public Types | |
| using | MapType = boost::container::flat_map< UInt, DataValue > |
| Internal map type (UInt key to DataValue) | |
| using | iterator = MapType::iterator |
| Mutable iterator type. | |
| using | const_iterator = MapType::const_iterator |
| Const iterator type. | |
Public Member Functions | |
| MetaInfo ()=default | |
| Constructor. | |
| MetaInfo (const MetaInfo &)=default | |
| Copy constructor. | |
| MetaInfo (MetaInfo &&)=default | |
| Move constructor. | |
| ~MetaInfo () | |
| Destructor. | |
| MetaInfo & | operator= (const MetaInfo &)=default |
| Assignment operator. | |
| MetaInfo & | operator= (MetaInfo &&) &=default |
| Move assignment operator. | |
| bool | operator== (const MetaInfo &rhs) const |
| Equality operator. | |
| bool | operator!= (const MetaInfo &rhs) const |
| Equality operator. | |
| MetaInfo & | operator+= (const MetaInfo &rhs) |
| Merge another MetaInfo into this one. | |
| const DataValue & | getValue (const String &name, const DataValue &default_value=DataValue::EMPTY) const |
| Returns the value corresponding to a string, or a default value (default: DataValue::EMPTY) if not found. | |
| const DataValue & | getValue (UInt index, const DataValue &default_value=DataValue::EMPTY) const |
| Returns the value corresponding to an index, or a default value (default: DataValue::EMPTY) if not found. | |
| bool | exists (const String &name) const |
| Returns whether an entry with the given name exists. | |
| bool | exists (UInt index) const |
| Returns whether an entry with the given index exists. | |
| void | setValue (const String &name, const DataValue &value) |
| Sets the DataValue corresponding to a name. | |
| void | setValue (UInt index, const DataValue &value) |
| Sets the DataValue corresponding to an index. | |
| void | removeValue (const String &name) |
Removes the DataValue corresponding to name if it exists. | |
| void | removeValue (UInt index) |
Removes the DataValue corresponding to index if it exists. | |
| void | getKeys (std::vector< String > &keys) const |
| Fills the given vector with a list of all keys for which a value is set. | |
| void | getKeys (std::vector< UInt > &keys) const |
| Fills the given vector with a list of all keys for which a value is set. | |
| bool | empty () const |
| Returns if the MetaInfo is empty. | |
| void | clear () |
| Removes all meta values. | |
| Size | size () const |
| Returns the number of meta value entries. | |
Iterator access | |
Provides iterator access to the underlying index-to-value map. Iterators dereference to std::pair<UInt, DataValue> where the first element is the registry index and the second is the associated value. The iteration order is sorted by index (ascending). | |
| const_iterator | begin () const |
| Returns a const iterator to the beginning of the meta info entries. | |
| const_iterator | end () const |
| Returns a const iterator to the end of the meta info entries. | |
| const_iterator | cbegin () const |
| Returns a const iterator to the beginning of the meta info entries. | |
| const_iterator | cend () const |
| Returns a const iterator to the end of the meta info entries. | |
| iterator | begin () |
| Returns a mutable iterator to the beginning of the meta info entries. | |
| iterator | end () |
| Returns a mutable iterator to the end of the meta info entries. | |
Static Public Member Functions | |
| static MetaInfoRegistry & | registry () |
| Returns a reference to the MetaInfoRegistry. | |
Private Attributes | |
| MapType | index_to_value_ |
| The actual mapping of indexes to values. | |
Static Private Attributes | |
| static MetaInfoRegistry | registry_ |
| Static MetaInfoRegistry. | |
Friends | |
| struct | std::hash< MetaInfo > |
A Type-Name-Value tuple class.
MetaInfo maps an index (an integer corresponding to a string) to DataValue objects. The mapping of strings to the index is performed by the MetaInfoRegistry, which can be accessed by the method registry().
There are two versions of nearly all members. One which operates with a string name and another one which operates on an index. The index version is always faster, as it does not need to look up the index corresponding to the string in the MetaInfoRegistry.
If you wish to add a MetaInfo member to a class, consider deriving that class from MetaInfoInterface, instead of simply adding MetaInfo as member. MetaInfoInterface implements a full interface to a MetaInfo member and is more memory efficient if no meta info gets added.
Const iterator type.
| using iterator = MapType::iterator |
Mutable iterator type.
|
default |
Constructor.
| ~MetaInfo | ( | ) |
Destructor.
|
inline |
Returns a mutable iterator to the beginning of the meta info entries.
|
inline |
Returns a const iterator to the beginning of the meta info entries.
|
inline |
Returns a const iterator to the beginning of the meta info entries.
|
inline |
Returns a const iterator to the end of the meta info entries.
| void clear | ( | ) |
Removes all meta values.
| bool empty | ( | ) | const |
Returns if the MetaInfo is empty.
|
inline |
Returns a mutable iterator to the end of the meta info entries.
|
inline |
Returns a const iterator to the end of the meta info entries.
| bool exists | ( | const String & | name | ) | const |
Returns whether an entry with the given name exists.
| bool exists | ( | UInt | index | ) | const |
Returns whether an entry with the given index exists.
| void getKeys | ( | std::vector< String > & | keys | ) | const |
Fills the given vector with a list of all keys for which a value is set.
| void getKeys | ( | std::vector< UInt > & | keys | ) | const |
Fills the given vector with a list of all keys for which a value is set.
| const DataValue & getValue | ( | const String & | name, |
| const DataValue & | default_value = DataValue::EMPTY |
||
| ) | const |
Returns the value corresponding to a string, or a default value (default: DataValue::EMPTY) if not found.
| const DataValue & getValue | ( | UInt | index, |
| const DataValue & | default_value = DataValue::EMPTY |
||
| ) | const |
Returns the value corresponding to an index, or a default value (default: DataValue::EMPTY) if not found.
| bool operator!= | ( | const MetaInfo & | rhs | ) | const |
Equality operator.
Merge another MetaInfo into this one.
All entries from rhs are added to this MetaInfo. If an entry with the same index already exists, it will be overwritten with the value from rhs.
Uses an O(n+m) two-way merge algorithm since the underlying flat_map is sorted.
| rhs | The MetaInfo to merge from. |
| bool operator== | ( | const MetaInfo & | rhs | ) | const |
Equality operator.
|
static |
Returns a reference to the MetaInfoRegistry.
Sets the DataValue corresponding to a name.
|
inline |
Returns the number of meta value entries.
|
friend |
|
private |
The actual mapping of indexes to values.
|
staticprivate |
Static MetaInfoRegistry.