libzypp  11.13.5
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 
92 public:
93 
94  std::list<std::string> stringList_val( tag tag_r ) const;
95 
96 public:
97 
98  virtual std::ostream & dumpOn( std::ostream & str ) const;
99 };
100 
102 
104 //
105 // CLASS NAME : BinHeader::intList
110 {
111  public:
113  : _type( RPM_NULL_TYPE )
114  {}
115 
116  bool empty() const
117  { return _data.empty(); }
118 
119  unsigned size() const
120  { return _data.size(); }
121 
122  long operator[]( const unsigned idx_r ) const
123  { return idx_r < _data.size() ? _data[idx_r] : 0; }
124 
125  private:
126  friend class BinHeader;
127  unsigned set( void * val_r, unsigned cnt_r, rpmTagType type_r );
128 
129  private:
130  std::vector<long> _data;
131  rpmTagType _type;
132 };
133 
135 
137 //
138 // CLASS NAME : BinHeader::stringList
143 {
144  public:
145  bool empty() const
146  { return _data.empty(); }
147 
148  unsigned size() const
149  { return _data.size(); }
150 
151  std::string operator[]( const unsigned idx_r ) const
152  { return idx_r < _data.size() ? _data[idx_r] : std::string(); }
153 
154  private:
155  friend class BinHeader;
156  unsigned set( char ** val_r, unsigned cnt_r );
157 
158  private:
159  std::vector<std::string> _data;
160 };
161 
163 
164 } // namespace rpm
165 } // namespace target
166 } // namespace zypp
167 
168 #endif // ZYPP_TARGET_RPM_BINHEADER_H