IODA Bundle
CompactTool.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 1996-2012 ECMWF.
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  * In applying this licence, ECMWF does not waive the privileges and immunities
7  * granted to it by virtue of its status as an intergovernmental organisation nor
8  * does it submit to any jurisdiction.
9  */
10 
11 #include "eckit/filesystem/PathName.h"
12 #include "eckit/log/Log.h"
13 #include "odc/Comparator.h"
14 #include "odc/Reader.h"
15 #include "odc/Writer.h"
16 #include "odc/tools/CompactTool.h"
17 
18 using namespace std;
19 using namespace eckit;
20 
21 namespace odc {
22 namespace tool {
23 
24 CompactTool::CompactTool (int argc, char *argv[]) : Tool(argc, argv) { }
25 
27 {
28  if (parameters().size() != 3)
29  {
30  Log::error() << "Usage: ";
32  Log::error() << std::endl;
33  return;
34  }
35 
36  PathName inFile = parameters(1);
37  PathName outFile = parameters(2);
38 
39  odc::Reader in(inFile);
40  odc::Writer<> out(outFile);
41 
43  odc::Reader::iterator end(in.end());
44 
46  writer->pass1(it, end);
47 
48  odc::Reader outReader(outFile);
49  Log::info() << "Verifying." << std::endl;
50  odc::Reader::iterator it1 = in.begin();
51  odc::Reader::iterator end1 = in.end();
52 
53  odc::Reader::iterator it2 = outReader.begin();
54  odc::Reader::iterator end2 = outReader.end();
55 
56  odc::Comparator comparator;
57  comparator.compare(it1, end1, it2, end2, inFile, outFile);
58 }
59 
60 } // namespace tool
61 } // namespace odc
62 
bool compare(T1 &it1, const T1 &end1, T2 &it2, const T2 &end2, const std::string &desc1, const std::string &desc2)
Definition: Comparator.h:108
const iterator end() const
Definition: Reader.cc:81
iterator begin()
Definition: Reader.cc:74
iterator begin(bool openDataHandle=true)
Definition: Writer.cc:92
const std::vector< std::string > parameters()
static void usage(const std::string &name, std::ostream &o)
Definition: CompactTool.h:27
Definition: ColumnInfo.h:23
Definition: encode.cc:30