libzypp  14.29.1
UserData.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
11 #ifndef ZYPP_USERDATA_H
12 #define ZYPP_USERDATA_H
13 
14 #include <iosfwd>
15 #include <string>
16 #include <map>
17 #include <boost/any.hpp>
18 
19 #include "zypp/base/PtrTypes.h"
20 #include "zypp/ContentType.h"
21 
23 namespace zypp
24 {
26  namespace callback
27  {
35  class UserData
36  {
37  typedef std::map<std::string,boost::any> DataType;
38  public:
41  {}
42 
43  public:
45  const ContentType & type() const
46  { return _type; }
47 
49  void type( const ContentType & type_r )
50  { _type = type_r; }
51 
52  public:
54  explicit operator bool() const
55  { return ! ( _dataP == nullptr || _dataP->empty() ); }
56 
57  private:
59  shared_ptr<DataType> _dataP;
60  };
61 
63  inline std::ostream & operator<<( std::ostream & str, const UserData & obj )
64  { return str << "UserData(" << obj.type() << ")";}
65 
66  } // namespace callback
68 } // namespace zypp
70 #endif // ZYPP_USERDATA_H
std::ostream & operator<<(std::ostream &str, const UserData &obj)
Definition: UserData.h:63
String related utilities and Regular expression matching.
void type(const ContentType &type_r)
Set type.
Definition: UserData.h:49
shared_ptr< DataType > _dataP
Definition: UserData.h:59
UserData()
Default ctor.
Definition: UserData.h:40
std::map< std::string, boost::any > DataType
Definition: UserData.h:37
Typesafe passing of user data via callbacks.
Definition: UserData.h:35
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
const ContentType & type() const
Get type.
Definition: UserData.h:45
Mime type like 'type/subtype' classification of content.
Definition: ContentType.h:28