Safir SDK Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Environment.h
Go to the documentation of this file.
1 /******************************************************************************
2 *
3 * Copyright Saab AB, 2005-2013 (http://safir.sourceforge.net)
4 *
5 * Created by: Jörgen Johansson / stjrjo
6 *
7 *******************************************************************************
8 *
9 * This file is part of Safir SDK Core.
10 *
11 * Safir SDK Core is free software: you can redistribute it and/or modify
12 * it under the terms of version 3 of the GNU General Public License as
13 * published by the Free Software Foundation.
14 *
15 * Safir SDK Core is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with Safir SDK Core. If not, see <http://www.gnu.org/licenses/>.
22 *
23 ******************************************************************************/
24 #ifndef Safir_Databases_Environment_h
25 #define Safir_Databases_Environment_h
26 
28 #include "Safir/Databases/Odbc/Internal/InternalDefs.h"
30 #include <boost/noncopyable.hpp>
31 
32 namespace Safir
33 {
34 namespace Databases
35 {
36 namespace Odbc
37 {
38 
39 #ifdef _MSC_VER
40 #pragma warning(push)
41 #pragma warning(disable: 4275)
42 #endif
43 
49 class OLIB_API Environment : private boost::noncopyable
50 {
51 public:
54  Environment(void);
55 
58  ~Environment(void);
59 
66  void Alloc();
67 
72  void Free();
73 
83  void SetEnvAttr(long lAttribute, long lValue);
84 
95  void SetEnvAttr(long lAttribute, const std::wstring & wszValue, unsigned long ulLength);
96 
106  void GetEnvAttr(long lAttribute, long & lValue) const;
107 
118  void GetEnvAttr(long lAttribute, wchar_t * wszValue, unsigned long ulLength) const;
119 
130  bool GetDiagRec(short sRecNumber,
131  std::wstring & SqlState,
132  boost::int32_t & NativeError,
133  std::wstring & MessageText,
134  bool & bDataRead) const;
135 
140  bool IsValid() const;
141 
146  SQLHENV Handle() const;
147 private:
148  SQLHENV m_hEnv;
149  bool bSetOdbcVersion;
150 
151  void ThrowReconnectException( const std::wstring & fileName,
152  const Safir::Dob::Typesystem::Int64 lineNumber) const;
153  void ThrowReconnectException( SQLHENV hEnv,
154  const std::wstring & fileName,
155  const Safir::Dob::Typesystem::Int64 lineNumber) const;
156 };
157 
158 #ifdef _MSC_VER
159 #pragma warning(pop)
160 #endif
161 
162 inline
164 {
165  return m_hEnv != SQL_NULL_HENV;
166 }
167 
168 inline
169 SQLHENV Environment::Handle() const
170 {
171  return m_hEnv;
172 }
173 
174 } // End namespace Odbc
175 
176 } // End namespace Databases
177 
178 } // End namespace Safir
179 
180 #endif // Safir_Databases_Environment_h
bool IsValid() const
Checks if this environment is a valid allocated environment.
Definition: Environment.h:163
DotsC_Int64 Int64
64 bit integer type.
Definition: Defs.h:70
SQLHENV Handle() const
Returns the ODBC Handle of the environment.
Definition: Environment.h:169
The Environment class models the necessary setup each application neeeds in order to access the datab...
Definition: Environment.h:49