libzypp 17.31.23
|
Typesafe passing of user data via callbacks. More...
#include <UserData.h>
Public Types | |
typedef boost::any | AnyType |
typedef boost::bad_any_cast | bad_AnyType_cast |
typedef std::map< std::string, AnyType > | DataType |
typedef DataType::size_type | size_type |
typedef DataType::key_type | key_type |
typedef DataType::value_type | value_type |
typedef DataType::const_iterator | const_iterator |
typedef zypp::ContentType | ContentType |
Public Member Functions | |
UserData () | |
Default ctor. | |
UserData (ContentType type_r) | |
Ctor taking ContentType. | |
UserData (std::string type_r) | |
Ctor taking ContentType. | |
UserData (std::string type_r, std::string subtype_r) | |
Ctor taking ContentType. | |
const ContentType & | type () const |
Get type. | |
void | type (ContentType type_r) |
Set type. | |
operator bool () const | |
Validate object in a boolean context: has data. | |
bool | empty () const |
Whether data is empty. | |
size_type | size () const |
Size of data. | |
const DataType & | data () const |
The data. | |
bool | haskey (const std::string &key_r) const |
Whether key_r is in data. | |
bool | hasvalue (const std::string &key_r) const |
Whether key_r is in data and value is not empty. | |
bool | set (const std::string &key_r, AnyType val_r) |
Set the value for key (nonconst version always returns true). | |
bool | set (const std::string &key_r, AnyType val_r) const |
bool | reset (const std::string &key_r) |
Set an empty value for key_r (if possible). | |
bool | reset (const std::string &key_r) const |
void | erase (const std::string &key_r) |
Remove key from data. | |
const AnyType & | getvalue (const std::string &key_r) const |
get helper returning the keys AnyType value or an empty value if key does not exist. | |
template<class Tp > | |
const Tp & | get (const std::string &key_r) const |
Pass back a const Tp & reference to key_r value. | |
template<class Tp > | |
Tp | get (const std::string &key_r, const Tp &default_r) const |
Pass back a Tp copy of key_r value. | |
template<class Tp > | |
bool | get (const std::string &key_r, Tp &ret_r) const |
If the value for key_r is of the same type as ret_r, pass it back in ret_r and return true ;. | |
Private Member Functions | |
DataType & | dataRef () const |
Private Attributes | |
ContentType | _type |
shared_ptr< DataType > | _dataP |
Related Functions | |
(Note that these are not member functions.) | |
std::ostream & | operator<< (std::ostream &str, const UserData &obj) |
Stream output. | |
Typesafe passing of user data via callbacks.
Basically a std::map<std::string,AnyType>
plus associated ContentType.
Constness protects non-empty values from being modified. It is possible to overwrite empty values or to add new ones.
Definition at line 38 of file UserData.h.
typedef boost::any zypp::callback::UserData::AnyType |
Definition at line 41 of file UserData.h.
typedef boost::bad_any_cast zypp::callback::UserData::bad_AnyType_cast |
Definition at line 42 of file UserData.h.
typedef std::map<std::string,AnyType> zypp::callback::UserData::DataType |
Definition at line 44 of file UserData.h.
typedef DataType::size_type zypp::callback::UserData::size_type |
Definition at line 45 of file UserData.h.
typedef DataType::key_type zypp::callback::UserData::key_type |
Definition at line 46 of file UserData.h.
typedef DataType::value_type zypp::callback::UserData::value_type |
Definition at line 47 of file UserData.h.
typedef DataType::const_iterator zypp::callback::UserData::const_iterator |
Definition at line 48 of file UserData.h.
Definition at line 50 of file UserData.h.
|
inline |
Default ctor.
Definition at line 54 of file UserData.h.
|
inlineexplicit |
Ctor taking ContentType.
Definition at line 58 of file UserData.h.
|
inlineexplicit |
Ctor taking ContentType.
Definition at line 62 of file UserData.h.
|
inline |
Ctor taking ContentType.
Definition at line 66 of file UserData.h.
|
inline |
Get type.
Definition at line 72 of file UserData.h.
|
inline |
Set type.
Definition at line 76 of file UserData.h.
|
inlineexplicit |
Validate object in a boolean context: has data.
Definition at line 81 of file UserData.h.
|
inline |
Whether data is empty.
Definition at line 85 of file UserData.h.
|
inline |
Size of data.
Definition at line 89 of file UserData.h.
|
inline |
The data.
Definition at line 93 of file UserData.h.
|
inline |
Whether key_r is in data.
Definition at line 97 of file UserData.h.
|
inline |
Whether key_r is in data and value is not empty.
Definition at line 101 of file UserData.h.
Set the value for key (nonconst version always returns true).
Const version is allowed to set empty values or to add new ones only.
Definition at line 118 of file UserData.h.
Definition at line 121 of file UserData.h.
|
inline |
Set an empty value for key_r (if possible).
Definition at line 134 of file UserData.h.
|
inline |
Definition at line 137 of file UserData.h.
|
inline |
Remove key from data.
Definition at line 141 of file UserData.h.
|
inline |
get helper returning the keys AnyType value or an empty value if key does not exist.
Definition at line 145 of file UserData.h.
|
inline |
Pass back a const Tp &
reference to key_r value.
bad_AnyType_cast | if key is not set or value is not of appropriate type std::string value( "defaultvalue" );
try
{
value = data.get<std::string>( "mykey" );
}
{
// no "mykey" or not a std::sting
}
boost::bad_any_cast bad_AnyType_cast Definition: UserData.h:42 |
Definition at line 175 of file UserData.h.
|
inline |
Pass back a Tp copy of key_r value.
bad_AnyType_cast | if key is not set or value is not of appropriate type |
Definition at line 186 of file UserData.h.
|
inline |
If the value for key_r is of the same type as ret_r, pass it back in ret_r and return true
;.
Definition at line 200 of file UserData.h.
|
inlineprivate |
Definition at line 220 of file UserData.h.
|
related |
Stream output.
Definition at line 229 of file UserData.h.
|
private |
Definition at line 224 of file UserData.h.
|
mutableprivate |
Definition at line 225 of file UserData.h.