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 #include <stdint.h> 00017 } 00018 00019 #include <iosfwd> 00020 #include <string> 00021 #include <list> 00022 00023 #include "zypp/base/ReferenceCounted.h" 00024 #include "zypp/base/NonCopyable.h" 00025 #include "zypp/base/PtrTypes.h" 00026 #include "zypp/target/rpm/librpm.h" 00027 00028 namespace zypp { 00029 namespace target { 00030 namespace rpm { 00032 // 00033 // CLASS NAME : BinHeader 00037 class BinHeader : public base::ReferenceCounted, private base::NonCopyable 00038 { 00039 00040 public: 00041 00042 typedef intrusive_ptr<BinHeader> Ptr; 00043 00044 typedef intrusive_ptr<const BinHeader> constPtr; 00045 00046 typedef int32_t tag; 00047 00048 class intList; 00049 00050 class stringList; 00051 00052 private: 00053 00054 Header _h; 00055 00056 bool assertHeader(); 00057 00058 public: 00059 00060 BinHeader( Header h_r = 0 ); 00061 00066 BinHeader( BinHeader::Ptr & rhs ); 00067 00068 virtual ~BinHeader(); 00069 00070 public: 00071 00072 bool empty() const { return( _h == NULL ); } 00073 00074 bool has_tag( tag tag_r ) const; 00075 00076 unsigned int_list( tag tag_r, intList & lst_r ) const; 00077 00078 unsigned string_list( tag tag_r, stringList & lst_r ) const; 00079 00080 int int_val( tag tag_r ) const; 00081 00082 std::string string_val( tag tag_r ) const; 00083 00084 public: 00085 00086 std::list<std::string> stringList_val( tag tag_r ) const; 00087 00088 public: 00089 00090 virtual std::ostream & dumpOn( std::ostream & str ) const; 00091 }; 00092 00094 00096 // 00097 // CLASS NAME : BinHeader::intList 00101 class BinHeader::intList { 00102 intList ( const intList & ); 00103 intList & operator=( const intList & ); 00104 private: 00105 unsigned cnt; 00106 void * val; 00107 tag type; 00108 private: 00109 friend class BinHeader; 00110 unsigned set( void * val_r, tag cnt_r, tag type_r ); 00111 public: 00112 intList(); 00113 bool empty() const { return cnt==0; } 00114 unsigned size() const { return cnt; } 00115 int operator[]( const unsigned idx_r ) const; 00116 }; 00117 00119 00121 // 00122 // CLASS NAME : BinHeader::stringList 00126 class BinHeader::stringList { 00127 stringList ( const stringList & ); 00128 stringList & operator=( const stringList & ); 00129 private: 00130 unsigned cnt; 00131 char ** val; 00132 void clear(); 00133 private: 00134 friend class BinHeader; 00135 unsigned set( char ** val_r, tag cnt_r ); 00136 public: 00137 stringList(); 00138 ~stringList() { clear(); } 00139 bool empty() const { return cnt==0; } 00140 unsigned size() const { return cnt; } 00141 std::string operator[]( const unsigned idx_r ) const; 00142 }; 00143 00145 00146 } // namespace rpm 00147 } // namespace target 00148 } // namespace zypp 00149 00150 #endif // ZYPP_TARGET_RPM_BINHEADER_H