IODA Bundle
FixedSizeRowTool.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"
17 
18 using namespace eckit;
19 
20 namespace odc {
21 namespace tool {
22 
23 FixedSizeRowTool::FixedSizeRowTool (int argc, char *argv[]) : Tool(argc, argv) { }
24 
26 {
27  if (parameters().size() != 3)
28  {
29  Log::error() << "Usage: ";
31  Log::error() << std::endl;
32  return;
33  }
34 
35  PathName inFile = parameters(1);
36  PathName outFile = parameters(2);
37 
38  odc::Reader in(inFile);
39  odc::Writer<> out(outFile);
40 
41  odc::Reader::iterator it = in.begin();
42  odc::Reader::iterator end = in.end();
43  odc::Writer<>::iterator outIt(out.begin());
44  outIt->pass1(it, end);
45 
46  odc::Reader outReader(outFile);
47  Log::info() << "Verifying." << std::endl;
48  odc::Reader::iterator it1 = in.begin();
49  odc::Reader::iterator end1 = in.end();
50  odc::Reader::iterator it2 = outReader.begin();
51  odc::Reader::iterator end2 = outReader.end();
52  odc::Comparator comparator;
53  comparator.compare(it1, end1, it2, end2, inFile, outFile);
54 }
55 
56 } // namespace tool
57 } // namespace odc
58 
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
unsigned long pass1(T b, const T e)
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: ColumnInfo.h:23