ROSE 0.11.145.192
|
Extends std::map with methods that return optional values.
Definition at line 13 of file util/Map.h.
#include <util/Map.h>
Public Types | |
typedef std::map< Key, T, Compare, Alloc > | map_type |
Public Member Functions | |
Map (const Compare &comp, const Alloc &alloc=Alloc()) | |
template<class InputIterator > | |
Map (InputIterator first, InputIterator last, const Compare &comp=Compare(), const Alloc &alloc=Alloc()) | |
Map (const Map &other) | |
boost::optional< T > | get (const Key &key) const |
Lookup and return a value or nothing. | |
bool | exists (const Key &key) const |
Convenience for determining if a key exists in this map. | |
const T & | get_one (const Key &key) const |
Look up one value or throw an exception. | |
T & | get_one (const Key &key) |
Look up one value or throw an exception. | |
const T & | get_value_or (const Key &key, const T &dflt) const |
Convenience for getting a value from an Option. | |
T & | get_value_or (const Key &key, T &dflt) |
Convenience for getting a value from an Option. | |
typedef std::map<Key, T, Compare, Alloc> Map< Key, T, Compare, Alloc >::map_type |
Definition at line 15 of file util/Map.h.
|
inline |
Definition at line 29 of file util/Map.h.
|
inlineexplicit |
Definition at line 31 of file util/Map.h.
|
inline |
Definition at line 35 of file util/Map.h.
|
inline |
Definition at line 38 of file util/Map.h.
|
inline |
Lookup and return a value or nothing.
This is similar to the operator[] defined for std::map, but does not add a new pair to the map when the key does not exist. It returns a copy of the value that was found (if found). Here's an example of the usual way to use this:
Definition at line 52 of file util/Map.h.
|
inline |
Look up one value or throw an exception.
This is like get() except it can't handle the case where the map does not contain the requested key. It is unlike operator[] in that it doesn't add a new default-constructed value. The return value is a reference to the value stored in the map.
Definition at line 61 of file util/Map.h.
Referenced by Rose::BinaryAnalysis::ControlFlow::explode_blocks(), and Rose::BinaryAnalysis::ControlFlow::fixup_fcall_fret().
|
inline |
Look up one value or throw an exception.
This is like get() except it can't handle the case where the map does not contain the requested key. It is unlike operator[] in that it doesn't add a new default-constructed value. The return value is a reference to the value stored in the map.
Definition at line 67 of file util/Map.h.
|
inline |
Convenience for getting a value from an Option.
Since the "map.get(key).get_value_or(dflt)" idiom is so frequenct, a get_value_or() method is defined directly on the map, combining both arguments into a single method call.
Definition at line 78 of file util/Map.h.
Referenced by Rose::BinaryAnalysis::ControlFlow::build_block_cfg_from_ast(), and Rose::BinaryAnalysis::ControlFlow::fixup_fcall_fret().
|
inline |
Convenience for getting a value from an Option.
Since the "map.get(key).get_value_or(dflt)" idiom is so frequenct, a get_value_or() method is defined directly on the map, combining both arguments into a single method call.
Definition at line 82 of file util/Map.h.
|
inline |
Convenience for determining if a key exists in this map.
The STL map requires one to do a find() and compare the result to end(). Although that can be more efficient when the value for that key will be used (because one just dereferences the already-obtained iterator rather than searching again), it requires more code when all one wants to do is check for existence.
Definition at line 92 of file util/Map.h.