Implemented the loading of the list of types into the database catalogue.
This commit is contained in:
parent
43c3835350
commit
5a35fa6a30
3 changed files with 48 additions and 1 deletions
|
|
@ -1,6 +1,29 @@
|
|||
#include "pgsqldatabasecatalogue.h"
|
||||
#include "pgsqldatabasecatalogue.h"
|
||||
#include "pgtypecontainer.h"
|
||||
#include "PgsqlConn.h"
|
||||
|
||||
PgsqlDatabaseCatalogue::PgsqlDatabaseCatalogue()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
PgsqlDatabaseCatalogue::~PgsqlDatabaseCatalogue()
|
||||
{
|
||||
delete m_types;
|
||||
}
|
||||
|
||||
void PgsqlDatabaseCatalogue::loadAll(Pgsql::Connection &conn)
|
||||
{
|
||||
loadTypes(conn);
|
||||
}
|
||||
|
||||
void PgsqlDatabaseCatalogue::loadTypes(Pgsql::Connection &conn)
|
||||
{
|
||||
if (m_types == nullptr) {
|
||||
m_types = new PgTypeContainer;
|
||||
}
|
||||
|
||||
std::string q = m_types->getLoadQuery();
|
||||
Pgsql::Result result = conn.query(q.c_str());
|
||||
m_types->load(result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,12 +3,27 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
namespace Pgsql {
|
||||
|
||||
class Connection;
|
||||
|
||||
}
|
||||
|
||||
class PgTypeContainer;
|
||||
|
||||
class PgsqlDatabaseCatalogue {
|
||||
public:
|
||||
PgsqlDatabaseCatalogue();
|
||||
PgsqlDatabaseCatalogue(const PgsqlDatabaseCatalogue&) = delete;
|
||||
PgsqlDatabaseCatalogue& operator = (const PgsqlDatabaseCatalogue&) = delete;
|
||||
|
||||
~PgsqlDatabaseCatalogue();
|
||||
|
||||
|
||||
void loadAll(Pgsql::Connection &conn);
|
||||
void loadTypes(Pgsql::Connection &conn);
|
||||
|
||||
const PgTypeContainer* getTypes() const { return m_types; }
|
||||
private:
|
||||
PgTypeContainer *m_types;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,15 @@
|
|||
#ifndef SCOPEGUARD_H
|
||||
#define SCOPEGUARD_H
|
||||
|
||||
/** \brief Template class for executing code at scope exit.
|
||||
*
|
||||
* By default the object will be an active mode and execute the function
|
||||
* passed to the constructor when the object is destructed. You can however
|
||||
* cancel this action by calling dismiss().
|
||||
*
|
||||
* There is a clever macro that allows you to write something like
|
||||
* SCOPE_EXIT { foo(); };
|
||||
*/
|
||||
template<class Fun>
|
||||
class ScopeGuard {
|
||||
Fun f_;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue