libzypp 8.13.6
|
00001 /*---------------------------------------------------------------------\ 00002 | ____ _ __ __ ___ | 00003 | |__ / \ / / . \ . \ | 00004 | / / \ V /| _/ _/ | 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 <list> 00023 00024 #include "zypp/base/ReferenceCounted.h" 00025 #include "zypp/base/NonCopyable.h" 00026 #include "zypp/base/PtrTypes.h" 00027 #include "zypp/target/rpm/librpm.h" 00028 00029 namespace zypp 00030 { 00031 namespace target 00032 { 00033 namespace rpm 00034 { 00036 // 00037 // CLASS NAME : BinHeader 00041 class BinHeader : public base::ReferenceCounted, private base::NonCopyable 00042 { 00043 00044 public: 00045 00046 typedef intrusive_ptr<BinHeader> Ptr; 00047 00048 typedef intrusive_ptr<const BinHeader> constPtr; 00049 00050 typedef rpmTag tag; 00051 00052 class intList; 00053 00054 class stringList; 00055 00056 private: 00057 00058 Header _h; 00059 00060 bool assertHeader(); 00061 00062 public: 00063 00064 BinHeader( Header h_r = 0 ); 00065 00070 BinHeader( BinHeader::Ptr & rhs ); 00071 00072 virtual ~BinHeader(); 00073 00074 public: 00075 00076 bool empty() const 00077 { 00078 return( _h == NULL ); 00079 } 00080 00081 bool has_tag( tag tag_r ) const; 00082 00083 unsigned int_list( tag tag_r, intList & lst_r ) const; 00084 00085 unsigned string_list( tag tag_r, stringList & lst_r ) const; 00086 00087 int int_val( tag tag_r ) const; 00088 00089 std::string string_val( tag tag_r ) const; 00090 00091 public: 00092 00093 std::list<std::string> stringList_val( tag tag_r ) const; 00094 00095 public: 00096 00097 virtual std::ostream & dumpOn( std::ostream & str ) const; 00098 }; 00099 00101 00103 // 00104 // CLASS NAME : BinHeader::intList 00108 class BinHeader::intList 00109 { 00110 intList ( const intList & ); 00111 intList & operator=( const intList & ); 00112 private: 00113 unsigned cnt; 00114 void * val; 00115 rpmTagType type; 00116 private: 00117 friend class BinHeader; 00118 unsigned set( void * val_r, unsigned cnt_r, rpmTagType type_r ); 00119 public: 00120 intList(); 00121 bool empty() const 00122 { 00123 return cnt==0; 00124 } 00125 unsigned size() const 00126 { 00127 return cnt; 00128 } 00129 int operator[]( const unsigned idx_r ) const; 00130 }; 00131 00133 00135 // 00136 // CLASS NAME : BinHeader::stringList 00140 class BinHeader::stringList 00141 { 00142 stringList ( const stringList & ); 00143 stringList & operator=( const stringList & ); 00144 private: 00145 unsigned cnt; 00146 char ** val; 00147 void clear(); 00148 private: 00149 friend class BinHeader; 00150 unsigned set( char ** val_r, unsigned cnt_r ); 00151 public: 00152 stringList(); 00153 ~stringList() 00154 { 00155 clear(); 00156 } 00157 bool empty() const 00158 { 00159 return cnt==0; 00160 } 00161 unsigned size() const 00162 { 00163 return cnt; 00164 } 00165 std::string operator[]( const unsigned idx_r ) const; 00166 }; 00167 00169 00170 } // namespace rpm 00171 } // namespace target 00172 } // namespace zypp 00173 00174 #endif // ZYPP_TARGET_RPM_BINHEADER_H