1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/UserData.h
11 #ifndef ZYPP_USERDATA_H
12 #define ZYPP_USERDATA_H
17 #include <boost/any.hpp>
19 #include "zypp/base/PtrTypes.h"
20 #include "zypp/ContentType.h"
22 ///////////////////////////////////////////////////////////////////
25 ///////////////////////////////////////////////////////////////////
28 ///////////////////////////////////////////////////////////////////
30 /// \brief Typesafe passing of user data via callbacks
32 /// Basically a <tt>std::map<std::string,boost::any></tt> plus
33 /// associated \ref ContentType.
34 ///////////////////////////////////////////////////////////////////
37 typedef std::map<std::string,boost::any> DataType;
45 const ContentType & type() const
49 void type( const ContentType & type_r )
53 /** Validate object in a boolean context: has data */
54 explicit operator bool() const
55 { return ! ( _dataP == nullptr || _dataP->empty() ); }
59 shared_ptr<DataType> _dataP;
62 /** \relates UserData Stream output */
63 inline std::ostream & operator<<( std::ostream & str, const UserData & obj )
64 { return str << "UserData(" << obj.type() << ")";}
66 } // namespace callback
67 ///////////////////////////////////////////////////////////////////
69 ///////////////////////////////////////////////////////////////////
70 #endif // ZYPP_USERDATA_H