Handle.h
Go to the documentation of this file.
1 #pragma once
2 
3 namespace AppSecInc
4 {
5  namespace Databases
6  {
7  namespace ODBC
8  {
10  typedef struct
11  {
12  std::wstring state;
13  std::wstring message;
15  } ODBCError;
16 
18  typedef struct
19  {
21  std::wstring vendor;
23  std::wstring component;
25  std::wstring datasource;
27  std::wstring text;
29 
31  class ODBCHandle
32  {
33  protected:
35  SQLSMALLINT _type;
37  SQLHANDLE _handle;
39  SQLHANDLE _hconn;
40  private:
41  void operator=(const ODBCHandle&);
42  public:
44  inline SQLHANDLE Peek() const { return _handle; }
46  inline SQLHANDLE PeekConnection() const { return _hconn; }
47  ODBCHandle();
48  virtual ~ODBCHandle();
50  void Allocate(SQLSMALLINT type, SQLHANDLE hconn);
52  void Release();
54  static std::wstring GetError(SQLHANDLE handle, int type);
56  static std::vector<ODBCError> GetErrors(SQLHANDLE handle, int type);
59  static std::vector<std::wstring> GetDiagFields(SQLHANDLE handle, int type, int diagidentifier);
61  static std::vector<ODBCDiagnosticsMessage> GetDiagMessages(SQLHANDLE handle, int type);
63  std::wstring GetError() const { return GetError(_handle, _type); }
65  std::vector<ODBCError> GetErrors() const { return GetErrors(_handle, _type); }
67  std::vector<std::wstring> GetDiagFields(int diagidentifier) const { return GetDiagFields(_handle, _type, diagidentifier); }
69  std::vector<ODBCDiagnosticsMessage> GetDiagMessages() const { return GetDiagMessages(_handle, _type); }
70  };
71  }
72  }
73 }
74 
75 
76 
77 
78 
std::wstring component
Identifies the component in which the error or warning occurred or that received the error or warning...
Definition: Handle.h:23
SQLHANDLE Peek() const
returns the ODBC handle
Definition: Handle.h:44
std::vector< ODBCError > GetErrors() const
get an array of errors on the current ODBC handle
Definition: Handle.h:65
std::vector< std::wstring > GetDiagFields(int diagidentifier) const
get an array of messages on the current ODBC handle
Definition: Handle.h:67
std::wstring GetError() const
get the text representation of the errors on an ODBC handle
Definition: Handle.h:63
An ODBC handle (smart pointer), bound to a connection.
Definition: Handle.h:31
std::wstring text
Generated by the ODBC component.
Definition: Handle.h:27
int native_error
Definition: Handle.h:14
void Allocate(SQLSMALLINT type, SQLHANDLE hconn)
allocates a handle, fails if a handle has been previously allocated
Definition: Handle.cpp:24
static std::vector< std::wstring > GetDiagFields(SQLHANDLE handle, int type, int diagidentifier)
Definition: Handle.cpp:49
SQLSMALLINT _type
type of handle
Definition: Handle.h:35
SQLHANDLE _hconn
ODBC connection handle.
Definition: Handle.h:39
std::vector< ODBCDiagnosticsMessage > GetDiagMessages() const
get an array of text messages on the current ODBC handle (cleaned up SQL_DIAG_MESSAGE_TEXT) ...
Definition: Handle.h:69
void Release()
releases the previously allocated handle, fails if no handle has been allocated
Definition: Handle.cpp:37
An ODBC error.
Definition: Handle.h:10
ODBCHandle()
Definition: Handle.cpp:8
std::wstring state
Definition: Handle.h:12
A diagnostics message, see http://msdn.microsoft.com/en-us/library/ms713606(VS.85).aspx.
Definition: Handle.h:18
virtual ~ODBCHandle()
Definition: Handle.cpp:16
SQLHANDLE PeekConnection() const
returns the connection handle
Definition: Handle.h:46
std::wstring message
Definition: Handle.h:13
SQLHANDLE _handle
ODBC handle.
Definition: Handle.h:37
std::wstring datasource
Identifies the data source. For file-based drivers, this is typically a file format, such as Xbase[1] For DBMS-based drivers, this is the DBMS product.
Definition: Handle.h:25
std::wstring vendor
Identifies the vendor of the component in which the error or warning occurred or that received the er...
Definition: Handle.h:21


© Application Security Inc. - All Rights Reserved http://msiext.codeplex.com