IODA Bundle
CountTool.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/eckit.h"
12
#include "
odc/core/MetaData.h
"
13
#include "
odc/core/TablesReader.h
"
14
#include "
odc/Reader.h
"
15
#include "
odc/tools/CountTool.h
"
16
17
using namespace
eckit
;
18
19
namespace
odc
{
20
namespace
tool {
21
22
CountTool::CountTool (
int
argc,
char
*argv[]) :
Tool
(argc, argv) { }
23
24
size_t
CountTool::rowCount
(
const
PathName &db)
25
{
26
odc::core::TablesReader
reader(db);
27
auto
it = reader.
begin
();
28
auto
end = reader.
end
();
29
30
size_t
n = 0;
31
32
for
(; it != end; ++it) {
33
n += it->
rowCount
();
34
}
35
36
return
n;
37
}
38
39
void
CountTool::run
()
40
{
41
if
(
parameters
().size() < 2)
42
{
43
Log::error
() <<
"Usage: "
;
44
usage
(
parameters
(0),
Log::error
());
45
Log::error
() << std::endl;
46
return
;
47
}
48
49
unsigned
long
long
n (0);
50
for
(
size_t
i
(1);
i
<
parameters
().size(); ++
i
)
51
{
52
const
std::string fileName (
parameters
(
i
));
53
54
Log::debug() <<
"CountTool: counting "
<< fileName << std::endl;
55
56
n +=
rowCount
(fileName);
57
}
58
59
std::cout << n << std::endl;
60
}
61
62
}
// namespace tool
63
}
// namespace odc
64
CountTool.h
MetaData.h
Reader.h
TablesReader.h
odc::core::Table::rowCount
size_t rowCount() const
Definition:
Table.cc:50
odc::core::TablesReader
Definition:
TablesReader.h:77
odc::core::TablesReader::end
iterator end()
Definition:
TablesReader.cc:98
odc::core::TablesReader::begin
iterator begin()
Definition:
TablesReader.cc:94
odc::tool::CommandLineParser::parameters
const std::vector< std::string > parameters()
Definition:
CommandLineParser.cc:82
odc::tool::CountTool::usage
static void usage(const std::string &name, std::ostream &o)
Definition:
CountTool.h:32
odc::tool::CountTool::rowCount
static size_t rowCount(const eckit::PathName &)
Definition:
CountTool.cc:24
odc::tool::CountTool::run
void run()
Definition:
CountTool.cc:39
odc::tool::Tool
Definition:
Tool.h:27
compare.error
int error
Definition:
build/bin/compare.py:168
eckit
Definition:
DistributionUtils.h:15
odc
Definition:
ColumnInfo.h:23
proc_gsi_ncdiag.i
i
Definition:
proc_gsi_ncdiag.py:155
odc
src
odc
tools
CountTool.cc
Generated on Fri Aug 20 2021 11:49:03 for IODA Bundle by
1.9.1