libzypp
10.5.0
|
Reads a zypp history log file and calls the ProcessItem function passed in the constructor for each item read. More...
#include <HistoryLogReader.h>
Classes | |
struct | Impl |
Public Types | |
typedef function< bool(const HistoryItem::Ptr &)> | ProcessItem |
Public Member Functions | |
HistoryLogReader (const Pathname &repo_file, const ProcessItem &callback) | |
~HistoryLogReader () | |
void | readAll (const ProgressData::ReceiverFnc &progress=ProgressData::ReceiverFnc()) |
Read the whole log file. | |
void | readFrom (const Date &date, const ProgressData::ReceiverFnc &progress=ProgressData::ReceiverFnc()) |
Read log from specified date. | |
void | readFromTo (const Date &fromDate, const Date &toDate, const ProgressData::ReceiverFnc &progress=ProgressData::ReceiverFnc()) |
Read log between fromDate and toDate. | |
void | setIgnoreInvalidItems (bool ignoreInvalid=false) |
Set the reader to ignore invalid log entries and continue with the rest. | |
bool | ignoreInvalidItems () const |
Whether the reader is set to ignore invalid log entries. | |
Private Attributes | |
RW_pointer< Impl, rw_pointer::Scoped< Impl > > | _pimpl |
Reads a zypp history log file and calls the ProcessItem function passed in the constructor for each item read.
Example:
struct HistoryItemCollector { vector<HistoryItem::Ptr> items;
bool operator()( const HistoryItem::Ptr & item_ptr ) { items.push_back(item_ptr); return true; } }
...
HistoryItemCollector ic; HistoryLogReader reader("/var/log/zypp/history", boost::ref(ic));
try { reader.readAll(); } catch (const Exception & e) { cout << e.asUserHistory() << endl; }
Definition at line 73 of file HistoryLogReader.h.
typedef function< bool( const HistoryItem::Ptr & )> zypp::parser::HistoryLogReader::ProcessItem |
Definition at line 76 of file HistoryLogReader.h.
zypp::parser::HistoryLogReader::HistoryLogReader | ( | const Pathname & | repo_file, |
const ProcessItem & | callback | ||
) |
Definition at line 248 of file HistoryLogReader.cc.
zypp::parser::HistoryLogReader::~HistoryLogReader | ( | ) |
Definition at line 253 of file HistoryLogReader.cc.
void zypp::parser::HistoryLogReader::readAll | ( | const ProgressData::ReceiverFnc & | progress = ProgressData::ReceiverFnc() | ) |
Read the whole log file.
progress | An optional progress data receiver function. |
Definition at line 262 of file HistoryLogReader.cc.
void zypp::parser::HistoryLogReader::readFrom | ( | const Date & | date, |
const ProgressData::ReceiverFnc & | progress = ProgressData::ReceiverFnc() |
||
) |
Read log from specified date.
date | Date from which to read. |
progress | An optional progress data receiver function. |
Definition at line 265 of file HistoryLogReader.cc.
void zypp::parser::HistoryLogReader::readFromTo | ( | const Date & | fromDate, |
const Date & | toDate, | ||
const ProgressData::ReceiverFnc & | progress = ProgressData::ReceiverFnc() |
||
) |
Read log between fromDate and toDate.
The date comparison's precision goes to seconds. Omitted time parts get replaced by zeroes, so if e.g. the time is not specified at all, the date means midnight of the specified date. So
fromDate = Date("2009-01-01", "%Y-%m-%d"); toDate = Date("2009-01-02", "%Y-%m-%d");
will yield log entries from midnight of January, 1st untill one second before midnight of January, 2nd.
fromDate | Date from which to read. |
toDate | Date on which to stop reading. |
progress | An optional progress data receiver function. |
Definition at line 269 of file HistoryLogReader.cc.
void zypp::parser::HistoryLogReader::setIgnoreInvalidItems | ( | bool | ignoreInvalid = false | ) |
Set the reader to ignore invalid log entries and continue with the rest.
ignoreInvalid | true will cause the reader to ignore invalid entries |
Definition at line 256 of file HistoryLogReader.cc.
bool zypp::parser::HistoryLogReader::ignoreInvalidItems | ( | ) | const |
Whether the reader is set to ignore invalid log entries.
Definition at line 259 of file HistoryLogReader.cc.
Definition at line 140 of file HistoryLogReader.h.