From fff2dcb58ab85b590c7c3d511532fd5a3e5460e4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A1n=20Kupec?= Date: Wed, 28 Jan 2009 14:36:39 +0100 Subject: [PATCH] backup --- devel/devel.jkupec/play.cc | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/devel/devel.jkupec/play.cc b/devel/devel.jkupec/play.cc index 4852540..5133d74 100644 --- a/devel/devel.jkupec/play.cc +++ b/devel/devel.jkupec/play.cc @@ -1,6 +1,7 @@ #include #include "zypp/base/LogTools.h" +#include "zypp/ZYppCallbacks.h" #include "zypp/parser/HistoryLogReader.h" #include "zypp/parser/ParseException.h" @@ -9,14 +10,20 @@ using std::endl; using std::cout; using namespace zypp; +bool progress_function(const ProgressData & p) +{ + cout << "."; + return true; +} + struct HistoryItemCollector { -// vector items; + std::vector items; bool operator()( const HistoryItem::Ptr & item_ptr ) { -// items.insert(item); - cout << *item_ptr << endl; + items.push_back(item_ptr); + //cout << *item_ptr << endl; return true; } }; @@ -28,18 +35,22 @@ int main( int argc, const char * argv[] ) --argc; ++argv; // skip arg 0 HistoryItemCollector ic; - parser::HistoryLogReader reader(*argv, ic); - + parser::HistoryLogReader reader(*argv, boost::ref(ic)); + reader.setIgnoreInvalidItems(true); + ProgressReportReceiver progress; + progress.connect(); try { - reader.readAll(); + //reader.readAll(&progress_function); + reader.readFromTo(Date("2009-01-01", "%Y-%m-%d"), Date("2009-01-02", "%Y-%m-%d")); } catch (const parser::ParseException & e) { cout << "error in " << *argv << ":" << endl; cout << e.asUserHistory() << endl; } + progress.disconnect(); - cout << "done" << endl; + cout << "got " << ic.items.size() << endl; return 0; } -- 2.7.4