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

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