Manages the database connection and queries. More...
#include <database.hpp>
Public Types | |
| enum | DocumentStatus { Waiting = 0, Parsed = 1, Processing = 2, Error = 3 } |
The status of the document in the database. More... | |
| enum | Encoding { None, Utf8 } |
The database encoding. More... | |
Public Member Functions | |
| Database () | |
| Database (const QString &host, const QString &dbName, const QString &userName, const QString &password) | |
| Initializes the database connection. | |
| ~Database () | |
| void | configureDatabase (OptionManager &optionManager) |
| Configures the database. | |
| void | set (const QString &host, const QString &dbName, const QString &userName, const QString &password) |
| Initializes the database connection. | |
Static Public Member Functions | |
| static void | configureOptions (OptionManager &optionManager) |
| Configures the option manager for database options (t, d, u, w, x). | |
Protected Member Functions | |
| void | copy (const QString &tableTarget, const QString &data) |
| Performs a COPY query. | |
| QByteArray | encodeStringForDatabase (const QString &string) const |
| Encodes a string for SQL queries, depending on the database-encoding option. | |
| QString | encodeStringFromDatabase (const char *string) const |
| Encodes a string sent by the database, depending on the database-encoding option. | |
| QByteArray | escapeString (const QString &string) |
| Escapes the string delimiter, then quotes the whole string. | |
Static Protected Member Functions | |
| static QString & | escapeCopyString (QString &string) |
| Escapes the copy delimiter and newline characters, then quotes the whole string. | |
Protected Attributes | |
| PGconn * | _connection |
| Encoding | _encoding |
Manages the database connection and queries.
This class uses the C libpq library as PosgreSQL API.
| enum Database::Encoding |
| Database::Database | ( | ) |
| Database::~Database | ( | ) |
| Database::Database | ( | const QString & | host, | |
| const QString & | dbName, | |||
| const QString & | userName, | |||
| const QString & | password | |||
| ) |
Initializes the database connection.
| DatabaseException | If connection fails |
| void Database::configureDatabase | ( | OptionManager & | optionManager | ) |
Configures the database.
| DatabaseException | From Database::set() |
| void Database::configureOptions | ( | OptionManager & | optionManager | ) | [static] |
Configures the option manager for database options (t, d, u, w, x).
| Exception | If options can not be added |
| void Database::copy | ( | const QString & | tableTarget, | |
| const QString & | data | |||
| ) | [protected] |
| QByteArray Database::encodeStringForDatabase | ( | const QString & | string | ) | const [protected] |
Encodes a string for SQL queries, depending on the database-encoding option.
| QString Database::encodeStringFromDatabase | ( | const char * | string | ) | const [protected] |
Encodes a string sent by the database, depending on the database-encoding option.
| QString & Database::escapeCopyString | ( | QString & | string | ) | [static, protected] |
Escapes the copy delimiter and newline characters, then quotes the whole string.
| QByteArray Database::escapeString | ( | const QString & | string | ) | [protected] |
Escapes the string delimiter, then quotes the whole string.
| void Database::set | ( | const QString & | host, | |
| const QString & | dbName, | |||
| const QString & | userName, | |||
| const QString & | password | |||
| ) |
Initializes the database connection.
| DatabaseException | If connection fails |
PGconn* Database::_connection [protected] |
Encoding Database::_encoding [protected] |
1.7.1