libzypp: zypp/parser/ProductFileReader.h Source File

libzypp 17.38.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-core/base/PtrTypes.h>
18#include <zypp-core/base/Function.h>
19#include <utility>
20#include <zypp-core/base/InputStream>
21
22#include <zypp-core/Pathname.h>
23#include <zypp/IdString.h>
24#include <zypp/Edition.h>
25#include <zypp/Arch.h>
26
28namespace zypp
29{
31 namespace parser
32 {
33
35 //
36 // CLASS NAME : ProductFileData
37 //
41 class ZYPP_API ProductFileData
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:
89 RWCOW_pointer<Impl> _pimpl;
90 };
91
92
93 using Upgrades = std::vector<Upgrade>;
94 const Upgrades & upgrades() const;
95
96 private:
97 RWCOW_pointer<Impl> _pimpl;
98 };
99
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 //
121 class ZYPP_API ProductFileReader
122 {
123 public:
127 using Consumer = function<bool (const ProductFileData &)>;
128
129 public:
130 ProductFileReader()
131 {}
132
133 ProductFileReader( Consumer consumer_r )
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:
169 Consumer _consumer;
170 };
171
172
174 } // namespace parser
177} // namespace zypp
179#endif // ZYPP_PARSER_PRODUCTSDREADER_H
Arch.h
Edition.h
Function.h
IdString.h
Pathname.h
PtrTypes.h
bool
zypp::Arch
Architecture.
Definition Arch.h:37
zypp::Edition
Edition represents [epoch:]version[-release].
Definition Edition.h:60
zypp::IdString
Access to the sat-pools string space.
Definition IdString.h:55
zypp::InputStream
Helper to create and pass std::istream.
Definition inputstream.h:57
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:48
zypp::parser::ProductFileData
Data returned by ProductFileReader.
Definition ProductFileReader.h:42
zypp::parser::ProductFileData::empty
bool empty() const
Whether this is an empty object without valid data.
Definition ProductFileReader.h:49
zypp::parser::ProductFileData::ProductFileData
ProductFileData(Impl *allocated_r=0)
Ctor takes ownership of allocated_r.
Definition ProductFileReader.cc:86
zypp::parser::ProductFileData::upgrades
const Upgrades & upgrades() const
Definition ProductFileReader.cc:105
zypp::parser::ProductFileData::name
IdString name() const
Definition ProductFileReader.cc:91
zypp::parser::ProductFileData::_pimpl
RWCOW_pointer< Impl > _pimpl
Definition ProductFileReader.h:97
zypp::parser::ProductFileData::Upgrades
std::vector< Upgrade > Upgrades
Definition ProductFileReader.h:93
zypp::parser::ProductFileReader::ProductFileReader
ProductFileReader()
Definition ProductFileReader.h:130
zypp::parser::ProductFileReader::consumer
const Consumer & consumer() const
Definition ProductFileReader.h:142
zypp::parser::ProductFileReader::ProductFileReader
ProductFileReader(Consumer consumer_r, const InputStream &input_r)
Definition ProductFileReader.h:137
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
zypp::parser::ProductFileReader::ProductFileReader
ProductFileReader(Consumer consumer_r)
Definition ProductFileReader.h:133
zypp::parser::ProductFileReader::Consumer
function< bool(const ProductFileData &)> Consumer
Callback being invoked for each ProductFileData parsed.
Definition ProductFileReader.h:127
zypp::parser::ProductFileReader::_consumer
Consumer _consumer
Definition ProductFileReader.h:169
zypp::parser::ProductFileReader::setConsumer
void setConsumer(const Consumer &consumer_r)
Definition ProductFileReader.h:145
std
Definition ansi.h:855
str
String related utilities and Regular expression matching.
zypp::parser
Definition HistoryLogReader.cc:30
zypp::parser::operator<<
std::ostream & operator<<(std::ostream &str, const ProductFileData &obj)
relates: ProductFileData Stream output
Definition ProductFileReader.cc:107
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zypp::ZYPP_API
const Arch Arch_empty ZYPP_API
relates: Arch This is an empty Arch represented by an empty string.
Definition Arch.h:173
zypp::RWCOW_pointer
RW_pointer supporting 'copy on write' functionality.
Definition PtrTypes.h:469
zypp::parser::ProductFileData::Impl
Definition ProductFileReader.cc:67
zypp::parser::ProductFileData::Upgrade::Impl
Definition ProductFileReader.cc:40
zypp::parser::ProductFileData::Upgrade
Definition ProductFileReader.h:74
zypp::parser::ProductFileData::Upgrade::name
std::string name() const
Definition ProductFileReader.cc:53
zypp::parser::ProductFileData::Upgrade::notify
bool notify() const
Definition ProductFileReader.cc:57
zypp::parser::ProductFileData::Upgrade::summary
std::string summary() const
Definition ProductFileReader.cc:54
zypp::parser::ProductFileData::Upgrade::product
std::string product() const
Definition ProductFileReader.cc:56
zypp::parser::ProductFileData::Upgrade::_pimpl
RWCOW_pointer< Impl > _pimpl
Definition ProductFileReader.h:89
zypp::parser::ProductFileData::Upgrade::status
std::string status() const
Definition ProductFileReader.cc:58
zypp::parser::ProductFileData::Upgrade::Upgrade
Upgrade(Impl *allocated_r=0)
Ctor takes ownership of allocated_r.
Definition ProductFileReader.cc:49
zypp::parser::ProductFileData::Upgrade::repository
std::string repository() const
Definition ProductFileReader.cc:55