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

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