ROOT logo
#ifndef HDBFILEIO
#define HDBFILEIO
using namespace std;
#include <fstream> 
#include <iostream> 
#include "TObject.h"
#include "TString.h"
#include "hdbconn.h"
 
class HDbFileUtil;
class HDbTable;
 
class HDbFileIo : public TObject {
private:
  HDbConn* dbConn;      // Pointer to the Oracle connection class
  HDbFileUtil* dbUtil;  // Pointer to the Oracle utility class
  ifstream* fin;        // Pointer to an input filestream
  ofstream* fout;       // Pointer to an output filestream
  TString defTableName; // Default table name (generated from filename)
  TList* tempTables;    // List of temporary tables created in the current session
  HDbTable* refTable;   // Pointer to an existing table
  HDbTable* curTable;   // Pointer to a table form for I/O
  TString colDelim;     // Delimiter between columns in the file
  TString textDelim;    // Enclosing delimiter for text in a single column
  TString nullValue;    // Identifier for a null value in a column
  Int_t maxBufLen;      // Maximum length of the I/O buffer (4000 bytes)
  Int_t maxStmLen;      // Maximum length of the insert statement (about 8000 bytes)
  Bool_t autoCommit;    // Flag (if kTRUE, a transaction is committed automatically)
  Bool_t autoNull;      // Flag (if kTRUE, null values are added automatically)
  TString actDateMask;  // Actual date format
  Bool_t needsCommit;   // Flag (is kTRUE, when inserts/updates where not yet committed)
public:
  HDbFileIo();
  ~HDbFileIo();
  Bool_t connectDb(TString, TString dbName="db-hades");
  Bool_t dbIsOpen() {return dbConn->isOpen(); }
  void closeDbConn();  
  HDbTable* setTableName(const Char_t*);
  void setColumnDelimiter(const Char_t* s=" ");
  void setTextDelimiter(const Char_t s) { textDelim[0]=s; }
  void setNullValue(const Char_t* s="null") { nullValue=s; }
  void setAutoCommit(Bool_t b) { autoCommit=b; }
  void setAutoNull(Bool_t b=kTRUE) { autoNull=b; }
  Bool_t setDateMask(const Char_t* mask="DD-MON-YYYY HH24:MI:SS");
  Bool_t setSearchDate(const Char_t* time="sysdate");
  Bool_t setRun(const Char_t* daqFile);
  HDbTable* getCurTable() { return curTable; }
  const Char_t* getColumnDelimiter() { return colDelim.Data(); }
  const Char_t getTextDelimiter() { return textDelim[0]; }
  const Char_t* getNullValue() const { return nullValue.Data(); }
  Bool_t getAutoCommit() { return autoCommit; }
  Bool_t getAutoNull() { return autoNull; }
  const Char_t* getDateMask() { return actDateMask.Data(); }
  Bool_t openFile(const Char_t*, const Char_t*);
  void closeFile();
  Bool_t fileIsOpen();
  Bool_t fileIsWritable();
  Bool_t readFile(Int_t nLineStart=1,Int_t nLineEnd=999999);
  Bool_t makeInsert(const Char_t*, const Char_t*);
  Bool_t makeUpdate(const Char_t*, const Char_t*);
  Bool_t writeFile();
  Bool_t printResult();
  void showTemporaryTables();
  HDbTable* getTempTable(const Char_t*);
  void dropTemporaryTable(const Char_t*);
  void dropTemporaryTables();
  void commit(void);
  void rollback(void);
  void clear();
  void showExistingTable();
  void showSettings();
private:
  Bool_t openInput(const Char_t*);
  Bool_t openOutput(const Char_t*, const Char_t*);
  Int_t checkTable(TString&);
  Int_t getValues(TString&, Int_t);
  void addTempTable(HDbTable* table);
  void removeTempTable(HDbTable* table);
  Bool_t write(ostream&);
  TString getActDate();
  void checkCommit();
  void confirmCommit();
  ClassDef(HDbFileIo,0) // Oracle I/O class for client-side files
};

#endif /* !HDBFILEIO_H */
 hdbfileio.h:1
 hdbfileio.h:2
 hdbfileio.h:3
 hdbfileio.h:4
 hdbfileio.h:5
 hdbfileio.h:6
 hdbfileio.h:7
 hdbfileio.h:8
 hdbfileio.h:9
 hdbfileio.h:10
 hdbfileio.h:11
 hdbfileio.h:12
 hdbfileio.h:13
 hdbfileio.h:14
 hdbfileio.h:15
 hdbfileio.h:16
 hdbfileio.h:17
 hdbfileio.h:18
 hdbfileio.h:19
 hdbfileio.h:20
 hdbfileio.h:21
 hdbfileio.h:22
 hdbfileio.h:23
 hdbfileio.h:24
 hdbfileio.h:25
 hdbfileio.h:26
 hdbfileio.h:27
 hdbfileio.h:28
 hdbfileio.h:29
 hdbfileio.h:30
 hdbfileio.h:31
 hdbfileio.h:32
 hdbfileio.h:33
 hdbfileio.h:34
 hdbfileio.h:35
 hdbfileio.h:36
 hdbfileio.h:37
 hdbfileio.h:38
 hdbfileio.h:39
 hdbfileio.h:40
 hdbfileio.h:41
 hdbfileio.h:42
 hdbfileio.h:43
 hdbfileio.h:44
 hdbfileio.h:45
 hdbfileio.h:46
 hdbfileio.h:47
 hdbfileio.h:48
 hdbfileio.h:49
 hdbfileio.h:50
 hdbfileio.h:51
 hdbfileio.h:52
 hdbfileio.h:53
 hdbfileio.h:54
 hdbfileio.h:55
 hdbfileio.h:56
 hdbfileio.h:57
 hdbfileio.h:58
 hdbfileio.h:59
 hdbfileio.h:60
 hdbfileio.h:61
 hdbfileio.h:62
 hdbfileio.h:63
 hdbfileio.h:64
 hdbfileio.h:65
 hdbfileio.h:66
 hdbfileio.h:67
 hdbfileio.h:68
 hdbfileio.h:69
 hdbfileio.h:70
 hdbfileio.h:71
 hdbfileio.h:72
 hdbfileio.h:73
 hdbfileio.h:74
 hdbfileio.h:75
 hdbfileio.h:76
 hdbfileio.h:77
 hdbfileio.h:78
 hdbfileio.h:79
 hdbfileio.h:80
 hdbfileio.h:81
 hdbfileio.h:82
 hdbfileio.h:83
 hdbfileio.h:84
 hdbfileio.h:85
 hdbfileio.h:86