MSSQLDatabase.h
Go to the documentation of this file.
1 #pragma once
2 
3 namespace AppSecInc
4 {
5  namespace Databases
6  {
7  namespace MSSQL
8  {
11  {
12  private:
13  std::list<MSSQLDatabaseFileSpec> _filespecs;
14  std::list<std::wstring> _database_options;
15  std::wstring _database_collate;
16  std::wstring _database_purpose;
18  std::wstring _connection_string;
19  std::wstring _database_name;
20  MSSQLDatabase& operator=(const MSSQLDatabase&);
21  public:
23  const std::wstring GetName() const { return _database_name; }
25  void SetName(const std::wstring& value) { _database_name = value; }
27  const std::wstring GetCollate() const { return _database_collate; }
29  void SetCollate(const std::wstring& value) { _database_collate = value; }
31  const std::wstring GetPurpose() const { return _database_purpose; }
33  void SetPurpose(const std::wstring& value) { _database_purpose = value; }
35  const std::list<MSSQLDatabaseFileSpec>& GetFileSpecs() const { return _filespecs; }
37  void AddFileSpec(const MSSQLDatabaseFileSpec& value) { _filespecs.push_back(value); }
39  const std::list<std::wstring>& GetOptions() const { return _database_options; }
41  void AddOption(const std::wstring& value) { _database_options.push_back(value); }
44  const AppSecInc::Databases::ODBC::ODBCConnection& GetConnection() const { return _connection; }
45  public:
47  MSSQLDatabase();
49  void Create();
50  bool Exists();
51  void Connect();
52  void Disconnect();
53  void Drop();
54  void CreateIfNotExists();
55  void DropIfExists();
57  std::wstring GetCreateQuery() const;
58  std::vector<std::wstring> GetOptionQueries() const;
59  std::wstring GetDropQuery() const;
60  std::wstring GetExistsQuery() const;
61  std::wstring GetNotExistsQuery() const;
63  MSXML2::IXMLDOMNodePtr Save(AppSecInc::Xml::XmlDocument& xmldoc, MSXML2::IXMLDOMNodePtr parent) const;
65  void Load(AppSecInc::Xml::XmlDocument& xmldoc, MSXML2::IXMLDOMNodePtr root);
66  };
67  }
68  }
69 }
std::wstring GetCreateQuery() const
Definition: MSSQLDatabase.cpp:37
void Disconnect()
disconnect from the database server
Definition: MSSQLDatabase.cpp:116
const std::list< MSSQLDatabaseFileSpec > & GetFileSpecs() const
get the database file specs
Definition: MSSQLDatabase.h:35
const AppSecInc::Databases::ODBC::ODBCConnection & GetConnection() const
Definition: MSSQLDatabase.h:44
A Microsoft SQL Server database.
Definition: MSSQLDatabase.h:10
void Drop()
drop the database
Definition: MSSQLDatabase.cpp:105
void CreateIfNotExists()
create the database if it doesn&#39;t exist
Definition: MSSQLDatabase.cpp:121
void SetCollate(const std::wstring &value)
set the database collate
Definition: MSSQLDatabase.h:29
void Connect()
connect to the database server
Definition: MSSQLDatabase.cpp:110
A generic connection info.
Definition: ConnectionInfo.h:10
std::vector< std::wstring > GetOptionQueries() const
Definition: MSSQLDatabase.cpp:25
void Load(AppSecInc::Xml::XmlDocument &xmldoc, MSXML2::IXMLDOMNodePtr root)
deserialize database from xml
Definition: MSSQLDatabase.cpp:154
A Microsoft SQL Server database file specification.
Definition: MSSQLDatabaseFileSpec.h:10
An MSXML document.
Definition: XmlDocument.h:8
void SetPurpose(const std::wstring &value)
set the database for
Definition: MSSQLDatabase.h:33
void DropIfExists()
drop the database if it exists
Definition: MSSQLDatabase.cpp:128
std::wstring GetExistsQuery() const
Definition: MSSQLDatabase.cpp:75
void AddFileSpec(const MSSQLDatabaseFileSpec &value)
add a database file spec
Definition: MSSQLDatabase.h:37
std::wstring GetDropQuery() const
Definition: MSSQLDatabase.cpp:68
A generic database.
Definition: Database.h:10
MSSQLDatabase()
constructors/destructors
Definition: MSSQLDatabase.cpp:7
const std::list< std::wstring > & GetOptions() const
get the database with options
Definition: MSSQLDatabase.h:39
AppSecInc::Databases::ODBC::ODBCConnection & GetConnection()
returns the connection object
Definition: MSSQLDatabase.h:43
MSXML2::IXMLDOMNodePtr Save(AppSecInc::Xml::XmlDocument &xmldoc, MSXML2::IXMLDOMNodePtr parent) const
serialize database to xml
Definition: MSSQLDatabase.cpp:135
void Create()
create the database, fail if exists
Definition: MSSQLDatabase.cpp:89
const std::wstring GetName() const
get the database name
Definition: MSSQLDatabase.h:23
void AddOption(const std::wstring &value)
add a database file spec
Definition: MSSQLDatabase.h:41
bool Exists()
returns true if database exists
Definition: MSSQLDatabase.cpp:98
std::wstring GetNotExistsQuery() const
Definition: MSSQLDatabase.cpp:82
An ODBC connection.
Definition: Connection.h:27
const std::wstring GetCollate() const
get the database collate
Definition: MSSQLDatabase.h:27
const std::wstring GetPurpose() const
get the database purpose, eg. ATTACH or ATTACH_REBUILD_LOG
Definition: MSSQLDatabase.h:31
void SetName(const std::wstring &value)
set the database name
Definition: MSSQLDatabase.h:25
~MSSQLDatabase()
Definition: MSSQLDatabase.cpp:21


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