libzypp  17.29.1
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
44 {
45 
46 public:
47 
48  typedef intrusive_ptr<BinHeader> Ptr;
49 
50  typedef intrusive_ptr<const BinHeader> constPtr;
51 
52  typedef rpmTag tag;
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  virtual ~BinHeader();
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  virtual std::ostream & dumpOn( std::ostream & str ) const;
105 };
106 
108 
110 //
111 // CLASS NAME : BinHeader::intList
116 {
117  public:
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
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
Base class for reference counted objects.
long operator[](const unsigned idx_r) const
Definition: BinHeader.h:128
unsigned set(void *val_r, unsigned cnt_r, rpmTagType type_r)
Definition: BinHeader.cc:94
std::vector< std::string > _data
Definition: BinHeader.h:165
std::string operator[](const unsigned idx_r) const
Definition: BinHeader.h:157
unsigned set(char **val_r, unsigned cnt_r)
Definition: BinHeader.cc:134
std::string string_val(tag tag_r) const
Definition: BinHeader.cc:375
unsigned string_list(tag tag_r, stringList &lst_r) const
Definition: BinHeader.cc:279
virtual std::ostream & dumpOn(std::ostream &str) const
Overload to realize std::ostream & operator<<.
Definition: BinHeader.cc:444
std::string format(const char *fmt) const
Definition: BinHeader.cc:398
intrusive_ptr< const BinHeader > constPtr
Definition: BinHeader.h:50
ByteArray blob_val(tag tag_r) const
Definition: BinHeader.cc:345
intrusive_ptr< BinHeader > Ptr
Definition: BinHeader.h:48
int int_val(tag tag_r) const
Definition: BinHeader.cc:310
std::list< std::string > stringList_val(tag tag_r) const
Definition: BinHeader.cc:420
bool has_tag(tag tag_r) const
Definition: BinHeader.cc:227
unsigned int_list(tag tag_r, intList &lst_r) const
Definition: BinHeader.cc:240
String related utilities and Regular expression matching.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition: NonCopyable.h:26
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2