libzypp
10.5.0
|
00001 /*---------------------------------------------------------------------\ 00002 | ____ _ __ __ ___ | 00003 | |__ / \ / / . \ . \ | 00004 | / / \ V /| _/ _/ | 00005 | / /__ | | | | | | | 00006 | /_____||_| |_| |_| | 00007 | | 00008 \---------------------------------------------------------------------*/ 00012 #ifndef ZYPP_PARSER_PRODUCTSDREADER_H 00013 #define ZYPP_PARSER_PRODUCTSDREADER_H 00014 00015 #include <iosfwd> 00016 00017 #include "zypp/base/PtrTypes.h" 00018 #include "zypp/base/Function.h" 00019 #include "zypp/base/InputStream.h" 00020 00021 #include "zypp/Pathname.h" 00022 #include "zypp/IdString.h" 00023 #include "zypp/Edition.h" 00024 #include "zypp/Arch.h" 00025 00027 namespace zypp 00028 { 00029 00030 namespace parser 00031 { 00032 00034 // 00035 // CLASS NAME : ProductFileData 00036 // 00040 class ProductFileData 00041 { 00042 public: 00043 class Impl; 00045 ProductFileData( Impl * allocated_r = 0 ); 00046 00048 bool empty() const 00049 { return name().empty(); } 00050 00051 public: 00052 IdString vendor() const; 00053 IdString name() const; 00054 Edition edition() const; 00055 Arch arch() const; 00056 00057 std::string shortName() const; 00058 std::string summary() const; 00059 00060 public: 00061 std::string productline() const; 00062 std::string registerTarget() const; 00063 std::string registerRelease() const; 00064 00065 public: 00066 std::string updaterepokey() const; 00067 00068 public: 00070 00071 struct Upgrade 00072 { 00073 public: 00074 class Impl; 00076 Upgrade( Impl * allocated_r = 0 ); 00077 00078 public: 00079 std::string name() const; 00080 std::string summary() const; 00081 std::string repository() const; 00082 std::string product() const; 00083 bool notify() const; 00084 std::string status() const; 00085 00086 private: 00087 RWCOW_pointer<Impl> _pimpl; 00088 }; 00090 00091 typedef std::vector<Upgrade> Upgrades; 00092 const Upgrades & upgrades() const; 00093 00094 private: 00095 RWCOW_pointer<Impl> _pimpl; 00096 }; 00098 00100 std::ostream & operator<<( std::ostream & str, const ProductFileData & obj ); 00101 00103 std::ostream & operator<<( std::ostream & str, const ProductFileData::Upgrade & obj ); 00104 00106 // 00107 // CLASS NAME : ProductFileReader 00108 // 00119 class ProductFileReader 00120 { 00121 public: 00125 typedef function<bool( const ProductFileData & )> Consumer; 00126 00127 public: 00128 ProductFileReader() 00129 {} 00130 00131 ProductFileReader( const Consumer & consumer_r ) 00132 : _consumer( consumer_r ) 00133 {} 00134 00135 ProductFileReader( const Consumer & consumer_r, const InputStream & input_r ) 00136 : _consumer( consumer_r ) 00137 { parse( input_r ); } 00138 00139 public: 00140 const Consumer & consumer() const 00141 { return _consumer; } 00142 00143 void setConsumer( const Consumer & consumer_r ) 00144 { _consumer = consumer_r; } 00145 00146 public: 00152 bool parse( const InputStream & input_r = InputStream() ) const; 00153 00154 public: 00160 static bool scanDir( const Consumer & consumer_r, const Pathname & dir_r ); 00161 00164 static ProductFileData scanFile( const Pathname & file_r ); 00165 00166 private: 00167 Consumer _consumer; 00168 }; 00170 00172 } // namespace parser 00175 } // namespace zypp 00177 #endif // ZYPP_PARSER_PRODUCTSDREADER_H