libzypp 17.37.10

BinHeader.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_TARGET_RPM_BINHEADER_H
13#define ZYPP_TARGET_RPM_BINHEADER_H
14
15 extern "C"
16{
17#include <stdint.h>
18}
19
20#include <iosfwd>
21#include <string>
22#include <vector>
23#include <list>
24
25#include <zypp/base/ReferenceCounted.h>
26#include <zypp/base/NonCopyable.h>
27#include <zypp/base/PtrTypes.h>
28#include <zypp/target/rpm/librpm.h>
29#include <zypp-core/ByteArray.h>
30
31 namespace zypp
32{
33 namespace target
34{
35 namespace rpm
36{
38//
39// CLASS NAME : BinHeader
43 class BinHeader : public base::ReferenceCounted, private base::NonCopyable
44{
45
46 public:
47
48 using Ptr = intrusive_ptr<BinHeader>;
49
50 using constPtr = intrusive_ptr<const BinHeader>;
51
52 using tag = rpmTag;
53
54 class intList;
55
56 class stringList;
57
58 private:
59
60 Header _h;
61
62 bool assertHeader();
63
64 public:
65
66 BinHeader( Header h_r = 0 );
67
72 BinHeader( BinHeader::Ptr & rhs );
73
74 ~BinHeader() override;
75
76 public:
77
78 bool empty() const
79 {
80 return( _h == NULL );
81 }
82
83 bool has_tag( tag tag_r ) const;
84
85 unsigned int_list( tag tag_r, intList & lst_r ) const;
86
87 unsigned string_list( tag tag_r, stringList & lst_r ) const;
88
89 int int_val( tag tag_r ) const;
90
91 ByteArray blob_val ( tag tag_r ) const;
92
93 std::string string_val( tag tag_r ) const;
94 std::string format ( const char * fmt) const;
95
96 Header get() const;
97
98 public:
99
100 std::list<std::string> stringList_val( tag tag_r ) const;
101
102 public:
103
104 std::ostream & dumpOn( std::ostream & str ) const override;
105};
106
108
110//
111// CLASS NAME : BinHeader::intList
115 class BinHeader::intList : private base::NonCopyable
116{
117 public:
118 intList()
119 : _type( RPM_NULL_TYPE )
120 {}
121
122 bool empty() const
123 { return _data.empty(); }
124
125 unsigned size() const
126 { return _data.size(); }
127
128 long operator[]( const unsigned idx_r ) const
129 { return idx_r < _data.size() ? _data[idx_r] : 0; }
130
131 private:
132 friend class BinHeader;
133 unsigned set( void * val_r, unsigned cnt_r, rpmTagType type_r );
134
135 private:
136 std::vector<long> _data;
137 rpmTagType _type;
138};
139
141
143//
144// CLASS NAME : BinHeader::stringList
148 class BinHeader::stringList : private base::NonCopyable
149{
150 public:
151 bool empty() const
152 { return _data.empty(); }
153
154 unsigned size() const
155 { return _data.size(); }
156
157 std::string operator[]( const unsigned idx_r ) const
158 { return idx_r < _data.size() ? _data[idx_r] : std::string(); }
159
160 private:
161 friend class BinHeader;
162 unsigned set( char ** val_r, unsigned cnt_r );
163
164 private:
165 std::vector<std::string> _data;
166};
167
169
170} // namespace rpm
171} // namespace target
172} // namespace zypp
173
174#endif // ZYPP_TARGET_RPM_BINHEADER_H
intrusive_ptr
zypp::ByteArray
Definition ByteArray.h:19
zypp::base::ReferenceCounted
Base class for reference counted objects.
Definition ReferenceCounted.h:35
zypp::target::rpm::BinHeader::intList
Definition BinHeader.h:116
zypp::target::rpm::BinHeader::intList::size
unsigned size() const
Definition BinHeader.h:125
zypp::target::rpm::BinHeader::intList::empty
bool empty() const
Definition BinHeader.h:122
zypp::target::rpm::BinHeader::intList::intList
intList()
Definition BinHeader.h:118
zypp::target::rpm::BinHeader::intList::BinHeader
friend class BinHeader
Definition BinHeader.h:132
zypp::target::rpm::BinHeader::intList::operator[]
long operator[](const unsigned idx_r) const
Definition BinHeader.h:128
zypp::target::rpm::BinHeader::intList::set
unsigned set(void *val_r, unsigned cnt_r, rpmTagType type_r)
Definition BinHeader.cc:100
zypp::target::rpm::BinHeader::intList::_type
rpmTagType _type
Definition BinHeader.h:137
zypp::target::rpm::BinHeader::intList::_data
std::vector< long > _data
Definition BinHeader.h:136
zypp::target::rpm::BinHeader::stringList
Definition BinHeader.h:149
zypp::target::rpm::BinHeader::stringList::_data
std::vector< std::string > _data
Definition BinHeader.h:165
zypp::target::rpm::BinHeader::stringList::operator[]
std::string operator[](const unsigned idx_r) const
Definition BinHeader.h:157
zypp::target::rpm::BinHeader::stringList::size
unsigned size() const
Definition BinHeader.h:154
zypp::target::rpm::BinHeader::stringList::set
unsigned set(char **val_r, unsigned cnt_r)
Definition BinHeader.cc:140
zypp::target::rpm::BinHeader::stringList::empty
bool empty() const
Definition BinHeader.h:151
zypp::target::rpm::BinHeader::stringList::BinHeader
friend class BinHeader
Definition BinHeader.h:161
zypp::target::rpm::BinHeader::Ptr
intrusive_ptr< BinHeader > Ptr
Definition BinHeader.h:48
zypp::target::rpm::BinHeader::string_val
std::string string_val(tag tag_r) const
Definition BinHeader.cc:381
zypp::target::rpm::BinHeader::constPtr
intrusive_ptr< const BinHeader > constPtr
Definition BinHeader.h:50
zypp::target::rpm::BinHeader::empty
bool empty() const
Definition BinHeader.h:78
zypp::target::rpm::BinHeader::string_list
unsigned string_list(tag tag_r, stringList &lst_r) const
Definition BinHeader.cc:285
zypp::target::rpm::BinHeader::_h
Header _h
Definition BinHeader.h:60
zypp::target::rpm::BinHeader::BinHeader
BinHeader(Header h_r=0)
Definition BinHeader.cc:161
zypp::target::rpm::BinHeader::format
std::string format(const char *fmt) const
Definition BinHeader.cc:404
zypp::target::rpm::BinHeader::~BinHeader
~BinHeader() override
Definition BinHeader.cc:197
zypp::target::rpm::BinHeader::blob_val
ByteArray blob_val(tag tag_r) const
Definition BinHeader.cc:351
zypp::target::rpm::BinHeader::dumpOn
std::ostream & dumpOn(std::ostream &str) const override
Overload to realize std::ostream & operator<<.
Definition BinHeader.cc:450
zypp::target::rpm::BinHeader::get
Header get() const
Definition BinHeader.cc:413
zypp::target::rpm::BinHeader::int_val
int int_val(tag tag_r) const
Definition BinHeader.cc:316
zypp::target::rpm::BinHeader::tag
rpmTag tag
Definition BinHeader.h:52
zypp::target::rpm::BinHeader::assertHeader
bool assertHeader()
Definition BinHeader.cc:211
zypp::target::rpm::BinHeader::stringList_val
std::list< std::string > stringList_val(tag tag_r) const
Definition BinHeader.cc:426
zypp::target::rpm::BinHeader::has_tag
bool has_tag(tag tag_r) const
Definition BinHeader.cc:233
zypp::target::rpm::BinHeader::int_list
unsigned int_list(tag tag_r, intList &lst_r) const
Definition BinHeader.cc:246
librpm.h
str
String related utilities and Regular expression matching.
zypp::base::NonCopyable
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition NonCopyable.h:26
zypp::target::rpm
Definition KeyRing.h:327
zypp::target
Definition KeyRing.h:325
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
ByteArray.h
NonCopyable.h
PtrTypes.h
ReferenceCounted.h