1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
10 /** \file HistoryLogReader.h
13 #ifndef ZYPP_HISTORYLOGREADER_H_
14 #define ZYPP_HISTORYLOGREADER_H_
16 #include "zypp/base/PtrTypes.h"
17 #include "zypp/ProgressData.h"
18 #include "zypp/Pathname.h"
20 #include "zypp/HistoryLogData.h"
22 ///////////////////////////////////////////////////////////////////
24 { /////////////////////////////////////////////////////////////////
28 ///////////////////////////////////////////////////////////////////
30 { /////////////////////////////////////////////////////////////////
33 /////////////////////////////////////////////////////////////////////
35 // CLASS NAME: HistoryLogReader
38 * Reads a zypp history log file and calls the ProcessItem function passed
39 * in the constructor for each item found.
44 * struct HistoryItemCollector
46 * vector<HistoryItem::Ptr> items;
48 * bool processEntry( const HistoryItem::Ptr & item_ptr )
50 * items.push_back(item_ptr);
57 * HistoryItemCollector ic;
58 * HistoryLogReader reader("/var/log/zypp/history", boost::ref(ic));
64 * catch (const Exception & e)
66 * cout << e.asUserHistory() << endl;
71 * \see http://en.opensuse.org/Libzypp/Package_History
73 class HistoryLogReader
76 typedef function< bool( const HistoryItem::Ptr & )> ProcessItem;
79 HistoryLogReader( const Pathname & repo_file,
80 const ProcessItem & callback );
84 * Read the whole log file.
87 const ProgressData::ReceiverFnc &progress = ProgressData::ReceiverFnc() );
90 * Read log from specified \a date.
92 void readFrom( const Date & date,
93 const ProgressData::ReceiverFnc &progress = ProgressData::ReceiverFnc() );
96 * Read log between \a fromDate and \a toDate.
98 void readFromTo( const Date & fromDate, const Date & toDate,
99 const ProgressData::ReceiverFnc &progress = ProgressData::ReceiverFnc() );
102 * Set the reader to ignore invalid log entries and continue with the rest.
104 * \param ignoreInvalid <tt>true</tt> will cause the reader to ignore invalid entries
106 void setIgnoreInvalidItems( bool ignoreInvalid = false );
109 * Whether the reader is set to ignore invalid log entries.
111 bool ignoreInvalidItems() const;
114 /** Implementation */
116 RW_pointer<Impl,rw_pointer::Scoped<Impl> > _pimpl;
118 ///////////////////////////////////////////////////////////////////
121 /////////////////////////////////////////////////////////////////
122 } // namespace parser
123 ///////////////////////////////////////////////////////////////////
124 /////////////////////////////////////////////////////////////////
126 ///////////////////////////////////////////////////////////////////
128 #endif /* ZYPP_HISTORYLOGREADER_H_ */