BinHeader.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00012 #ifndef ZYPP_TARGET_RPM_BINHEADER_H
00013 #define ZYPP_TARGET_RPM_BINHEADER_H
00014
00015 extern "C"
00016 {
00017 #include <stdint.h>
00018 }
00019
00020 #include <iosfwd>
00021 #include <string>
00022 #include <vector>
00023 #include <list>
00024
00025 #include "zypp/base/ReferenceCounted.h"
00026 #include "zypp/base/NonCopyable.h"
00027 #include "zypp/base/PtrTypes.h"
00028 #include "zypp/target/rpm/librpm.h"
00029
00030 namespace zypp
00031 {
00032 namespace target
00033 {
00034 namespace rpm
00035 {
00037
00038
00042 class BinHeader : public base::ReferenceCounted, private base::NonCopyable
00043 {
00044
00045 public:
00046
00047 typedef intrusive_ptr<BinHeader> Ptr;
00048
00049 typedef intrusive_ptr<const BinHeader> constPtr;
00050
00051 typedef rpmTag tag;
00052
00053 class intList;
00054
00055 class stringList;
00056
00057 private:
00058
00059 Header _h;
00060
00061 bool assertHeader();
00062
00063 public:
00064
00065 BinHeader( Header h_r = 0 );
00066
00071 BinHeader( BinHeader::Ptr & rhs );
00072
00073 virtual ~BinHeader();
00074
00075 public:
00076
00077 bool empty() const
00078 {
00079 return( _h == NULL );
00080 }
00081
00082 bool has_tag( tag tag_r ) const;
00083
00084 unsigned int_list( tag tag_r, intList & lst_r ) const;
00085
00086 unsigned string_list( tag tag_r, stringList & lst_r ) const;
00087
00088 int int_val( tag tag_r ) const;
00089
00090 std::string string_val( tag tag_r ) const;
00091
00092 public:
00093
00094 std::list<std::string> stringList_val( tag tag_r ) const;
00095
00096 public:
00097
00098 virtual std::ostream & dumpOn( std::ostream & str ) const;
00099 };
00100
00102
00104
00105
00109 class BinHeader::intList : private base::NonCopyable
00110 {
00111 public:
00112 intList()
00113 : _type( RPM_NULL_TYPE )
00114 {}
00115
00116 bool empty() const
00117 { return _data.empty(); }
00118
00119 unsigned size() const
00120 { return _data.size(); }
00121
00122 long operator[]( const unsigned idx_r ) const
00123 { return idx_r < _data.size() ? _data[idx_r] : 0; }
00124
00125 private:
00126 friend class BinHeader;
00127 unsigned set( void * val_r, unsigned cnt_r, rpmTagType type_r );
00128
00129 private:
00130 std::vector<long> _data;
00131 rpmTagType _type;
00132 };
00133
00135
00137
00138
00142 class BinHeader::stringList : private base::NonCopyable
00143 {
00144 public:
00145 bool empty() const
00146 { return _data.empty(); }
00147
00148 unsigned size() const
00149 { return _data.size(); }
00150
00151 std::string operator[]( const unsigned idx_r ) const
00152 { return idx_r < _data.size() ? _data[idx_r] : std::string(); }
00153
00154 private:
00155 friend class BinHeader;
00156 unsigned set( char ** val_r, unsigned cnt_r );
00157
00158 private:
00159 std::vector<std::string> _data;
00160 };
00161
00163
00164 }
00165 }
00166 }
00167
00168 #endif // ZYPP_TARGET_RPM_BINHEADER_H