libzypp  17.7.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
std::string operator[](const unsigned idx_r) const
Definition: BinHeader.h:152
std::string format(const char *fmt) const
Definition: BinHeader.cc:376
String related utilities and Regular expression matching.
intrusive_ptr< BinHeader > Ptr
Definition: BinHeader.h:47
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition: NonCopyable.h:26
unsigned string_list(tag tag_r, stringList &lst_r) const
Definition: BinHeader.cc:279
Base class for reference counted objects.
std::string string_val(tag tag_r) const
Definition: BinHeader.cc:353
std::vector< std::string > _data
Definition: BinHeader.h:160
intrusive_ptr< const BinHeader > constPtr
Definition: BinHeader.h:49
virtual std::ostream & dumpOn(std::ostream &str) const
Overload to realize std::ostream & operator<<.
Definition: BinHeader.cc:417
unsigned int_list(tag tag_r, intList &lst_r) const
Definition: BinHeader.cc:240
long operator[](const unsigned idx_r) const
Definition: BinHeader.h:123
std::list< std::string > stringList_val(tag tag_r) const
Definition: BinHeader.cc:393
bool has_tag(tag tag_r) const
Definition: BinHeader.cc:227
int int_val(tag tag_r) const
Definition: BinHeader.cc:310
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1