libzypp  17.25.0
ProductFileReader.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_PARSER_PRODUCTSDREADER_H
13 #define ZYPP_PARSER_PRODUCTSDREADER_H
14 
15 #include <iosfwd>
16 
17 #include <zypp/base/PtrTypes.h>
18 #include <zypp/base/Function.h>
19 #include <zypp/base/InputStream.h>
20 
21 #include <zypp/Pathname.h>
22 #include <zypp/IdString.h>
23 #include <zypp/Edition.h>
24 #include <zypp/Arch.h>
25 
27 namespace zypp
28 {
29  namespace parser
31  {
32 
34  //
35  // CLASS NAME : ProductFileData
36  //
41  {
42  public:
43  struct Impl;
45  ProductFileData( Impl * allocated_r = 0 );
46 
48  bool empty() const
49  { return name().empty(); }
50 
51  public:
52  IdString vendor() const;
53  IdString name() const;
54  Edition edition() const;
55  Arch arch() const;
56 
57  std::string shortName() const;
58  std::string summary() const;
59 
60  public:
61  std::string productline() const;
62  std::string registerTarget() const;
63  std::string registerRelease() const;
64  std::string registerFlavor() const;
65 
66  public:
67  std::string updaterepokey() const;
68 
69  public:
71 
72  struct Upgrade
73  {
74  public:
75  struct Impl;
77  Upgrade( Impl * allocated_r = 0 );
78 
79  public:
80  std::string name() const;
81  std::string summary() const;
82  std::string repository() const;
83  std::string product() const;
84  bool notify() const;
85  std::string status() const;
86 
87  private:
89  };
91 
92  typedef std::vector<Upgrade> Upgrades;
93  const Upgrades & upgrades() const;
94 
95  private:
97  };
99 
101  std::ostream & operator<<( std::ostream & str, const ProductFileData & obj );
102 
104  std::ostream & operator<<( std::ostream & str, const ProductFileData::Upgrade & obj );
105 
107  //
108  // CLASS NAME : ProductFileReader
109  //
121  {
122  public:
126  typedef function<bool( const ProductFileData & )> Consumer;
127 
128  public:
130  {}
131 
132  ProductFileReader( const Consumer & consumer_r )
133  : _consumer( consumer_r )
134  {}
135 
136  ProductFileReader( const Consumer & consumer_r, const InputStream & input_r )
137  : _consumer( consumer_r )
138  { parse( input_r ); }
139 
140  public:
141  const Consumer & consumer() const
142  { return _consumer; }
143 
144  void setConsumer( const Consumer & consumer_r )
145  { _consumer = consumer_r; }
146 
147  public:
153  bool parse( const InputStream & input_r = InputStream() ) const;
154 
155  public:
161  static bool scanDir( const Consumer & consumer_r, const Pathname & dir_r );
162 
165  static ProductFileData scanFile( const Pathname & file_r );
166 
167  private:
169  };
171 
173  } // namespace parser
176 } // namespace zypp
178 #endif // ZYPP_PARSER_PRODUCTSDREADER_H
zypp::parser::ProductFileData::productline
std::string productline() const
Definition: ProductFileReader.cc:98
Edition.h
zypp::parser::ProductFileReader::Consumer
function< bool(const ProductFileData &)> Consumer
Callback being invoked for each ProductFileData parsed.
Definition: ProductFileReader.h:126
zypp::parser::ProductFileData::Upgrade
Definition: ProductFileReader.h:72
zypp::parser::ProductFileReader::scanFile
static ProductFileData scanFile(const Pathname &file_r)
Parse one file (or symlink) and return the ProductFileData parsed.
Definition: ProductFileReader.cc:272
zypp::parser::ProductFileData::arch
Arch arch() const
Definition: ProductFileReader.cc:93
zypp::parser::ProductFileData::upgrades
const Upgrades & upgrades() const
Definition: ProductFileReader.cc:105
zypp::parser::ProductFileData::Upgrade::status
std::string status() const
Definition: ProductFileReader.cc:58
zypp::parser::ProductFileReader::ProductFileReader
ProductFileReader(const Consumer &consumer_r)
Definition: ProductFileReader.h:132
zypp::parser::ProductFileReader::ProductFileReader
ProductFileReader()
Definition: ProductFileReader.h:129
zypp::parser::ProductFileData::updaterepokey
std::string updaterepokey() const
Definition: ProductFileReader.cc:103
zypp::parser::ProductFileData::_pimpl
RWCOW_pointer< Impl > _pimpl
Definition: ProductFileReader.h:96
zypp::parser::ProductFileData::Upgrade::Upgrade
Upgrade(Impl *allocated_r=0)
Ctor takes ownership of allocated_r.
Definition: ProductFileReader.cc:49
zypp::Edition
Edition represents [epoch:]version[-release]
Definition: Edition.h:60
zypp::parser::ProductFileReader::parse
bool parse(const InputStream &input_r=InputStream()) const
Parse the input stream and call _consumer for each parsed section.
Definition: ProductFileReader.cc:217
PtrTypes.h
zypp::parser::ProductFileReader::ProductFileReader
ProductFileReader(const Consumer &consumer_r, const InputStream &input_r)
Definition: ProductFileReader.h:136
zypp::parser::ProductFileReader::consumer
const Consumer & consumer() const
Definition: ProductFileReader.h:141
zypp::parser::ProductFileReader
Parser for /etc/products.d enries (just relevant entires).
Definition: ProductFileReader.h:120
Pathname.h
zypp::Arch
Architecture.
Definition: Arch.h:36
zypp::parser::ProductFileData::Upgrade::notify
bool notify() const
Definition: ProductFileReader.cc:57
zypp::parser::ProductFileData::Upgrades
std::vector< Upgrade > Upgrades
Definition: ProductFileReader.h:92
bool
zypp::parser::ProductFileData::empty
bool empty() const
Whether this is an empty object without valid data.
Definition: ProductFileReader.h:48
zypp::IdString
Access to the sat-pools string space.
Definition: IdString.h:42
zypp::parser::ProductFileData::Impl
Definition: ProductFileReader.cc:66
zypp::parser::ProductFileData::Upgrade::product
std::string product() const
Definition: ProductFileReader.cc:56
Arch.h
zypp::parser::ProductFileData::vendor
IdString vendor() const
Definition: ProductFileReader.cc:90
zypp::parser::ProductFileData::registerFlavor
std::string registerFlavor() const
Definition: ProductFileReader.cc:101
zypp::parser::ProductFileReader::_consumer
Consumer _consumer
Definition: ProductFileReader.h:168
IdString.h
zypp::InputStream
Helper to create and pass std::istream.
Definition: InputStream.h:56
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
zypp::parser::ProductFileData::Upgrade::_pimpl
RWCOW_pointer< Impl > _pimpl
Definition: ProductFileReader.h:88
zypp::parser::ProductFileData::summary
std::string summary() const
Definition: ProductFileReader.cc:96
zypp::parser::ProductFileData::registerRelease
std::string registerRelease() const
Definition: ProductFileReader.cc:100
zypp::parser::ProductFileData::edition
Edition edition() const
Definition: ProductFileReader.cc:92
zypp::parser::ProductFileData
Data returned by ProductFileReader.
Definition: ProductFileReader.h:40
zypp::parser::operator<<
std::ostream & operator<<(std::ostream &str, const IniDict &obj)
Definition: IniDict.cc:159
zypp::parser::ProductFileData::registerTarget
std::string registerTarget() const
Definition: ProductFileReader.cc:99
zypp::parser::ProductFileData::name
IdString name() const
Definition: ProductFileReader.cc:91
zypp::parser::ProductFileData::Upgrade::summary
std::string summary() const
Definition: ProductFileReader.cc:54
zypp::parser::ProductFileData::Upgrade::name
std::string name() const
Definition: ProductFileReader.cc:53
Function.h
zypp::filesystem::Pathname
Pathname.
Definition: Pathname.h:44
InputStream.h
zypp::parser::ProductFileReader::setConsumer
void setConsumer(const Consumer &consumer_r)
Definition: ProductFileReader.h:144
zypp::RWCOW_pointer< Impl >
str
String related utilities and Regular expression matching.
zypp::parser::ProductFileData::Upgrade::Impl
Definition: ProductFileReader.cc:39
zypp::parser::ProductFileData::shortName
std::string shortName() const
Definition: ProductFileReader.cc:95
zypp::parser::ProductFileReader::scanDir
static bool scanDir(const Consumer &consumer_r, const Pathname &dir_r)
Parse all files (no symlinks) in dir_r and call consumer_r for each ProductFileData parsed.
Definition: ProductFileReader.cc:251
zypp::parser::ProductFileData::ProductFileData
ProductFileData(Impl *allocated_r=0)
Ctor takes ownership of allocated_r.
Definition: ProductFileReader.cc:86
zypp::IdString::empty
constexpr bool empty() const
Whether the string is empty.
Definition: IdString.h:87
zypp::parser::ProductFileData::Upgrade::repository
std::string repository() const
Definition: ProductFileReader.cc:55