libzypp 17.37.17
librpmDb.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef librpmDb_h
13#define librpmDb_h
14
15#include <iosfwd>
16
19#include <zypp/base/PtrTypes.h>
20#include <zypp/PathInfo.h>
23
24namespace zypp
25{
26namespace target
27{
28namespace rpm
29{
30 struct _dumpPath {
31 _dumpPath( const Pathname & root_r, const Pathname & sub_r )
32 : _root {root_r }
33 , _sub { sub_r }
34 {}
35 const Pathname & _root;
36 const Pathname & _sub;
37 };
38 inline std::ostream & operator<<( std::ostream & str, const _dumpPath & obj )
39 { return str << "'(" << obj._root << ")" << obj._sub << "'"; }
40
42 inline _dumpPath dumpPath( const Pathname & root_r, const Pathname & sub_r )
43 { return _dumpPath( root_r, sub_r ); }
44
46//
47// CLASS NAME : librpmDb
52{
53public:
56
57private:
65 static void dbAccess( librpmDb::Ptr & ptr_r );
66
67public:
69 //
70 // static interface
71 //
73
80 static bool globalInit();
81
85 static std::string expand( const std::string & macro_r );
86
94 static Pathname suggestedDbPath( const Pathname & root_r );
95
103 static bool dbExists( const Pathname & root_r, const Pathname & dbPath_r = Pathname() );
104
112 static librpmDb::constPtr dbOpenIf( const Pathname & root_r, const Pathname & dbPath_r = Pathname() );
113
121 static librpmDb::constPtr dbOpenCreate( const Pathname & root_r, const Pathname & dbPath_r = Pathname() );
122
126 class db_const_iterator;
127
128private:
129
134 static librpmDb::constPtr dbAccess( const Pathname & root_r, const Pathname & dbPath_r, bool create_r = false );
135
136private:
138 //
139 // internal database handle interface (nonstatic)
140 //
142
146 class D;
147 D & _d;
148
153 librpmDb( const Pathname & root_r, const Pathname & dbPath_r, bool readonly_r = true );
154
158 void unref_to( unsigned refCount_r ) const override;
159
160public:
161
165 ~librpmDb() override;
166
170 const Pathname & root() const;
171
175 const Pathname & dbPath() const;
176
177public:
178
182 std::ostream & dumpOn( std::ostream & str ) const override;
183};
184
198{
199 db_const_iterator & operator=( const db_const_iterator & ); // NO ASSIGNMENT!
200 db_const_iterator ( const db_const_iterator & ); // NO COPY!
201 friend std::ostream & operator<<( std::ostream & str, const db_const_iterator & obj );
202 friend class librpmDb;
203
204private:
205
209 class D;
210 D & _d;
211
212#if LEGACY(1735)
213public:
222#endif
223
224public:
230
232 explicit db_const_iterator( const Pathname & root_r );
233
235 db_const_iterator( const Pathname & root_r, const Pathname & dbPath_r );
236
240 db_const_iterator( std::nullptr_t );
241
246
248 bool hasDB() const;
249
253 void operator++();
254
259 unsigned dbHdrNum() const;
260
265 const RpmHeader::constPtr & operator*() const;
266
270 const RpmHeader::constPtr & operator->() const
271 {
272 return operator*();
273 }
274
275public:
276
281 bool findAll();
282
286 bool findByFile( const std::string & file_r );
287
291 bool findByProvides( const std::string & tag_r );
292
296 bool findByRequiredBy( const std::string & tag_r );
297
301 bool findByConflicts( const std::string & tag_r );
302
313 bool findByName( const std::string & name_r );
314
315public:
316
324 bool findPackage( const std::string & name_r );
325
330 bool findPackage( const std::string & name_r, const Edition & ed_r );
331
335 bool findPackage( const Package::constPtr & which_r );
336};
337
339std::ostream & operator<<( std::ostream & str, const librpmDb::db_const_iterator & obj ) ZYPP_API;
340
342} //namespace rpm
343} //namespace target
344} // namespace zypp
345
346#endif // librpmDb_h
347
std::ostream & operator<<(std::ostream &str, const zypp::sat::detail::CDataiterator *obj)
Edition represents [epoch:]version[-release]
Definition Edition.h:61
TraitsType::constPtrType constPtr
Definition Package.h:39
Base class for reference counted objects.
Wrapper class for rpm header struct.
Definition RpmHeader.h:62
librpmDb internal database handle
Definition librpmDb.cc:93
Subclass to retrieve rpm database content.
Definition librpmDb.h:198
unsigned dbHdrNum() const
Returns the current headers index in database, 0 if no header.
Definition librpmDb.cc:406
db_const_iterator & operator=(const db_const_iterator &)
bool hasDB() const
Whether an underlying rpmdb exists.
Definition librpmDb.cc:400
const RpmHeader::constPtr & operator*() const
Returns the current RpmHeader::constPtr or NULL, if no more entries available.
Definition librpmDb.cc:409
db_const_iterator(const db_const_iterator &)
intrusive_ptr< const librpmDb > constPtr
Definition librpmDb.h:55
const Pathname & dbPath() const
Definition librpmDb.cc:243
const Pathname & root() const
Definition librpmDb.cc:240
static bool globalInit()
Initialize lib librpm (read configfiles etc.).
Definition librpmDb.cc:139
std::ostream & dumpOn(std::ostream &str) const override
Dump debug info.
Definition librpmDb.cc:246
static librpmDb::constPtr dbOpenCreate(const Pathname &root_r, const Pathname &dbPath_r=Pathname())
Assert the rpmdb below the system at root_r exists.
Definition librpmDb.cc:198
static std::string expand(const std::string &macro_r)
Definition librpmDb.cc:159
librpmDb(const Pathname &root_r, const Pathname &dbPath_r, bool readonly_r=true)
Private constructor!
Definition librpmDb.cc:227
static void dbAccess(librpmDb::Ptr &ptr_r)
INTENTIONALLY UNDEFINED<\B> because of bug in Ptr classes which allows implicit conversion from librp...
static librpmDb::constPtr dbOpenIf(const Pathname &root_r, const Pathname &dbPath_r=Pathname())
Open the rpmdb below the system at root_r (if it exists).
Definition librpmDb.cc:195
~librpmDb() override
Destructor.
Definition librpmDb.cc:231
intrusive_ptr< librpmDb > Ptr
Definition librpmDb.h:54
static Pathname suggestedDbPath(const Pathname &root_r)
Definition librpmDb.cc:171
static bool dbExists(const Pathname &root_r, const Pathname &dbPath_r=Pathname())
Definition librpmDb.cc:183
void unref_to(unsigned refCount_r) const override
Trigger from Rep, after refCount was decreased.
Definition librpmDb.cc:237
Definition Arch.h:364
String related utilities and Regular expression matching.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition NonCopyable.h:26
std::ostream & operator<<(std::ostream &str, const librpmDb::db_const_iterator &obj)
Definition librpmDb.cc:412
_dumpPath dumpPath(const Pathname &root_r, const Pathname &sub_r)
dumpPath iomaip to dump '(root_r)sub_r' output,
Definition librpmDb.h:42
Easy-to use interface to the ZYPP dependency resolver.
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247
const Pathname & _sub
Definition librpmDb.h:36
const Pathname & _root
Definition librpmDb.h:35
_dumpPath(const Pathname &root_r, const Pathname &sub_r)
Definition librpmDb.h:31
#define ZYPP_DEPRECATED
The ZYPP_DEPRECATED macro can be used to trigger compile-time warnings with gcc >= 3....
Definition Globals.h:112