Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cSQLConfig.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cSQLConfig_H
7 #define _INC_cSQLConfig_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "../GrayLibBase.h"
13 #include "../Variant/cVariantType.h"
16 
17 namespace GrayLib
18 {
19  typedef INT16 SQL_TYPE_t;
20  static const SQL_TYPE_t k_SQL_TYPE_NULL = 0;
21 
22 #ifdef _WIN64
23  typedef UINT64 SQL_SCALE_t; // AKA SQLULEN
24 #else
25  typedef unsigned long SQL_SCALE_t; // AKA SQLULEN
26 #endif
27 
29  {
34 
38  INT16 m_nPrecision;
40 
42 
43  void SetClear() noexcept
44  {
45  m_strName = "";
46  m_nSQLType = 0;
47  m_nScale = 0;
48  m_nPrecision = 0;
49  m_bNullability = false;
51  }
52  };
53 
55  {
60 
61  public:
63  {
66  // CMDFLG_ReadOnly = 0x02, //!< TODO like MFC
67  // CMDFLG_CursorLib = 0x04, //!< TODO like MFC
68  CMDFLG_MSSQL = 0,
69  CMDFLG_MySQL = 0x08,
70  CMDFLG_DateWrap = 0x10,
71  };
72 
73  public:
74  UINT m_uCmdFlags;
75 
76  public:
77  cSQLConfigCmd(UINT uCmdFlags = CMDFLG_MSSQL)
78  : m_uCmdFlags(uCmdFlags)
79  {
80  }
81  bool isConvertEscapes() const noexcept
82  {
85  return m_uCmdFlags & CMDFLG_MySQL;
86  }
87  bool isUseLIMITCommand() const noexcept
88  {
90  return m_uCmdFlags & CMDFLG_MySQL;
91  }
92  bool isDateWrap() const noexcept
93  {
94  // Allow {ts'X'} wrapper for the date.
95  return m_uCmdFlags & CMDFLG_DateWrap;
96  }
97 
98  cStringA GetSQLTypeName(const cSQLColumnInfo& f) const;
99  bool ConvertEscapeQuotes(cStringA& a_cs) const;
100  };
101 
103  {
107 
108  public:
114 
115  public:
117  : m_bPopulated(false)
118  , m_bAutoCommit(true)
119  , m_bSupportsTransactions(true)
120  {
121  }
122 
123  void Clear()
124  {
125  m_bPopulated = false;
126  m_bAutoCommit = true;
127  m_sDatabaseName.Empty(); // reset at each open
128  m_sDataSourceName.Empty();
129  }
130 
132  {
136  if (m_sDatabaseName.IsEmpty())
137  {
138  return "Database";
139  }
140  return m_sDatabaseName;
141  }
143  {
147  if (m_sDataSourceName.IsEmpty()) // not using a DSN is OK.
148  {
149  return get_DatabaseName();
150  }
151  return m_sDataSourceName;
152  }
153 
155  {
158  return m_bSupportsTransactions;
159  }
160 
161  bool get_AutoCommit() const
162  {
164  return m_bAutoCommit;
165  }
166  void put_AutoCommit(bool bAutoCommit) // makes all transactions COMMIT immediately
167  {
170  m_bAutoCommit = bAutoCommit;
171  }
172  };
173 }
174 
175 #endif
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
Definition: cSQLConfig.h:55
CMDFLG_TYPE
Definition: cSQLConfig.h:63
UINT m_uCmdFlags
These flags effect how a command might be built. options supported (or not) by drivers.
Definition: cSQLConfig.h:74
bool isConvertEscapes() const noexcept
Definition: cSQLConfig.h:81
bool isUseLIMITCommand() const noexcept
Definition: cSQLConfig.h:87
bool isDateWrap() const noexcept
Definition: cSQLConfig.h:92
cSQLConfigCmd(UINT uCmdFlags=CMDFLG_MSSQL)
Definition: cSQLConfig.h:77
Definition: cSQLConfig.h:103
bool m_bAutoCommit
Definition: cSQLConfig.h:110
bool get_AutoCommit() const
Definition: cSQLConfig.h:161
void put_AutoCommit(bool bAutoCommit)
Definition: cSQLConfig.h:166
bool m_bPopulated
Have we tested the db/connection for capabilities ?
Definition: cSQLConfig.h:109
cStringA m_sDatabaseName
SQL_DATABASE_NAME - Database = reset at each m_bIsConnected.
Definition: cSQLConfig.h:112
cStringA get_DatabaseName() const
Definition: cSQLConfig.h:131
cStringA get_DataSourceName() const
Definition: cSQLConfig.h:142
bool get_SupportsTransactions() const
Definition: cSQLConfig.h:154
void Clear()
Definition: cSQLConfig.h:123
cSQLConfigDB()
Definition: cSQLConfig.h:116
cStringA m_sDataSourceName
SQL_DATA_SOURCE_NAME - DSN = reset at each m_bIsConnected. parsed from m_ConnectionString.
Definition: cSQLConfig.h:113
bool m_bSupportsTransactions
We can do a Rollback?
Definition: cSQLConfig.h:111
void Empty()
Definition: cString.h:193
bool IsEmpty() const noexcept
Definition: cString.h:176
Definition: cMesh.h:22
VARTYPE_TYPE
< define types of structure/record elements. (COM uses VARTYPE=VARENUM for this) stored as BYTE
Definition: cVariantType.h:19
@ VARTYPE_NoType
Definition: cVariantType.h:24
unsigned long SQL_SCALE_t
Definition: cSQLConfig.h:25
INT16 SQL_TYPE_t
Internal/Native/driver type code. enum SWORD = SQL_TYPE_NULL = 0, short int.
Definition: cSQLConfig.h:19
Definition: cSQLConfig.h:29
INT16 m_nPrecision
SQL_COLUMN_PRECISION. // SQLULEN = 64 or 32 bit. AKA DecimalDigits.
Definition: cSQLConfig.h:38
SQL_TYPE_t m_nSQLType
SQL_COLUMN_TYPE = ODBC/Driver/Internal data type (SQL_BINARY) VARTYPE_TYPE. See Cvt_ODBCType_to_CType...
Definition: cSQLConfig.h:36
VARTYPE_TYPE m_eVarType
My internal type equiv to m_nSQLType.
Definition: cSQLConfig.h:41
SQL_SCALE_t m_nScale
SQL_COLUMN_SCALE. // AKA ColumnSize, SWORD or SQLSMALLINT. e.g. nvarchar(nScale) for max size of stri...
Definition: cSQLConfig.h:37
bool m_bNullability
SQL_COLUMN_NULLABLE.
Definition: cSQLConfig.h:39
void SetClear() noexcept
Definition: cSQLConfig.h:43
cStringA m_strName
SQL_COLUMN_NAME.
Definition: cSQLConfig.h:35