Debian Codegraph @

tests/printCatalog.cc

raw
1 #include <iostream>
2 #include <fstream>
3
4 #include "test_utils.hh"
5
6 #include "geners/ContiguousCatalog.hh"
7 #include "geners/CatalogIO.hh"
8
9 using namespace gs;
10 using namespace std;
11
12 int main(int argc, char const* argv[])
13 {
14 if (argc != 2)
15 {
16 cerr << "Usage: " << parse_progname(argv[0]) << " filename" << endl;
17 return 1;
18 }
19
20 ifstream in(argv[1], ios_base::binary);
21 if (!in.is_open())
22 {
23 cerr << "Error: failed to open file \"" << argv[1] << "\""
24 << std::endl;
25 return 1;
26 }
27
28 unsigned compressionCode = 0, mergeLevel = 0;
29 std::vector<std::string> annotations;
30 CPP11_auto_ptr<ContiguousCatalog> cat(readBinaryCatalog<ContiguousCatalog>(
31 in, &compressionCode, &mergeLevel, &annotations, true));
32 if (!cat.get())
33 {
34 cerr << "Error: failed to read catalog from file \"" << argv[1] << "\""
35 << std::endl;
36 return 1;
37 }
38
39 cout << "Compression code: " << compressionCode << endl;
40 cout << "Merge level: " << mergeLevel << endl;
41 for (unsigned i=0; i<annotations.size(); ++i)
42 cout << "\nAnnotation " << i << ": " << annotations[i] << endl;
43
44 const unsigned long long sz = cat->size();
45 for (unsigned long long id=1; id<=sz; ++id)
46 {
47 CPP11_shared_ptr<const CatalogEntry> e = cat->retrieveEntry(id);
48 cout << '\n';
49 e->humanReadable(cout);
50 }
51
52 return 0;
53 }