libzypp  17.36.7
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 <utility>
20 #include <zypp-core/base/InputStream>
21 
22 #include <zypp/Pathname.h>
23 #include <zypp/IdString.h>
24 #include <zypp/Edition.h>
25 #include <zypp/Arch.h>
26 
28 namespace zypp
29 {
30  namespace parser
32  {
33 
35  //
36  // CLASS NAME : ProductFileData
37  //
42  {
43  public:
44  struct Impl;
46  ProductFileData( Impl * allocated_r = 0 );
47 
49  bool empty() const
50  { return name().empty(); }
51 
52  public:
53  IdString vendor() const;
54  IdString name() const;
55  Edition edition() const;
56  Arch arch() const;
57 
58  std::string shortName() const;
59  std::string summary() const;
60 
61  public:
62  std::string productline() const;
63  std::string registerTarget() const;
64  std::string registerRelease() const;
65  std::string registerFlavor() const;
66 
67  public:
68  std::string updaterepokey() const;
69 
70  public:
72 
73  struct Upgrade
74  {
75  public:
76  struct Impl;
78  Upgrade( Impl * allocated_r = 0 );
79 
80  public:
81  std::string name() const;
82  std::string summary() const;
83  std::string repository() const;
84  std::string product() const;
85  bool notify() const;
86  std::string status() const;
87 
88  private:
90  };
92 
93  using Upgrades = std::vector<Upgrade>;
94  const Upgrades & upgrades() const;
95 
96  private:
98  };
100 
102  std::ostream & operator<<( std::ostream & str, const ProductFileData & obj ) ZYPP_API;
103 
105  std::ostream & operator<<( std::ostream & str, const ProductFileData::Upgrade & obj ) ZYPP_API;
106 
108  //
109  // CLASS NAME : ProductFileReader
110  //
122  {
123  public:
127  using Consumer = function<bool (const ProductFileData &)>;
128 
129  public:
131  {}
132 
134  : _consumer(std::move( consumer_r ))
135  {}
136 
137  ProductFileReader( Consumer consumer_r, const InputStream & input_r )
138  : _consumer(std::move( consumer_r ))
139  { parse( input_r ); }
140 
141  public:
142  const Consumer & consumer() const
143  { return _consumer; }
144 
145  void setConsumer( const Consumer & consumer_r )
146  { _consumer = consumer_r; }
147 
148  public:
154  bool parse( const InputStream & input_r = InputStream() ) const;
155 
156  public:
162  static bool scanDir( const Consumer & consumer_r, const Pathname & dir_r );
163 
166  static ProductFileData scanFile( const Pathname & file_r );
167 
168  private:
170  };
172 
174  } // namespace parser
177 } // namespace zypp
179 #endif // ZYPP_PARSER_PRODUCTSDREADER_H
Architecture.
Definition: Arch.h:36
const Consumer & consumer() const
function< bool(const ProductFileData &)> Consumer
Callback being invoked for each ProductFileData parsed.
String related utilities and Regular expression matching.
Definition: Arch.h:363
Access to the sat-pools string space.
Definition: IdString.h:43
Helper to create and pass std::istream.
Definition: inputstream.h:56
Edition represents [epoch:]version[-release]
Definition: Edition.h:60
RWCOW_pointer< Impl > _pimpl
std::ostream & operator<<(std::ostream &str, const ProductFileData &obj)
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition: ResTraits.h:93
ProductFileReader(Consumer consumer_r, const InputStream &input_r)
ProductFileReader(Consumer consumer_r)
Data returned by ProductFileReader.
std::vector< Upgrade > Upgrades
Easy-to use interface to the ZYPP dependency resolver.
Definition: Application.cc:19
Parser for /etc/products.d enries (just relevant entires).
void setConsumer(const Consumer &consumer_r)
bool empty() const
Whether this is an empty object without valid data.