#include <uhd/types/dict.hpp>
|
| dict (void) |
|
template<typename InputIterator > |
| dict (InputIterator first, InputIterator last) |
|
std::size_t | size (void) const |
|
std::vector< Key > | keys (void) const |
|
std::vector< Val > | vals (void) const |
|
bool | has_key (const Key &key) const |
|
const Val & | get (const Key &key, const Val &other) const |
|
const Val & | get (const Key &key) const |
|
void | set (const Key &key, const Val &val) |
|
const Val & | operator[] (const Key &key) const |
|
Val & | operator[] (const Key &key) |
|
Val | pop (const Key &key) |
|
template<typename Key, typename Val>
class uhd::dict< Key, Val >
A templated dictionary class with a python-like interface.
◆ dict() [1/2]
template<typename Key , typename Val >
Create a new empty dictionary.
◆ dict() [2/2]
template<typename Key , typename Val >
template<typename InputIterator >
uhd::dict< Key, Val >::dict |
( |
InputIterator |
first, |
|
|
InputIterator |
last |
|
) |
| |
Input iterator constructor: Makes boost::assign::map_list_of work.
- Parameters
-
first | the begin iterator |
last | the end iterator |
◆ get() [1/2]
template<typename Key, typename Val>
const Val & uhd::dict< Key, Val >::get |
( |
const Key & |
key, |
|
|
const Val & |
other |
|
) |
| const |
Get a value in the dict or default.
- Parameters
-
key | the key to look for |
other | use if key not found |
- Returns
- the value or default
◆ get() [2/2]
template<typename Key, typename Val>
const Val & uhd::dict< Key, Val >::get |
( |
const Key & |
key | ) |
const |
Get a value in the dict or throw.
- Parameters
-
- Returns
- the value or default
◆ has_key()
template<typename Key, typename Val >
bool uhd::dict< Key, Val >::has_key |
( |
const Key & |
key | ) |
const |
Does the dictionary contain this key?
- Parameters
-
- Returns
- true if found
◆ keys()
template<typename Key , typename Val >
std::vector< Key > uhd::dict< Key, Val >::keys |
( |
void |
| ) |
const |
Get a list of the keys in this dict. Key order depends on insertion precedence.
- Returns
- vector of keys
◆ operator[]() [1/2]
template<typename Key, typename Val >
const Val & uhd::dict< Key, Val >::operator[] |
( |
const Key & |
key | ) |
const |
Get a value for the given key if it exists. If the key is not found throw an error.
- Parameters
-
- Returns
- the value at the key
- Exceptions
-
an | exception when not found |
◆ operator[]() [2/2]
template<typename Key, typename Val >
Val & uhd::dict< Key, Val >::operator[] |
( |
const Key & |
key | ) |
|
Set a value for the given key, however, in reality it really returns a reference which can be assigned to.
- Parameters
-
- Returns
- a reference to the value
◆ pop()
template<typename Key, typename Val >
Val uhd::dict< Key, Val >::pop |
( |
const Key & |
key | ) |
|
Pop an item out of the dictionary.
- Parameters
-
- Returns
- the value of the item
- Exceptions
-
an | exception when not found |
◆ set()
template<typename Key, typename Val>
void uhd::dict< Key, Val >::set |
( |
const Key & |
key, |
|
|
const Val & |
val |
|
) |
| |
Set a value in the dict at the key.
- Parameters
-
key | the key to set at |
val | the value to set |
◆ size()
template<typename Key , typename Val >
std::size_t uhd::dict< Key, Val >::size |
( |
void |
| ) |
const |
Get the number of elements in this dict.
- Returns
- the number of elements
◆ vals()
template<typename Key , typename Val >
std::vector< Val > uhd::dict< Key, Val >::vals |
( |
void |
| ) |
const |
Get a list of the values in this dict. Value order depends on insertion precedence.
- Returns
- vector of values
The documentation for this class was generated from the following files: