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

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