11#ifndef ZYPP_CORE_USERDATA_H
12#define ZYPP_CORE_USERDATA_H
17#include <boost/any.hpp>
45 typedef std::map<std::string,AnyType>
DataType;
82 explicit operator bool()
const
108 if (
it !=
_dataP->end() && !
it->second.empty() )
128 val = std::move(
val_r);
209 auto ptr = boost::any_cast<const Tp>(&
it->second);
231 {
return str <<
"UserData(" <<
obj.type() <<
":" <<
obj.size() <<
")";}
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Mime type like 'type/subtype' classification of content.
Typesafe passing of user data via callbacks.
DataType::const_iterator const_iterator
bool reset(const std::string &key_r)
Set an empty value for key_r (if possible).
void type(ContentType type_r)
Set type.
const Tp & get(const std::string &key_r) const
Pass back a const Tp & reference to key_r value.
const DataType & data() const
The data.
shared_ptr< DataType > _dataP
const ContentType & type() const
Get type.
UserData(ContentType type_r)
Ctor taking ContentType.
DataType & dataRef() const
DataType::size_type size_type
bool hasvalue(const std::string &key_r) const
Whether key_r is in data and value is not empty.
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;.
void erase(const std::string &key_r)
Remove key from data.
boost::bad_any_cast bad_AnyType_cast
size_type size() const
Size of data.
DataType::key_type key_type
std::ostream & operator<<(std::ostream &str, const UserData &obj)
Stream output.
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
DataType::value_type value_type
bool haskey(const std::string &key_r) const
Whether key_r is in data.
UserData(std::string type_r, std::string subtype_r)
Ctor taking ContentType.
zypp::ContentType ContentType
std::map< std::string, AnyType > DataType
UserData(std::string type_r)
Ctor taking ContentType.
bool empty() const
Whether data is empty.
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.
Tp get(const std::string &key_r, const Tp &default_r) const
Pass back a Tp copy of key_r value.
bool reset(const std::string &key_r) const
String related utilities and Regular expression matching.
Easy-to use interface to the ZYPP dependency resolver.