00001 /*---------------------------------------------------------------------\ 00002 | | 00003 | __ __ ____ _____ ____ | 00004 | \ \ / /_ _/ ___|_ _|___ \ | 00005 | \ V / _` \___ \ | | __) | | 00006 | | | (_| |___) || | / __/ | 00007 | |_|\__,_|____/ |_| |_____| | 00008 | | 00009 | core system | 00010 | (C) SuSE GmbH | 00011 \----------------------------------------------------------------------/ 00012 00013 File: PkgChangelog.h 00014 00015 Author: Michael Andres <ma@suse.de> 00016 Maintainer: Michael Andres <ma@suse.de> 00017 00018 Purpose: Helper class providing changelog information. 00019 00020 /-*/ 00021 #ifndef PkgChangelog_h 00022 #define PkgChangelog_h 00023 00024 #include <iosfwd> 00025 #include <list> 00026 #include <string> 00027 00028 #include <y2util/Date.h> 00029 00031 // 00032 // CLASS NAME : PkgChangelog 00045 class PkgChangelog { 00046 00050 friend std::ostream & operator<<( std::ostream & str, const PkgChangelog & obj ); 00051 00052 public: 00053 00054 struct Entry { 00058 Date _date; 00062 std::string _name; 00066 std::string _text; 00070 Entry( const Date & d, const std::string & n, const std::string & t ) 00071 : _date( d ), _name( n ), _text( t ) 00072 {} 00073 }; 00074 00075 private: 00076 00080 std::list<Entry> _entries; 00081 00082 public: 00083 00087 PkgChangelog() {} 00091 ~PkgChangelog() {} 00095 void push_back( const Entry & e_r ) { _entries.push_back( e_r ); } 00099 void push_front( const Entry & e_r ) { _entries.push_front( e_r ); } 00103 unsigned size() const { return _entries.size(); } 00104 00105 public: 00106 00107 typedef std::list<Entry>::iterator iterator; 00108 typedef std::list<Entry>::reverse_iterator reverse_iterator; 00109 00113 iterator begin() { return _entries.begin(); } 00117 iterator end() { return _entries.end(); } 00121 reverse_iterator rbegin() { return _entries.rbegin(); } 00125 reverse_iterator rend() { return _entries.rend(); } 00126 00127 typedef std::list<Entry>::const_iterator const_iterator; 00128 typedef std::list<Entry>::const_reverse_iterator const_reverse_iterator; 00129 00133 const_iterator begin() const { return _entries.begin(); } 00137 const_iterator end() const { return _entries.end(); } 00141 const_reverse_iterator rbegin() const { return _entries.rbegin(); } 00145 const_reverse_iterator rend() const { return _entries.rend(); } 00146 00147 public: 00148 00153 std::list<std::string> asStringList() const; 00154 }; 00155 00157 00158 #endif // PkgChangelog_h