FOSSology
4.4.0
Open Source License Compliance by Open Source Software
|
Wrapper for DB result. More...
#include <libfossdbQueryResult.hpp>
Public Member Functions | |
QueryResult (QueryResult &&o) | |
bool | isFailed () const |
Check if the query failed. More... | |
operator bool () const | |
int | getRowCount () const |
std::vector< std::string > | getRow (int i) const |
template<typename T > | |
std::vector< T > | getSimpleResults (int columnN, T(functionP)(const char *)) const |
Get vector of a single column from query result. More... | |
Private Member Functions | |
QueryResult (PGresult *ptr) | |
Private Attributes | |
unptr::unique_ptr< PGresult, PGresultDeleter > | ptr |
Unique pointer to the actual PGresult. | |
Friends | |
class | DbManager |
class | AgentDatabaseHandler |
Wrapper for DB result.
Definition at line 42 of file libfossdbQueryResult.hpp.
|
private |
Constructor for QueryResult
pgResult | Postgres query result object |
Definition at line 23 of file libfossdbQueryResult.cc.
std::vector< std::string > QueryResult::getRow | ( | int | i | ) | const |
Get all columns from required row as a string vector
i | The row to be fetched |
Definition at line 53 of file libfossdbQueryResult.cc.
int QueryResult::getRowCount | ( | ) | const |
Check the row count in the query result
Definition at line 40 of file libfossdbQueryResult.cc.
std::vector< T > fo::QueryResult::getSimpleResults | ( | int | columnN, |
T(functionP)(const char *) | |||
) | const |
Get vector of a single column from query result.
Get a single column's values as a vector of type T (defined by functionP
param). The values will be translated using the functionP
.
columnN | Position of the required column |
functionP | Function to translate the string result in desired format |
Definition at line 85 of file libfossdbQueryResult.hpp.
bool QueryResult::isFailed | ( | ) | const |
Check if the query failed.
Check if the query is failed by checking the Postgres object for NULL
Definition at line 32 of file libfossdbQueryResult.cc.
|
inline |
Check if the query result failed
Definition at line 60 of file libfossdbQueryResult.hpp.