OpendTect  6.6
tableconvimpl.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*+
4 ________________________________________________________________________
5 
6  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
7  Author: A.H.Bril
8  Date: Jul 2006
9  RCS: $Id$
10 ________________________________________________________________________
11 
12 -*/
13 
14 #include "generalmod.h"
15 #include "tableconv.h"
16 #include "bufstringset.h"
17 #include "globexpr.h"
18 #include "od_iosfwd.h"
19 #include "uistring.h"
20 
21 
22 namespace Table
23 {
24 
26 {
27 public:
28 
29 
31  : ImportHandler(s)
32  , insingqstring_(false)
33  , indoubqstring_(false) {}
34 
35  State add(char);
36  const char* getCol() const { return col_.buf(); }
37  const char* errMsg() const { return col_.buf(); }
38 
39  virtual void newRow() {}
40 
41 protected:
42 
45 
46 };
47 
48 
50 {
51 public:
53  : ImportHandler(s)
54  , nlreplace_('\n')
55  , instring_(false) {}
56 
57  State add(char);
58  const char* getCol() const { return col_.buf(); }
59  const char* errMsg() const { return col_.buf(); }
60 
61  virtual void newRow() { instring_ = false; }
62 
63  char nlreplace_;
65 
66 protected:
67 
68  bool instring_;
69 
70 };
71 
72 
74 {
75 public:
76 
77  enum ColWSHandl { None, Underscores, SingQuot, DoubQuot };
78 
80  ColWSHandl w=Underscores )
81  : ExportHandler(s)
82  , colwshanld_(w) {}
83 
85 
87 
88 protected:
89 
90  void addVal(int col,const char*);
91 
92 };
93 
94 
96 {
97 public:
99  : ExportHandler(s) {}
100 
102 
103 protected:
104 
105  void addVal(int col,const char*);
106 
107 };
108 
109 
112 public:
113 
115  : ExportHandler(s)
116  , startindex_(1)
117  , stepindex_(1)
118  , nrrows_(0) {}
119 
121 
124 
128 
131 
132 protected:
133 
134  void addVal(int col,const char*);
135 
136  int nrrows_;
137  bool addindex_;
139 
140 };
141 
142 
151 {
152 public:
154  : startdone_(false)
155  , count_(0) {}
156 
157  struct Criterion
158  {
159  enum Type { None, Records, Match };
160 
162  : type_(t)
163  , count_(1)
164  , matchcolidx_(0) {}
165 
167  int count_;
170 
171  };
172 
175 
176  bool accept(BufferStringSet&) const;
177 
178 protected:
179 
180  mutable bool startdone_;
181  mutable int count_;
182 
183  void updCount(const Criterion&,const BufferStringSet&) const;
184  bool isGEMatch(const Criterion&,const BufferStringSet&) const;
185 
186 };
187 
188 
193 {
194 public:
195  RecordMatcher( bool a=true )
196  : any_(a) {}
197 
198  bool accept(BufferStringSet&) const;
199 
200  bool any_;
201  bool not_;
204 
206 protected:
207 
208  static const GlobExpr emptyge_;
209 
210 };
211 
212 
222 {
223 public:
225  : nrdone_(0), nrremoved_(0) {}
226 
227  bool accept(BufferStringSet&) const;
228 
230 
231  int nrRemoved() const { return nrremoved_; }
232 
233 protected:
234 
236  mutable int nrdone_;
237  mutable int nrremoved_;
238 
239  void setPrevKeys(const BufferStringSet&) const;
240 
241 };
242 
243 
245 {
246 public:
249 
250  const char* xy() const;
251  const char* z(od_uint16 extradecimals=0) const;
252  const char* trcnr() const;
253  const char* spnr() const;
254  const char* string(od_uint16 length=10) const;
255 
256 protected:
257  void readSettings();
258 };
259 
260 } // namespace Table
Table::CSVImportHandler::add
State add(char)
Table::CSVImportHandler::errMsg
const char * errMsg() const
Definition: tableconvimpl.h:59
Table::CSVExportHandler::putRow
bool putRow(const BufferStringSet &, uiString &)
Table::SQLInsertExportHandler::addindex_
bool addindex_
Definition: tableconvimpl.h:137
Table::CSVExportHandler
Definition: tableconvimpl.h:96
Table::StartStopManipulator::Criterion::Type
Type
Definition: tableconvimpl.h:159
Table::Converter::RowManipulator
Definition: tableconv.h:101
Table::SQLInsertExportHandler::nrextracols_
int nrextracols_
Definition: tableconvimpl.h:138
Table::StartStopManipulator::StartStopManipulator
StartStopManipulator()
Definition: tableconvimpl.h:153
uistring.h
Table::WSImportHandler::add
State add(char)
Table::SQLInsertExportHandler::mODTextTranslationClass
mODTextTranslationClass(SQLInsertExportHandler)
BufferStringSet
Set of BufferString objects.
Definition: bufstringset.h:26
Table::CSVExportHandler::CSVExportHandler
CSVExportHandler(od_ostream &s)
Definition: tableconvimpl.h:98
Table::StartStopManipulator::Criterion::type_
Type type_
Definition: tableconvimpl.h:166
Table::CSVImportHandler::nlreplace_
char nlreplace_
replace newlines with this char (optional)
Definition: tableconvimpl.h:63
Table::WSImportHandler::WSImportHandler
WSImportHandler(od_istream &s)
Definition: tableconvimpl.h:30
Table::SQLInsertExportHandler::colnms_
BufferStringSet colnms_
names of the columns: optional
Definition: tableconvimpl.h:123
GlobExpr
Glob-expression matching like UNIX shells.
Definition: globexpr.h:26
mExpClass
#define mExpClass(module)
Definition: commondefs.h:177
Table::ImportHandler::State
State
Definition: tableconv.h:31
Table::SQLInsertExportHandler::putRow
bool putRow(const BufferStringSet &, uiString &)
Table::StartStopManipulator::updCount
void updCount(const Criterion &, const BufferStringSet &) const
od_istream
OD class for stream read common access to the std::cin.
Definition: od_istream.h:24
Table::RecordMatcher::not_
bool not_
If true, matches will not pass.
Definition: tableconvimpl.h:201
Table::StartStopManipulator::Criterion::matchexpr_
GlobExpr matchexpr_
Definition: tableconvimpl.h:168
Table::CSVExportHandler::addVal
void addVal(int col, const char *)
Table
Definition: geom2dascio.h:20
Table::SQLInsertExportHandler::tblname_
BufferString tblname_
name of the table: mandatory
Definition: tableconvimpl.h:122
Table::RecordMatcher
Only passes records where col(s) (don't) match expression(s)
Definition: tableconvimpl.h:193
Table::WSExportHandler::addVal
void addVal(int col, const char *)
Table::StartStopManipulator
Removes lines at start or stop of input.
Definition: tableconvimpl.h:151
Table::DuplicateKeyRemover::nrRemoved
int nrRemoved() const
Definition: tableconvimpl.h:231
Table::StartStopManipulator::Criterion::count_
int count_
nr of lines or nr of matches
Definition: tableconvimpl.h:167
Table::StartStopManipulator::Criterion
Definition: tableconvimpl.h:158
Table::StartStopManipulator::start_
Criterion start_
Definition: tableconvimpl.h:173
Table::SQLInsertExportHandler::indexcolnm_
BufferString indexcolnm_
if not empty, will add column
Definition: tableconvimpl.h:125
Table::FormatProvider::trcnr
const char * trcnr() const
Table::WSImportHandler::errMsg
const char * errMsg() const
Definition: tableconvimpl.h:37
Table::FormatProvider::spnr
const char * spnr() const
Table::SQLInsertExportHandler
Definition: tableconvimpl.h:111
Table::RecordMatcher::accept
bool accept(BufferStringSet &) const
if false returned, the row should not be written
Table::RecordMatcher::any_
bool any_
If false, all need to match.
Definition: tableconvimpl.h:200
Table::FormatProvider::xy
const char * xy() const
Table::CSVImportHandler
Definition: tableconvimpl.h:50
Table::FormatProvider::string
const char * string(od_uint16 length=10) const
Table::WSExportHandler::colwshanld_
ColWSHandl colwshanld_
Definition: tableconvimpl.h:86
Table::DuplicateKeyRemover
Removes records with identical keys.
Definition: tableconvimpl.h:222
Table::RecordMatcher::ckcols_
TypeSet< int > ckcols_
Column numbers (mand)
Definition: tableconvimpl.h:202
Table::StartStopManipulator::stop_
Criterion stop_
Definition: tableconvimpl.h:174
Table::StartStopManipulator::startdone_
bool startdone_
Definition: tableconvimpl.h:180
Table::StartStopManipulator::accept
bool accept(BufferStringSet &) const
if false returned, the row should not be written
Table::RecordMatcher::emptyge_
static const GlobExpr emptyge_
Definition: tableconvimpl.h:208
globexpr.h
Table::WSImportHandler::insingqstring_
bool insingqstring_
Definition: tableconvimpl.h:43
Table::CSVImportHandler::instring_
bool instring_
Definition: tableconvimpl.h:68
Table::ExportHandler
Definition: tableconv.h:55
Table::SQLInsertExportHandler::SQLInsertExportHandler
SQLInsertExportHandler(od_ostream &s)
Definition: tableconvimpl.h:114
Table::WSExportHandler
Definition: tableconvimpl.h:74
od_uint16
#define od_uint16
Definition: plftypes.h:27
Table::FormatProvider::z
const char * z(od_uint16 extradecimals=0) const
Table::ImportHandler
Definition: tableconv.h:24
Table::CSVImportHandler::CSVImportHandler
CSVImportHandler(od_istream &s)
Definition: tableconvimpl.h:52
Table::SQLInsertExportHandler::stepindex_
int stepindex_
if indexcolnm_ set, step index
Definition: tableconvimpl.h:127
Table::FormatProvider::~FormatProvider
~FormatProvider()
BufferString
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size.
Definition: bufstring.h:40
Table::CSVImportHandler::getCol
const char * getCol() const
Definition: tableconvimpl.h:58
Table::RecordMatcher::colvals_
TypeSet< GlobExpr > colvals_
Definition: tableconvimpl.h:203
Network::None
@ None
Definition: networkcommon.h:33
Table::WSImportHandler::newRow
virtual void newRow()
Definition: tableconvimpl.h:39
Table::WSImportHandler
Definition: tableconvimpl.h:26
Table::FormatProvider
Definition: tableconvimpl.h:245
bufstringset.h
Table::DuplicateKeyRemover::prevkeys_
BufferStringSet prevkeys_
Definition: tableconvimpl.h:235
Table::RecordMatcher::RecordMatcher
RecordMatcher(bool a=true)
Definition: tableconvimpl.h:195
Table::FormatProvider::readSettings
void readSettings()
uiString
String that is able to hold international (UTF-8) strings for the user interface.
Definition: uistring.h:121
tableconv.h
Table::WSExportHandler::WSExportHandler
WSExportHandler(od_ostream &s, ColWSHandl w=Underscores)
Definition: tableconvimpl.h:79
od_iosfwd.h
Table::SQLInsertExportHandler::startindex_
int startindex_
if indexcolnm_ set, startindex
Definition: tableconvimpl.h:126
Table::DuplicateKeyRemover::nrdone_
int nrdone_
Definition: tableconvimpl.h:236
Table::SQLInsertExportHandler::addVal
void addVal(int col, const char *)
Table::CSVImportHandler::newRow
virtual void newRow()
Definition: tableconvimpl.h:61
Table::WSExportHandler::putRow
bool putRow(const BufferStringSet &, uiString &)
Table::DuplicateKeyRemover::accept
bool accept(BufferStringSet &) const
if false returned, the row should not be written
Table::SQLInsertExportHandler::extracolvals_
BufferStringSet extracolvals_
Values for columns not in input.
Definition: tableconvimpl.h:129
Table::WSExportHandler::ColWSHandl
ColWSHandl
Definition: tableconvimpl.h:77
Table::DuplicateKeyRemover::DuplicateKeyRemover
DuplicateKeyRemover()
Definition: tableconvimpl.h:224
Table::WSImportHandler::getCol
const char * getCol() const
Definition: tableconvimpl.h:36
Table::StartStopManipulator::count_
int count_
Definition: tableconvimpl.h:181
Table::FormatProvider::FormatProvider
FormatProvider()
Table::StartStopManipulator::isGEMatch
bool isGEMatch(const Criterion &, const BufferStringSet &) const
Table::WSExportHandler::Underscores
@ Underscores
Definition: tableconvimpl.h:77
Table::DuplicateKeyRemover::keycols_
TypeSet< int > keycols_
column numbers (mand)
Definition: tableconvimpl.h:229
Table::DuplicateKeyRemover::setPrevKeys
void setPrevKeys(const BufferStringSet &) const
Table::WSImportHandler::indoubqstring_
bool indoubqstring_
Definition: tableconvimpl.h:44
Table::SQLInsertExportHandler::nrrows_
int nrrows_
Definition: tableconvimpl.h:136
od_ostream
OD class for stream write common access to the user log file, or std::cout in other than od_main.
Definition: od_ostream.h:26
Table::SQLInsertExportHandler::extracolnms_
BufferStringSet extracolnms_
Column names for extracolvals_.
Definition: tableconvimpl.h:130
Table::DuplicateKeyRemover::nrremoved_
int nrremoved_
Definition: tableconvimpl.h:237
Table::StartStopManipulator::Criterion::matchcolidx_
int matchcolidx_
specify -1 for any col
Definition: tableconvimpl.h:169
Table::StartStopManipulator::Criterion::Criterion
Criterion(Type t=None)
Definition: tableconvimpl.h:161
TypeSet< int >

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B.V. 1995-2021