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 );
54 #if defined(WITH_DEPRECATED_HISTORYITEM_API)
55 ProcessItem _oldAPICallback;
57 HistoryItem::Ptr _oldAPIcreateHistoryItem( HistoryItem::FieldVector & fields );
58 void _oldAPIparseLine(
const std::string & line,
unsigned int lineNr);
59 #endif // WITH_DEPRECATED_HISTORYITEM_API
64 #if defined(WITH_DEPRECATED_HISTORYITEM_API)
65 if ( _oldAPICallback )
67 _oldAPIparseLine( line_r, lineNr_r );
70 #endif // WITH_DEPRECATED_HISTORYITEM_API
75 if ( fields.size() >= 2 )
89 WAR <<
"Ignore invalid history log entry on line #" << lineNr_r <<
" '"<< line_r <<
"'" << endl;
94 ERR <<
"Invalid history log entry on line #" << lineNr_r <<
" '"<< line_r <<
"'" << endl;
104 WAR <<
"Stop parsing requested by consumer callback on line #" << lineNr_r << endl;
119 for ( ; line; line.
next(), pd.
tick() )
122 if ( (*line)[0] ==
'#' )
125 if ( ! parseLine( *line, line.
lineNo() ) )
141 bool pastDate =
false;
142 for ( ; line; line.
next(), pd.
tick() )
144 const std::string & s = *line;
152 if ( ! parseLine( s, line.
lineNo() ) )
158 if ( logDate > date_r )
161 if ( ! parseLine( s, line.
lineNo() ) )
179 bool pastFromDate =
false;
180 for ( ; line; line.
next(), pd.
tick() )
182 const std::string & s = *line;
191 if ( logDate >= toDate_r )
195 if ( !pastFromDate && logDate > fromDate_r )
200 if ( ! parseLine( s, line.
lineNo() ) )
209 #if defined(WITH_DEPRECATED_HISTORYITEM_API)
210 HistoryItem::Ptr HistoryLogReader::Impl::_oldAPIcreateHistoryItem( HistoryItem::FieldVector & fields )
213 switch ( aid.toEnum() )
216 return HistoryItemInstall::Ptr(
new HistoryItemInstall( fields ) );
220 return HistoryItemRemove::Ptr(
new HistoryItemRemove( fields ) );
224 return HistoryItemRepoAdd::Ptr(
new HistoryItemRepoAdd( fields ) );
228 return HistoryItemRepoRemove::Ptr(
new HistoryItemRepoRemove( fields ) );
232 return HistoryItemRepoAliasChange::Ptr(
new HistoryItemRepoAliasChange( fields ) );
236 return HistoryItemRepoUrlChange::Ptr(
new HistoryItemRepoUrlChange( fields ) );
242 return HistoryItem::Ptr();
244 void HistoryLogReader::Impl::_oldAPIparseLine(
const std::string & line,
unsigned int lineNr )
247 HistoryItem::FieldVector fields;
250 if ( fields.size() <= 2 )
254 ParseException e(
str::form(
"Error in history log on line #%u.", lineNr ) );
255 e.addHistory(
str::form(
"Bad number of fields. Got %zd, expected more than %d.", fields.size(), 2 ) );
260 WAR <<
"Ignoring suspicious non-comment entry on line #" << lineNr << endl;
265 HistoryItem::Ptr item_ptr;
268 item_ptr = _oldAPIcreateHistoryItem( fields );
270 catch (
const Exception & e )
273 ERR <<
"Invalid history log entry on line #" << lineNr <<
" '"<< line <<
"'" << endl;
277 ParseException newe(
str::form(
"Error in history log on line #%u.", lineNr ) );
285 _oldAPICallback( item_ptr );
289 ParseException e(
str::form(
"Error in history log on line #%u.", lineNr ) );
290 e.addHistory(
"Unknown entry type." );
295 WAR <<
"Unknown history log action type: " << fields[1] <<
" on line #" << lineNr << endl;
298 #endif // WITH_DEPRECATED_HISTORYITEM_API
306 #if defined(WITH_DEPRECATED_HISTORYITEM_API)
308 const ProcessItem & callback )
310 {
_pimpl->_oldAPICallback = callback; }
311 #endif // WITH_DEPRECATED_HISTORYITEM_API