backup
[platform/upstream/libzypp.git] / devel / devel.jkupec / play.cc
1 #include <iostream>
2
3 #include "zypp/base/LogTools.h"
4 #include "zypp/ZYppCallbacks.h"
5
6 #include "zypp/parser/HistoryLogReader.h"
7 #include "zypp/parser/ParseException.h"
8
9 using std::endl;
10 using std::cout;
11 using namespace zypp;
12
13 bool progress_function(const ProgressData & p)
14 {
15   cout << ".";
16   return true;
17 }
18
19 struct HistoryItemCollector
20 {
21   std::vector<HistoryItem::Ptr> items;
22
23   bool operator()( const HistoryItem::Ptr & item_ptr )
24   {
25     items.push_back(item_ptr);
26     //cout << *item_ptr << endl;
27     return true;
28   }
29 };
30
31 // ---------------------------------------------------------------------------
32
33 int main( int argc, const char * argv[] )
34 {
35   --argc; ++argv; // skip arg 0
36
37   HistoryItemCollector ic;
38   parser::HistoryLogReader reader(*argv, boost::ref(ic));
39   reader.setIgnoreInvalidItems(true);
40   ProgressReportReceiver progress;
41   progress.connect();
42   try
43   {
44     //reader.readAll(&progress_function);
45     reader.readFromTo(Date("2009-01-01", "%Y-%m-%d"), Date("2009-01-02", "%Y-%m-%d"));
46   }
47   catch (const parser::ParseException & e)
48   {
49     cout << "error in " << *argv << ":" << endl;
50     cout << e.asUserHistory() << endl;
51   }
52   progress.disconnect();
53
54   cout << "got " << ic.items.size() << endl;
55   return 0;
56 }