00001
00002
00003
00004
00005
00006
00014 #ifndef DB_H
00015 #define DB_H
00016
00017
00018 #include <string>
00019 #include <vector>
00020 #include <ostream>
00021
00022 #include "SchemaMap.h"
00023
00024
00034 class Db
00035 {
00036 public:
00037 static const std::string DB_DEFAULT_NAME;
00038
00039 SchemaMap& _schemaMapping;
00040
00041 Db(SchemaMap& schemaMapping, const std::string& dbName = DB_DEFAULT_NAME);
00042 virtual ~Db();
00043
00044 void SetUseOnlyPopulated(bool mode=true);
00045 bool GetUseOnlyPopulated();
00046
00047 void SetAppendFlag(const bool appendFlag);
00048 bool GetAppendFlag();
00049
00050 void SetFieldSeparator(const std::string& fieldSeparator);
00051 void SetRowSeparator(const std::string& rowSeparator);
00052
00053 std::string GetCommandTerm();
00054
00055 std::string GetFieldSeparator();
00056 std::string GetRowSeparator();
00057
00058 virtual void GetStart(std::string& start);
00059
00060 virtual void WriteSchemaStart(std::ostream& io);
00061 void WriteDeleteTable(std::ostream& io, const std::string& table,
00062 const std::string& where, const std::string& what);
00063
00064 virtual void DropTableSql(std::ostream& io, const std::string& tableNameDb);
00065
00066 virtual const std::string& GetExec();
00067 virtual const std::string& GetExecOption();
00068 virtual const std::string& GetUserOption();
00069 virtual const std::string& GetPassOption();
00070
00071 virtual const std::string& GetEnvDbUser();
00072 virtual const std::string& GetEnvDbPass();
00073
00074 virtual const std::string& GetConnect();
00075 virtual const std::string& GetTerminate();
00076 virtual const std::string& GetDbCommand();
00077
00078 virtual void WriteLoad(std::ostream& io);
00079
00080 const std::string& GetDataLoadingFileName();
00081
00082 virtual void WriteLoadingStart(std::ostream& io);
00083 virtual void WriteLoadingEnd(std::ostream& io);
00084 virtual void WriteLoadingTable(std::ostream& io,
00085 const std::string& tableName, const std::string& path);
00086
00087 virtual void WritePrint(std::ostream& io, const std::string& tableNameDb);
00088
00089 virtual void GetChar(std::string& dType, const unsigned int width);
00090 virtual void GetFloat(std::string& dType);
00091 virtual void GetText(std::string& dType, const unsigned int width);
00092 virtual void GetDate(std::string& dType);
00093 virtual void WriteNull(std::ostream& io, const int iNull,
00094 const unsigned int curr, const unsigned int attSize);
00095 virtual void WriteTableIndex(std::ostream& io,
00096 const std::string& tableNameDb,
00097 const vector<std::string>& indexList);
00098
00099 const std::string& GetBcpStringDelimiter();
00100 virtual void WriteBcpDoubleQuotes(std::ostream& io);
00101
00102 virtual void WriteNewLine(std::ostream& io, bool special = false);
00103
00104 bool IsFirstTextNewLineSpecial();
00105
00106 virtual void ConvertDate(std::string& dbDate, const std::string& cifDate);
00107 virtual void ConvertTimestamp(std::string& dbTimestamp,
00108 const std::string& cifTimestamp);
00109
00110 virtual void GetDateAndTime(std::string& dateAndTime);
00111
00112 protected:
00113 bool _useOnlyPopulated;
00114
00115 bool _appendFlag;
00116
00117
00118 std::string _fieldSeparator;
00119 std::string _rowSeparator;
00120
00121 std::string _cmdTerm;
00122
00123
00124 std::string _dbName;
00125
00126 std::string _exec;
00127 std::string _execOption;
00128 std::string _userOption;
00129 std::string _passOption;
00130
00131 std::string _connect;
00132 std::string _terminate;
00133 std::string _dbCommand;
00134 std::string _envDbUser;
00135 std::string _envDbPass;
00136
00137 std::string _dataLoadingFileName;
00138
00139 std::string _bcpStringDelimiter;
00140
00141 bool _firstTextNewLineSpecial;
00142
00143 private:
00144 static const std::string _SCRIPT_LOADING_FILE;
00145
00146 };
00147
00148 #endif