38 Impl(
const Pathname & historyFile_r,
const Options & options_r,
const ProcessData & callback_r )
44 bool parseLine(
const std::string & line_r,
unsigned int lineNr_r );
60 if ( fields.size() >= 2 )
74 WAR <<
"Ignore invalid history log entry on line #" << lineNr_r <<
" '"<< line_r <<
"'" << endl;
79 ERR <<
"Invalid history log entry on line #" << lineNr_r <<
" '"<< line_r <<
"'" << endl;
89 WAR <<
"Stop parsing requested by consumer callback on line #" << lineNr_r << endl;
104 for ( ; line; line.
next(), pd.
tick() )
107 if ( (*line)[0] ==
'#' )
110 if ( ! parseLine( *line, line.
lineNo() ) )
126 bool pastDate =
false;
127 for ( ; line; line.
next(), pd.
tick() )
129 const std::string & s = *line;
137 if ( ! parseLine( s, line.
lineNo() ) )
143 if ( logDate > date_r )
146 if ( ! parseLine( s, line.
lineNo() ) )
164 bool pastFromDate =
false;
165 for ( ; line; line.
next(), pd.
tick() )
167 const std::string & s = *line;
176 if ( logDate >= toDate_r )
180 if ( !pastFromDate && logDate > fromDate_r )
185 if ( ! parseLine( s, line.
lineNo() ) )
213 {
_pimpl->readAll( progress_r ); }
216 {
_pimpl->readFrom( date_r, progress_r ); }
219 {
_pimpl->readFromTo( fromDate_r, toDate_r, progress_r ); }
void readFrom(const Date &date_r, const ProgressData::ReceiverFnc &progress_r)
std::vector< std::string > FieldVector
void sendTo(const ReceiverFnc &fnc_r)
Set ReceiverFnc.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
bool next()
Advance to next line.
Impl(const Pathname &historyFile_r, const Options &options_r, const ProcessData &callback_r)
bool ignoreInvalidItems() const
Whether the reader is set to ignore invalid log entries.
Zypp history file parserReads a zypp history log file and calls the ProcessData callback passed in th...
void readAll(const ProgressData::ReceiverFnc &progress=ProgressData::ReceiverFnc())
Read the whole log file.
void setIgnoreInvalidItems(bool ignoreInvalid=false)
Set the reader to ignore invalid log entries and continue with the rest.
bool toMax()
Set counter value to current max value (unless no range).
unsigned lineNo() const
Return the current line number.
Simple lineparser: Traverse each line in a file.
RW_pointer< Impl, rw_pointer::Scoped< Impl > > _pimpl
function< bool(const ProgressData &)> ReceiverFnc
Most simple version of progress reporting The percentage in most cases.
unsigned splitEscaped(const C_Str &line_r, _OutputIterator result_r, const C_Str &sepchars_r=" \t", bool withEmpty=false)
Split line_r into words with respect to escape delimeters.
function< bool(const HistoryLogData::Ptr &)> ProcessData
Callback type to consume a single history line split into fields.
void remember(const Exception &old_r)
Store an other Exception as history.
bool toMin()
Set counter value to current min value.
Store and operate on date (time_t).
Convenient building of std::string via std::ostream::operator<<.
std::string trim(const std::string &s, const Trim trim_r)
ignore invalid items and continue parsing
Maintain [min,max] and counter (value) for progress counting.
HistoryLogReader(const Pathname &historyFile_r, const Options &options_r, const ProcessData &callback_r)
Ctor taking file to parse and data consumer callback.
void readAll(const ProgressData::ReceiverFnc &progress_r)
static Ptr create(FieldVector &fields_r)
Factory method creating HistoryLogData classes.
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
void readFrom(const Date &date, const ProgressData::ReceiverFnc &progress=ProgressData::ReceiverFnc())
Read log from specified date.
Base class for Exception.
bool tick()
Leave counter value unchanged (still alive).
#define HISTORY_LOG_DATE_FORMAT
void readFromTo(const Date &fromDate, const Date &toDate, const ProgressData::ReceiverFnc &progress=ProgressData::ReceiverFnc())
Read log between fromDate and toDate.
shared_ptr< HistoryLogData > Ptr
bool parseLine(const std::string &line_r, unsigned int lineNr_r)
void readFromTo(const Date &fromDate_r, const Date &toDate_r, const ProgressData::ReceiverFnc &progress_r)