OpendTect  6.3
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 ________________________________________________________________________
10 
11 -*/
12 
13 #include "generalmod.h"
14 #include "tableconv.h"
15 #include "bufstringset.h"
16 #include "globexpr.h"
17 #include "od_iosfwd.h"
18 #include "uistring.h"
19 
20 
21 namespace Table
22 {
23 
25 {
26 public:
27 
28 
30  : ImportHandler(s)
31  , insingqstring_(false)
32  , indoubqstring_(false) {}
33 
34  State add(char);
35  const char* getCol() const { return col_.buf(); }
36  const char* errMsg() const { return col_.buf(); }
37 
38  virtual void newRow() {}
39 
40 protected:
41 
44 
45 };
46 
47 
49 {
50 public:
52  : ImportHandler(s)
53  , nlreplace_('\n')
54  , instring_(false) {}
55 
56  State add(char);
57  const char* getCol() const { return col_.buf(); }
58  const char* errMsg() const { return col_.buf(); }
59 
60  virtual void newRow() { instring_ = false; }
61 
62  char nlreplace_;
64 
65 protected:
66 
67  bool instring_;
68 
69 };
70 
71 
73 {
74 public:
75 
76  enum ColWSHandl { None, Underscores, SingQuot, DoubQuot };
77 
79  ColWSHandl w=Underscores )
80  : ExportHandler(s)
81  , colwshanld_(w) {}
82 
83  bool putRow(const BufferStringSet&,uiString&);
84 
86 
87 protected:
88 
89  void addVal(int col,const char*);
90 
91 };
92 
93 
95 {
96 public:
98  : ExportHandler(s) {}
99 
100  bool putRow(const BufferStringSet&,uiString&);
101 
102 protected:
103 
104  void addVal(int col,const char*);
105 
106 };
107 
108 
111 public:
112 
114  : ExportHandler(s)
115  , startindex_(1)
116  , stepindex_(1)
117  , nrrows_(0) {}
118 
119  bool putRow(const BufferStringSet&,uiString&);
120 
123 
127 
130 
131 protected:
132 
133  void addVal(int col,const char*);
134 
135  int nrrows_;
136  bool addindex_;
138 
139 };
140 
141 
149 mExpClass(General) StartStopManipulator : public Converter::RowManipulator
150 {
151 public:
153  : startdone_(false)
154  , count_(0) {}
155 
156  struct Criterion
157  {
158  enum Type { None, Records, Match };
159 
161  : type_(t)
162  , count_(1)
163  , matchcolidx_(0) {}
164 
166  int count_;
169 
170  };
171 
174 
175  bool accept(BufferStringSet&) const;
176 
177 protected:
178 
179  mutable bool startdone_;
180  mutable int count_;
181 
182  void updCount(const Criterion&,const BufferStringSet&) const;
183  bool isGEMatch(const Criterion&,const BufferStringSet&) const;
184 
185 };
186 
187 
191 mExpClass(General) RecordMatcher : public Converter::RowManipulator
192 {
193 public:
194  RecordMatcher( bool a=true )
195  : any_(a) {}
196 
197  bool accept(BufferStringSet&) const;
198 
199  bool any_;
200  bool not_;
203 
205 protected:
206 
207  static const GlobExpr emptyge_;
208 
209 };
210 
211 
220 mExpClass(General) DuplicateKeyRemover : public Converter::RowManipulator
221 {
222 public:
224  : nrdone_(0), nrremoved_(0) {}
225 
226  bool accept(BufferStringSet&) const;
227 
229 
230  int nrRemoved() const { return nrremoved_; }
231 
232 protected:
233 
235  mutable int nrdone_;
236  mutable int nrremoved_;
237 
238  void setPrevKeys(const BufferStringSet&) const;
239 
240 };
241 
242 }; // namespace Table
#define mExpClass(module)
Definition: commondefs.h:157
int startindex_
if indexcolnm_ set, startindex
Definition: tableconvimpl.h:125
Removes records with identical keys.
Definition: tableconvimpl.h:220
int nrrows_
Definition: tableconvimpl.h:135
virtual void newRow()
Definition: tableconvimpl.h:38
OD class for stream write common access to the user log file, or std::cout in batch progs...
Definition: od_ostream.h:25
ColWSHandl
Definition: tableconvimpl.h:76
bool any_
If false, all need to match.
Definition: tableconvimpl.h:199
Definition: tableconvimpl.h:94
BufferString indexcolnm_
if not empty, will add column
Definition: tableconvimpl.h:124
BufferStringSet colnms_
names of the columns: optional
Definition: tableconvimpl.h:122
#define mODTextTranslationClass(clss)
Definition: uistring.h:37
CSVImportHandler(od_istream &s)
Definition: tableconvimpl.h:51
WSImportHandler(od_istream &s)
Definition: tableconvimpl.h:29
const char * getCol() const
Definition: tableconvimpl.h:57
BufferStringSet prevkeys_
Definition: tableconvimpl.h:234
ColWSHandl colwshanld_
Definition: tableconvimpl.h:85
BufferString tblname_
name of the table: mandatory
Definition: tableconvimpl.h:121
int nrdone_
Definition: tableconvimpl.h:235
GlobExpr matchexpr_
Definition: tableconvimpl.h:167
bool instring_
Definition: tableconvimpl.h:67
bool indoubqstring_
Definition: tableconvimpl.h:43
Definition: uistring.h:88
CSVExportHandler(od_ostream &s)
Definition: tableconvimpl.h:97
Set of BufferString objects.
Definition: bufstringset.h:25
static const GlobExpr emptyge_
Definition: tableconvimpl.h:207
BufferStringSet extracolvals_
Values for columns not in input.
Definition: tableconvimpl.h:128
bool startdone_
Definition: tableconvimpl.h:179
TypeSet< GlobExpr > colvals_
Definition: tableconvimpl.h:202
int nrextracols_
Definition: tableconvimpl.h:137
FixedString None()
Definition: keystrs.h:90
OD class for stream read.
Definition: od_istream.h:23
Definition: tableconv.h:82
Definition: tableconvimpl.h:76
const char * errMsg() const
Definition: tableconvimpl.h:58
DuplicateKeyRemover()
Definition: tableconvimpl.h:223
Criterion start_
Definition: tableconvimpl.h:172
Criterion stop_
Definition: tableconvimpl.h:173
Definition: geom2dascio.h:18
TypeSet< int > keycols_
column numbers (mand)
Definition: tableconvimpl.h:228
Removes lines at start or stop of input.
Definition: tableconvimpl.h:149
Criterion(Type t=None)
Definition: tableconvimpl.h:160
Definition: tableconvimpl.h:156
int nrRemoved() const
Definition: tableconvimpl.h:230
int nrremoved_
Definition: tableconvimpl.h:236
bool insingqstring_
Definition: tableconvimpl.h:42
Only passes records where col(s) (don&#39;t) match expression(s)
Definition: tableconvimpl.h:191
int count_
nr of lines or nr of matches
Definition: tableconvimpl.h:166
Glob-expression matching like UNIX shells.
Definition: globexpr.h:24
Type type_
Definition: tableconvimpl.h:165
WSExportHandler(od_ostream &s, ColWSHandl w=Underscores)
Definition: tableconvimpl.h:78
char nlreplace_
replace newlines with this char (optional)
Definition: tableconvimpl.h:62
SQLInsertExportHandler(od_ostream &s)
Definition: tableconvimpl.h:113
virtual void newRow()
Definition: tableconvimpl.h:60
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:38
int count_
Definition: tableconvimpl.h:180
const char * errMsg() const
Definition: tableconvimpl.h:36
Definition: tableconvimpl.h:48
int matchcolidx_
specify -1 for any col
Definition: tableconvimpl.h:168
Definition: tableconv.h:53
TypeSet< int > ckcols_
Column numbers (mand)
Definition: tableconvimpl.h:201
BufferStringSet extracolnms_
Column names for extracolvals_.
Definition: tableconvimpl.h:129
Type
Definition: tableconvimpl.h:158
Definition: tableconvimpl.h:72
Definition: tableconv.h:22
bool not_
If true, matches will not pass.
Definition: tableconvimpl.h:200
Definition: tableconvimpl.h:24
Definition: tableconvimpl.h:109
const char * getCol() const
Definition: tableconvimpl.h:35
int stepindex_
if indexcolnm_ set, step index
Definition: tableconvimpl.h:126
StartStopManipulator()
Definition: tableconvimpl.h:152
bool addindex_
Definition: tableconvimpl.h:136
State
Definition: tableconv.h:30
RecordMatcher(bool a=true)
Definition: tableconvimpl.h:194

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