libzypp  17.25.0
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 
26 #include <zypp/base/NonCopyable.h>
27 #include <zypp/base/PtrTypes.h>
28 #include <zypp/target/rpm/librpm.h>
29 
30 namespace zypp
31 {
32 namespace target
33 {
34 namespace rpm
35 {
37 //
38 // CLASS NAME : BinHeader
43 {
44 
45 public:
46 
47  typedef intrusive_ptr<BinHeader> Ptr;
48 
49  typedef intrusive_ptr<const BinHeader> constPtr;
50 
51  typedef rpmTag tag;
52 
53  class intList;
54 
55  class stringList;
56 
57 private:
58 
59  Header _h;
60 
61  bool assertHeader();
62 
63 public:
64 
65  BinHeader( Header h_r = 0 );
66 
71  BinHeader( BinHeader::Ptr & rhs );
72 
73  virtual ~BinHeader();
74 
75 public:
76 
77  bool empty() const
78  {
79  return( _h == NULL );
80  }
81 
82  bool has_tag( tag tag_r ) const;
83 
84  unsigned int_list( tag tag_r, intList & lst_r ) const;
85 
86  unsigned string_list( tag tag_r, stringList & lst_r ) const;
87 
88  int int_val( tag tag_r ) const;
89 
90  std::string string_val( tag tag_r ) const;
91  std::string format ( const char * fmt) const;
92 
93 public:
94 
95  std::list<std::string> stringList_val( tag tag_r ) const;
96 
97 public:
98 
99  virtual std::ostream & dumpOn( std::ostream & str ) const;
100 };
101 
103 
105 //
106 // CLASS NAME : BinHeader::intList
111 {
112  public:
114  : _type( RPM_NULL_TYPE )
115  {}
116 
117  bool empty() const
118  { return _data.empty(); }
119 
120  unsigned size() const
121  { return _data.size(); }
122 
123  long operator[]( const unsigned idx_r ) const
124  { return idx_r < _data.size() ? _data[idx_r] : 0; }
125 
126  private:
127  friend class BinHeader;
128  unsigned set( void * val_r, unsigned cnt_r, rpmTagType type_r );
129 
130  private:
131  std::vector<long> _data;
132  rpmTagType _type;
133 };
134 
136 
138 //
139 // CLASS NAME : BinHeader::stringList
144 {
145  public:
146  bool empty() const
147  { return _data.empty(); }
148 
149  unsigned size() const
150  { return _data.size(); }
151 
152  std::string operator[]( const unsigned idx_r ) const
153  { return idx_r < _data.size() ? _data[idx_r] : std::string(); }
154 
155  private:
156  friend class BinHeader;
157  unsigned set( char ** val_r, unsigned cnt_r );
158 
159  private:
160  std::vector<std::string> _data;
161 };
162 
164 
165 } // namespace rpm
166 } // namespace target
167 } // namespace zypp
168 
169 #endif // ZYPP_TARGET_RPM_BINHEADER_H
zypp::target::rpm::BinHeader::stringList::operator[]
std::string operator[](const unsigned idx_r) const
Definition: BinHeader.h:152
zypp::target::rpm::BinHeader::stringList::empty
bool empty() const
Definition: BinHeader.h:146
zypp::target::rpm::BinHeader
Definition: BinHeader.h:42
zypp::target::rpm::BinHeader::string_val
std::string string_val(tag tag_r) const
Definition: BinHeader.cc:353
zypp::base::ReferenceCounted
Base class for reference counted objects.
Definition: ReferenceCounted.h:33
zypp::target::rpm::BinHeader::intList::operator[]
long operator[](const unsigned idx_r) const
Definition: BinHeader.h:123
zypp::target::rpm::BinHeader::intList::set
unsigned set(void *val_r, unsigned cnt_r, rpmTagType type_r)
Definition: BinHeader.cc:94
zypp::target::rpm::BinHeader::int_list
unsigned int_list(tag tag_r, intList &lst_r) const
Definition: BinHeader.cc:240
zypp::target::rpm::BinHeader::constPtr
intrusive_ptr< const BinHeader > constPtr
Definition: BinHeader.h:49
PtrTypes.h
zypp::target::rpm::BinHeader::empty
bool empty() const
Definition: BinHeader.h:77
zypp::target::rpm::BinHeader::has_tag
bool has_tag(tag tag_r) const
Definition: BinHeader.cc:227
zypp::target::rpm::BinHeader::assertHeader
bool assertHeader()
Definition: BinHeader.cc:205
zypp::target::rpm::BinHeader::int_val
int int_val(tag tag_r) const
Definition: BinHeader.cc:310
zypp::target::rpm::BinHeader::stringList_val
std::list< std::string > stringList_val(tag tag_r) const
Definition: BinHeader.cc:393
zypp::target::rpm::BinHeader::~BinHeader
virtual ~BinHeader()
Definition: BinHeader.cc:191
zypp::target::rpm::BinHeader::intList::intList
intList()
Definition: BinHeader.h:113
zypp::target::rpm::BinHeader::stringList::set
unsigned set(char **val_r, unsigned cnt_r)
Definition: BinHeader.cc:134
zypp::base::NonCopyable
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition: NonCopyable.h:26
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
zypp::target::rpm::BinHeader::intList
Definition: BinHeader.h:110
zypp::target::rpm::BinHeader::intList::_data
std::vector< long > _data
Definition: BinHeader.h:131
zypp::target::rpm::BinHeader::_h
Header _h
Definition: BinHeader.h:55
zypp::target::rpm::BinHeader::format
std::string format(const char *fmt) const
Definition: BinHeader.cc:376
zypp::target::rpm::BinHeader::stringList
Definition: BinHeader.h:143
zypp::target::rpm::BinHeader::stringList::_data
std::vector< std::string > _data
Definition: BinHeader.h:160
zypp::target::rpm::BinHeader::intList::empty
bool empty() const
Definition: BinHeader.h:117
zypp::target::rpm::BinHeader::intList::_type
rpmTagType _type
Definition: BinHeader.h:132
zypp::target::rpm::BinHeader::stringList::size
unsigned size() const
Definition: BinHeader.h:149
ReferenceCounted.h
zypp::target::rpm::BinHeader::dumpOn
virtual std::ostream & dumpOn(std::ostream &str) const
Overload to realize std::ostream & operator<<.
Definition: BinHeader.cc:417
zypp::target::rpm::BinHeader::Ptr
intrusive_ptr< BinHeader > Ptr
Definition: BinHeader.h:47
librpm.h
str
String related utilities and Regular expression matching.
zypp::target::rpm::BinHeader::BinHeader
BinHeader(Header h_r=0)
Definition: BinHeader.cc:155
zypp::target::rpm::BinHeader::tag
rpmTag tag
Definition: BinHeader.h:51
zypp::target::rpm::BinHeader::intList::size
unsigned size() const
Definition: BinHeader.h:120
zypp::target::rpm::BinHeader::string_list
unsigned string_list(tag tag_r, stringList &lst_r) const
Definition: BinHeader.cc:279
NonCopyable.h