OpendTect  6.3
tableconv.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 "sets.h"
15 #include "executor.h"
16 #include "bufstringset.h"
17 #include "od_iosfwd.h"
18 
19 namespace Table
20 {
21 
23 {
24 public:
26  : strm_(strm)
27  , colpos_(0) {}
28  virtual ~ImportHandler() {}
29 
30  enum State { Error, InCol, EndCol, EndRow };
31 
32  virtual State add(char) = 0;
33  const char* getCol() const { return col_.buf(); }
34  const char* errMsg() const { return col_.buf(); }
35 
36  virtual void newRow() {}
37  virtual void newCol() { col_.setEmpty(); colpos_ = 0;}
38 
39  char readNewChar() const;
40  bool atEnd() const;
41 
42 protected:
43 
46  int colpos_;
47 
48  void addToCol(char);
49 
50 };
51 
52 
54 {
55 public:
57  : strm_(strm) {}
58  virtual ~ExportHandler() {}
59 
60  virtual bool putRow(const BufferStringSet&,uiString&) = 0;
61 
62  virtual bool init();
63  virtual void finish();
64 
65  static bool isNumber(const char*);
66 
71 
72 protected:
73 
75 
76  uiString getStrmMsg() const;
77 
78 };
79 
80 
81 
82 mExpClass(General) Converter : public Executor
84 public:
86  : Executor("Data import")
87  , imphndlr_(i), exphndlr_(o)
88  , rowsdone_(0), selcolnr_(-1), atend_(false)
89  , msg_(tr("Importing")) {}
90  // Setup
93 
94  virtual int nextStep();
95  uiString message() const { return msg_; }
96  uiString nrDoneText() const { return tr("Records read"); }
97  od_int64 nrDone() const { return rowsdone_; }
98 
100  {
101  virtual bool accept(BufferStringSet&) const = 0;
103  };
105  { manipulators_.erase(); addManipulator(m); }
107  { manipulators_ += m; }
108 
109 protected:
110 
115 
116  int colnr_;
119  bool atend_;
120 
121  bool handleImpState(ImportHandler::State);
122  inline bool colSel() const
123  { return selcols_.isEmpty()
124  || selcols_.isPresent(colnr_); }
125 };
126 
127 }; // namespace Table
#define mExpClass(module)
Definition: commondefs.h:157
const char * errMsg() const
Definition: tableconv.h:34
od_istream & strm_
Definition: tableconv.h:44
const char * getCol() const
Definition: tableconv.h:33
ExportHandler & exphndlr_
Definition: tableconv.h:112
BufferString prepend_
Before first record. Add newline if needed.
Definition: tableconv.h:67
Converter(ImportHandler &i, ExportHandler &o)
Definition: tableconv.h:85
OD class for stream write common access to the user log file, or std::cout in batch progs...
Definition: od_ostream.h:25
BufferString append_
After last record.
Definition: tableconv.h:69
int colpos_
Definition: tableconv.h:46
ImportHandler(od_istream &strm)
Definition: tableconv.h:25
#define mODTextTranslationClass(clss)
Definition: uistring.h:37
#define od_int64
Definition: plftypes.h:34
virtual void newRow()
Definition: tableconv.h:36
bool init()
void setManipulator(const RowManipulator *m)
Definition: tableconv.h:104
Definition: uistring.h:88
bool isEmpty() const
Definition: odset.h:43
Set of BufferString objects.
Definition: bufstringset.h:25
bool atend_
Definition: tableconv.h:119
int rowsdone_
Definition: tableconv.h:118
OD class for stream read.
Definition: od_istream.h:23
Definition: tableconv.h:82
Set of pointers to objects.
Definition: commontypes.h:28
uiString nrDoneText() const
Definition: tableconv.h:96
ExportHandler(od_ostream &strm)
Definition: tableconv.h:56
Definition: geom2dascio.h:18
od_ostream & strm_
Definition: tableconv.h:74
Definition: tableconv.h:99
virtual ~ImportHandler()
Definition: tableconv.h:28
int colnr_
Definition: tableconv.h:116
ImportHandler & imphndlr_
Definition: tableconv.h:111
virtual ~ExportHandler()
Definition: tableconv.h:58
void addManipulator(const RowManipulator *m)
Definition: tableconv.h:106
bool isPresent(const T &) const
Definition: typeset.h:336
virtual void newCol()
Definition: tableconv.h:37
TypeSet< int > selcols_
Definition: tableconv.h:91
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:38
uiString message() const
Definition: tableconv.h:95
BufferString col_
Definition: tableconv.h:45
ObjectSet< const RowManipulator > manipulators_
Definition: tableconv.h:114
BufferStringSet row_
Definition: tableconv.h:113
od_int64 nrDone() const
Definition: tableconv.h:97
Definition: tableconv.h:53
Definition: tableconv.h:22
int selcolnr_
Definition: tableconv.h:117
bool colSel() const
Definition: tableconv.h:122
State
Definition: tableconv.h:30
Specification to enable chunkwise execution of a process.
Definition: executor.h:38
uiString msg_
Definition: tableconv.h:92

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