IODA Bundle
SQLTool.h
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 /// @author Piotr Kuchta
12 /// @author Simon Smart
13 /// @date Aug 2018
14 
15 #ifndef odc_SQLTool_H
16 #define odc_SQLTool_H
17 
18 #include <memory>
19 
20 #include "odc/tools/Tool.h"
21 #include "eckit/sql/SQLOutputConfig.h"
22 
23 namespace eckit {
24  class Offset;
25  class Length;
26  namespace sql {
27  class SQLSession;
28  class SQLParser;
29  class SQLOutputConfig;
30  }
31 }
32 
33 namespace odc {
34 
35 namespace sql { class SQLOutputConfig; }
36 
37 namespace tool {
38 
39 //----------------------------------------------------------------------------------------------------------------------
40 
41 class SQLTool : public Tool {
42 
43 public:
44  SQLTool(int argc, char **argv);
45  virtual ~SQLTool();
46 
47  virtual void run();
48 
49  static void help(std::ostream &o) { o << "Executes SQL statement"; }
50  static void usage(const std::string& name, std::ostream &o)
51  {
52  o << name << " <select-statement> | <script-filename>" << std::endl;
53  o << " [-T] Disables printing of column names" << std::endl;
54  o << " [-offset <offset>] Start processing file at a given offset" << std::endl;
55  o << " [-length <length>] Process only given bytes of data" << std::endl;
56  o << " [-N] Do not write NULLs, but proper missing data values" << std::endl;
57  o << " [-i <inputfile>] ODB input file" << std::endl;
58  o << " [-o <outputfile>] ODB output file" << std::endl;
59  o << " [-f default|wide|odb] ODB output format (default is ascii; odb is binary ODB, wide is ascii with"
60  << " bitfields definitions in header)" << std::endl;
61  o << " [-delimiter <delim>] Changes the default values' delimiter (TAB by default)" << std::endl;
62  o << " delim can be any character or string" << std::endl;
63  o << " [--binary|--bin] Print bitfields in binary notation" << std::endl;
64 // o << " [--hexadecimal|--hex] Print bitfields in hexadecimal notation" << std::endl;
65  o << " [--no_alignment] Do not align columns" << std::endl;
66  o << " [--full_precision] Print with full precision" << std::endl;
67  }
68 
69 private:
70 
71  std::unique_ptr<odc::sql::SQLOutputConfig> sqlOutputConfig_;
72 
73  std::string inputFile_; // -i
74  eckit::Offset offset_; // -offset
75  eckit::Length length_; // -length
76 };
77 
78 //----------------------------------------------------------------------------------------------------------------------
79 
80 } // namespace tool
81 } // namespace odc
82 
83 #endif
84 
std::unique_ptr< odc::sql::SQLOutputConfig > sqlOutputConfig_
Definition: SQLTool.h:71
SQLTool(int argc, char **argv)
Definition: SQLTool.cc:39
static void usage(const std::string &name, std::ostream &o)
Definition: SQLTool.h:50
eckit::Length length_
Definition: SQLTool.h:75
std::string inputFile_
Definition: SQLTool.h:73
virtual ~SQLTool()
Definition: SQLTool.cc:82
eckit::Offset offset_
Definition: SQLTool.h:74
static void help(std::ostream &o)
Definition: SQLTool.h:49
virtual void run()
Definition: SQLTool.cc:84
std::string name()
Definition: Tool.h:34
Definition: ColumnInfo.h:23