FOSSology  4.4.0
Open Source License Compliance by Open Source Software
fo::DbManager Class Reference

DB wrapper for agents. More...

#include <libfossdbmanagerclass.hpp>

Collaboration diagram for fo::DbManager:
Collaboration graph

Public Member Functions

 DbManager (int *argc, char **argv)
 Constructor for DbManager. More...
 
 DbManager (fo_dbManager *dbManager)
 
PGconn * getConnection () const
 
DbManager spawn () const
 
fo_dbManagergetStruct_dbManager () const
 
bool tableExists (const char *tableName) const
 
bool sequenceExists (const char *name) const
 
bool begin () const
 
bool commit () const
 
bool rollback () const
 
void ignoreWarnings (bool) const
 
QueryResult queryPrintf (const char *queryFormat,...) const
 Execute a query in printf format. More...
 
QueryResult execPrepared (fo_dbManager_PreparedStatement *stmt,...) const
 Execute a prepared statement with new parameters. More...
 

Private Attributes

unptr::shared_ptr< fo_dbManagerdbManager
 Shared DB manager.
 

Detailed Description

DB wrapper for agents.

Definition at line 48 of file libfossdbmanagerclass.hpp.

Constructor & Destructor Documentation

◆ DbManager() [1/2]

DbManager::DbManager ( int *  argc,
char **  argv 
)

Constructor for DbManager.

Store a shared pointer for DB Manager

Definition at line 49 of file libfossdbmanagerclass.cc.

◆ DbManager() [2/2]

DbManager::DbManager ( fo_dbManager _dbManager)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 57 of file libfossdbmanagerclass.cc.

Member Function Documentation

◆ begin()

bool DbManager::begin ( ) const

BEGIN a transaction block

Returns
True on success, false otherwise
See also
fo_dbManager_begin()

Definition at line 117 of file libfossdbmanagerclass.cc.

◆ commit()

bool DbManager::commit ( ) const

COMMIT a transaction block

Returns
True on success, false otherwise
See also
fo_dbManager_commit()

Definition at line 127 of file libfossdbmanagerclass.cc.

◆ execPrepared()

QueryResult DbManager::execPrepared ( fo_dbManager_PreparedStatement stmt,
  ... 
) const

Execute a prepared statement with new parameters.

Parameters
stmtPointer to the prepared statement
Returns
QueryResult
See also
fo_dbManager_ExecPreparedv()

Definition at line 170 of file libfossdbmanagerclass.cc.

◆ getConnection()

PGconn * DbManager::getConnection ( ) const

Get bare DB connection object

Returns
Get the native connection object

Definition at line 66 of file libfossdbmanagerclass.cc.

◆ getStruct_dbManager()

fo_dbManager * DbManager::getStruct_dbManager ( ) const

Get the C wrapper for DB manager

Returns
C wrapper for DB manager

Definition at line 85 of file libfossdbmanagerclass.cc.

◆ ignoreWarnings()

void DbManager::ignoreWarnings ( bool  b) const

Set the ignore warning flag for connection

Parameters
bTrue to ignore waring
See also
fo_dbManager_ignoreWarnings()

Definition at line 185 of file libfossdbmanagerclass.cc.

◆ queryPrintf()

QueryResult DbManager::queryPrintf ( const char *  queryFormat,
  ... 
) const

Execute a query in printf format.

This function can execute a query using the printf format (s, d, etc. placeholder in queryFormat).

Parameters
queryFormatPrintf styled string format
Returns
QueryResult
See also
fo_dbManager_Exec_printf()

Definition at line 151 of file libfossdbmanagerclass.cc.

◆ rollback()

bool DbManager::rollback ( ) const

ROLLBACK a transaction block

Returns
True on success, false otherwise
See also
fo_dbManager_rollback()

Definition at line 137 of file libfossdbmanagerclass.cc.

◆ sequenceExists()

bool DbManager::sequenceExists ( const char *  name) const

Check if a sequence exists in Database

Parameters
nameSequence to check
Returns
True if sequence exists, false otherwise
See also
fo_dbManager_exists()

Definition at line 107 of file libfossdbmanagerclass.cc.

◆ spawn()

DbManager DbManager::spawn ( ) const

Fork a new DB connection

Returns
New DbManager object with new DB connection
See also
fo_dbManager_fork()

Definition at line 76 of file libfossdbmanagerclass.cc.

◆ tableExists()

bool DbManager::tableExists ( const char *  tableName) const

Check if a table exists in Database

Parameters
tableNameTable to check
Returns
True if table exists, false otherwise
See also
fo_dbManager_tableExists()

Definition at line 96 of file libfossdbmanagerclass.cc.


The documentation for this class was generated from the following files: