00001 /*---------------------------------------------------------------------\ 00002 | | 00003 | __ __ ____ _____ ____ | 00004 | \ \ / /_ _/ ___|_ _|___ \ | 00005 | \ V / _` \___ \ | | __) | | 00006 | | | (_| |___) || | / __/ | 00007 | |_|\__,_|____/ |_| |_____| | 00008 | | 00009 | core system | 00010 | (C) SuSE GmbH | 00011 \----------------------------------------------------------------------/ 00012 00013 File: binHeader.h 00014 00015 Author: Michael Andres <ma@suse.de> 00016 Maintainer: Michael Andres <ma@suse.de> 00017 00018 Purpose: 00019 00020 /-*/ 00021 #ifndef binHeader_h 00022 #define binHeader_h 00023 00024 extern "C" { 00025 #include <stdint.h> 00026 } 00027 00028 #include <iosfwd> 00029 #include <string> 00030 #include <list> 00031 00032 #include <y2pm/binHeaderPtr.h> 00033 00035 // 00036 // CLASS NAME : binHeader 00040 class binHeader : public CountedRep { 00041 REP_BODY(binHeader); 00042 00043 public: 00044 00045 typedef int32_t tag; 00046 00047 typedef struct headerToken * Header; 00048 00049 class intList; 00050 00051 class stringList; 00052 00053 private: 00054 00055 Header _h; 00056 00057 bool assertHeader(); 00058 00059 public: 00060 00061 binHeader( Header h_r = 0 ); 00062 00067 binHeader( binHeaderPtr & rhs ); 00068 00069 virtual ~binHeader(); 00070 00071 public: 00072 00073 bool empty() const { return( _h == NULL ); } 00074 00075 bool has_tag( tag tag_r ) const; 00076 00077 unsigned int_list( tag tag_r, intList & lst_r ) const; 00078 00079 unsigned string_list( tag tag_r, stringList & lst_r ) const; 00080 00081 int int_val( tag tag_r ) const; 00082 00083 std::string string_val( tag tag_r ) const; 00084 00085 public: 00086 00087 std::list<std::string> stringList_val( tag tag_r ) const; 00088 00089 public: 00090 00091 virtual std::ostream & dumpOn( std::ostream & str ) const; 00092 }; 00093 00095 00097 // 00098 // CLASS NAME : binHeader::intList 00102 class binHeader::intList { 00103 intList ( const intList & ); 00104 intList & operator=( const intList & ); 00105 private: 00106 unsigned cnt; 00107 void * val; 00108 tag type; 00109 private: 00110 friend class binHeader; 00111 unsigned set( void * val_r, tag cnt_r, tag type_r ); 00112 public: 00113 intList(); 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 unsigned size() const { return cnt; } 00140 std::string operator[]( const unsigned idx_r ) const; 00141 }; 00142 00144 00145 #endif // binHeader_h