SQL Relay C++ API
|
#include <sqlrexport.h>
Inherited by sqlrexportdomnode [virtual]
, sqlrexportfile [virtual]
, and sqlrexporttable [virtual]
.
Public Member Functions | |
sqlrexport () | |
virtual | ~sqlrexport () |
void | setSqlrConnection (sqlrconnection *sqlrcon) |
void | setSqlrCursor (sqlrcursor *sqlrcur) |
sqlrconnection * | getSqlrConnection () |
sqlrcursor * | getSqlrCursor () |
void | setTable (const char *table) |
const char * | getTable () |
void | setExcludeColumns (bool excludecolumns) |
bool | getExcludeColumns () |
void | setColumnsToExclude (const char *const *columnstoexclude) |
const char *const * | getColumnsToExclude () |
void | setLogger (logger *lg) |
logger * | getLogger () |
void | setCoarseLogLevel (uint8_t coarseloglevel) |
uint8_t | getCoarseLogLevel () |
void | setFineLogLevel (uint8_t fineloglevel) |
uint8_t | getFineLogLevel () |
void | setLogIndent (uint32_t logindent) |
uint32_t | getLogIndent () |
void | setLogErrors (bool logerrors) |
bool | getLogErrors () |
virtual bool | exportData () |
uint64_t | getExportedRowCount () |
Protected Member Functions | |
virtual bool | exportStart () |
virtual bool | columnsStart () |
virtual bool | columnStart () |
virtual bool | columnEnd () |
virtual bool | columnsEnd () |
virtual bool | rowsStart () |
virtual bool | rowStart () |
virtual bool | fieldStart () |
virtual bool | fieldEnd () |
virtual bool | rowEnd () |
virtual bool | rowsEnd () |
virtual bool | beginStart () |
virtual bool | beginEnd () |
virtual bool | commitStart () |
virtual bool | commitEnd () |
virtual bool | error (int64_t errornumber, const char *errormessage) |
virtual bool | exportEnd () |
void | setExcludeRow (bool excluderow) |
bool | getExcludeRow () |
void | setCurrentRow (uint64_t currentrow) |
uint64_t | getCurrentRow () |
void | setCurrentColumn (uint32_t currentcol) |
uint32_t | getCurrentColumn () |
void | setCurrentColumnName (const char *currentcolname) |
const char * | getCurrentColumnName () |
void | setCurrentField (const char *currentfield) |
const char * | getCurrentField () |
void | setIsNumericColumn (uint64_t index, bool numeric) |
bool | getIsNumericColumn (uint64_t index) |
void | clearAreNumericColumns () |
void | setExportedRowCount (uint64_t exportedrowcount) |
The sqlrexport class provides a base class for child classes that wish to implement export of data from a database, via SQL Relay. It provides various common methods. Each child class should implement the exportData() method.
sqlrexport::sqlrexport | ( | ) |
Creates an instance of the sqlrexport class.
|
virtual |
Destroys this instance of the sqlrexport class.
|
protectedvirtual |
This method should be called after a begin().
This implementation just returns true but a child class may override this method to do something else.
Should return true on success and false if an error occurred and export should stop if this method return false.
|
protectedvirtual |
This method should be called before a begin().
This implementation just returns true but a child class may override this method to do something else.
Should return true on success and false if an error occurred and export should stop if this method return false.
|
protected |
Clears the data types of all columns, setting them to to non-numeric.
Not commonly called by implementations of the *Start/End() methods.
|
protectedvirtual |
This method should be called after the export of each column.
Note that it should be called for each column, whether or not columns are excluded, and whether or not this particular column is excluded.
This implementation just returns true but a child class may override this method to do something else.
At this point, unless specifically set otherwise in an overridden method...
If you called setColumnName(...) in columnStart(), and had to allocate memory for the new value, then this may be an appropriate place to free that memory. See notes in columnStart() for details.
Should return true on success and false if an error occurred and export should stop if this method return false.
|
protectedvirtual |
This method should be called after the export of the columns.
Note that it should be called whether or not columns are excluded.
This implementation just returns true but a child class may override this method to do something else.
At this point, unless specifically set otherwise in an overridden method...
If you called setColumnName(...) in columnStart(), and had to allocate memory for the new value, then this may be an appropriate place to free that memory. See notes in columnStart() for details.
Should return true on success and false if an error occurred and export should stop if this method return false.
|
protectedvirtual |
This method should be called prior to the export of the columns.
Note that it should be called whether or not columns are excluded.
This implementation just returns true but a child class may override this method to do something else.
At this point, unless specifically set otherwise in an overridden method...
Should return true on success and false if an error occurred and export should stop if this method return false.
|
protectedvirtual |
This method should be called prior to the export of each column.
Note that it should be called for each column, whether or not columns are excluded, and whether or not this particular column is excluded.
This implementation just returns true but a child class may override this method to do something else.
At this point, unless specifically set otherwise in an overridden method...
If you want to modify the name of the column that is going to be exported, this is a good method to override to call setCurrentColumnName(...)
Note, however...
The memory allocated to store the new value must persist until the value is actually exported. When this is depends on the implementation of the exportData() method.
Implementations that export to a file or json domnode typically export the column name before calling columnEnd(). As such, storage for the updated column name may be freed inside of your implementation of columnEnd().
However, other implementations may export all column names at once prior to calling columnsEnd(). In this case, storage for the updated column name should be freed inside of your implemenatation of columnsEnd().
Be sure to verify how the various exportData() methods that you are using were written, and use care when freeing storage allocated for updated column names.
Should return true on success and false if an error occurred and export should stop if this method return false.
|
protectedvirtual |
This method should be called after a commit().
This implementation just returns true but a child class may override this method to do something else.
Should return true on success and false if an error occurred and export should stop if this method return false.
|
protectedvirtual |
This method should be called before a commit().
This implementation just returns true but a child class may override this method to do something else.
Should return true on success and false if an error occurred and export should stop if this method return false.
|
protectedvirtual |
This method should be called if a commit(), begin(), executeQuery(), or other database operation fails.
This implementation just returns false but a child class may override this method to do something else.
Should return true if export may continue, or false if should stop.
|
virtual |
Exports the result set of the cursor currently in use as set by the most recent call to setSqlrCursor().
Returns true on success and false if an error occurred.
Note that the default implementation of this method just returns true. Child classes should override this method.
Reimplemented in sqlrexportcsv, sqlrexportcsvjsondomnode, sqlrexportdomnode, sqlrexportfile, sqlrexporttable, and sqlrexportxml.
|
protectedvirtual |
This method should be called at the end of the export process.
This implementation just returns true but a child class may override this method to do something else.
At this point, unless specifically set otherwise in an overridden method...
Should return true on success and false if an error occurred and export should stop if this method return false.
|
protectedvirtual |
This method should be called at the beginning of the export process.
This implementation just returns true but a child class may override this method to do something else.
At this point...
Should return true on success and false if an error occurred and export should stop if this method return false.
|
protectedvirtual |
This method should be called after the export of each field.
This implementation just returns true but a child class may override this method to do something else.
At this point, unless specifically set otherwise in an overridden method...
If you called setCurrentField(...) in fieldStart(), and had to allocate memory for the new value, then this may be an appropriate place to free that memory. See notes in fieldStart() for details.
Should return true on success and false if an error occurred and export should stop if this method return false.
|
protectedvirtual |
This method should be called by prior to the export of each field.
This implementation just returns true but a child class may override this method to do something else.
At this point, unless specifically set otherwise in an overridden method...
If you want to modify the value of the field that is going to be exported, this is a good method to override to call setCurrentField(...)
Note, however...
The memory allocated to store the new value must persist until the value is actually exported. When this is depends on the implementation of the exportData() method.
Implementations that export to a file or json domnode typically export the field before calling fieldEnd(). As such, storage for the updated field value may be freed inside of your implementation of fieldEnd().
However, implementations that export to a table tend to build an insert statement, bind values before calling fieldEnd(), and then execute the statement before calling rowEnd(). In this case, storage for the updated field value should be freed inside of your implemenatation of rowEnd().
Be sure to verify how the various exportData() methods that you are using were written, and use care when freeing storage allocated for updated field values.
Should return true on success and false if an error occurred and export should stop if this method return false.
uint8_t sqlrexport::getCoarseLogLevel | ( | ) |
Returns the coarse log level.
const char *const * sqlrexport::getColumnsToExclude | ( | ) |
Returns the current set of columns that will not be exported as a NULL-terminated array.
|
protected |
Gets the index of the column that is currently being exported.
May be called by implementations of the *Start/End() methods.
|
protected |
Gets the name of the column that is currently being exported.
May be called by implementations of the *Start/End() methods.
|
protected |
Gets the value of the field that is currently being exported.
May be called by implementations of the *Start/End() methods.
|
protected |
Gets the index of the row that is currently being exported.
May be called by implementations of the *Start/End() methods.
bool sqlrexport::getExcludeColumns | ( | ) |
Returns whether or not column information will be exported.
|
protected |
Gets whether the current row will be excluded or not. Rows that are excluded are not exported.
May be called by implementations of the *Start/End() methods.
uint64_t sqlrexport::getExportedRowCount | ( | ) |
Returns the number of rows that were exported by the most recent call to exportData(), or the current number of rows that have been exported, if called from inside one of the Start()/End() methods.
uint8_t sqlrexport::getFineLogLevel | ( | ) |
Returns the fine log level.
|
protected |
Get whether the data type of the column in position "index" is a numeric type or not.
May be called by implementations of the *Start/End() methods.
bool sqlrexport::getLogErrors | ( | ) |
Returns true if SQL errors will be logged at the coarse log level and false otherwise.
logger * sqlrexport::getLogger | ( | ) |
Returns the logger that is set to use when logging progress or NULL if no logger is set.
uint32_t sqlrexport::getLogIndent | ( | ) |
Returns the log indent.
sqlrconnection * sqlrexport::getSqlrConnection | ( | ) |
Returns the instance of sqlrconnection that this instance is configured to use to fetch data for the export.
sqlrcursor * sqlrexport::getSqlrCursor | ( | ) |
Returns the instance of sqlrursor that this instance is configured to use to fetch data for the export.
const char * sqlrexport::getTable | ( | ) |
Gets the name of the table associated with the export.
This may be used differently by different child classes. Eg. it may be the name of the table being exported, or the name of the table that data is being exported to.
|
protectedvirtual |
This method should be called after the export of each row.
This implementation just returns true but a child class may override this method to do something else.
At this point, unless specifically set otherwise in an overridden method...
If you called setCurrentField(...) in fieldStart(), and had to allocate memory for the new value, then this may be an appropriate place to free that memory. See notes in fieldStart() for details.
Should return true on success and false if an error occurred and export should stop if this method return false.
|
protectedvirtual |
This method should be called after the export of the rows.
This implementation just returns true but a child class may override this method to do something else.
At this point, unless specifically set otherwise in an overridden method...
Should return true on success and false if an error occurred and export should stop if this method return false.
|
protectedvirtual |
This method should be called by prior to the export of the rows.
This implementation just returns true but a child class may override this method to do something else.
At this point, unless specifically set otherwise in an overridden method...
Should return true on success and false if an error occurred and export should stop if this method return false.
|
protectedvirtual |
This method should be called prior to the export of each row.
This implementation just returns true but a child class may override this method to do something else.
At this point, unless specifically set otherwise in an overridden method...
This is a good place to call setExcludeRow(true) if you don't want this row to be exported.
Should return true on success and false if an error occurred and export should stop if this method return false.
void sqlrexport::setCoarseLogLevel | ( | uint8_t | coarseloglevel | ) |
Sets the coarse log level. General log messages will be logged at this level. If the log level of "lg" (set by setLogger() above) is set equal to or greater than "coarseloglevel" then general log messages will be logged. Defaults to 0.
void sqlrexport::setColumnsToExclude | ( | const char *const * | columnstoexclude | ) |
If "columnstoexclude" is a null terminated array of column names, then those columns will not be exported. If "columnstoexclude" is NULL then all columns will be exported.
|
protected |
Sets the index of the column that is currently being exported.
Not commonly called by implementations of the *Start/End() methods.
|
protected |
Sets the name of the column that is currently being exported.
May be called by columnStart(). Not commonly called by other *Start/End() methods.
|
protected |
Sets the value of the field that is currently being exported.
Not commonly called by implementations of the *Start/End() methods.
|
protected |
Sets the index of the row that is currently being exported.
Not commonly called by implementations of the *Start/End() methods.
void sqlrexport::setExcludeColumns | ( | bool | excludecolumns | ) |
If "excludecolumns" is set false, then column information will be exported (eg. to the CSV header, XML tags inside of the file, etc.).
If "excludecolumns" is set true, then column information will not be exported.
Defaults to false.
|
protected |
Sets whether the current row will be excluded or not. Rows that are excluded are not exported.
May be called by rowStart(), fieldStart(), or fieldEnd(). Not commonly called by other *Start/End() methods.
|
protected |
Sets the number of rows that have been exported.
Not commonly called by implementations of the *Start/End() methods.
void sqlrexport::setFineLogLevel | ( | uint8_t | fineloglevel | ) |
Sets the fine log level. Detailed log messages will be logged at this level. If the log level of "lg" (set by setLogger() above) is set equal to or greater than "coarseloglevel" then general log messages will be logged. Defaults to 9.
|
protected |
Sets whether the data type of the column in position "index" is a numeric type or not. If "numeric" is true then the type of the column is set to numeric. If "numeric" is false then the type of the column is set to non-numeric.
Not commonly called by implementations of the *Start/End() methods.
void sqlrexport::setLogErrors | ( | bool | logerrors | ) |
If "logerrors" is set true then SQL errors will be logged at the coarse log level. If set false then SQL errors will not be logged. Defaults to false.
void sqlrexport::setLogger | ( | logger * | lg | ) |
Sets the logger to use when logging progress to "lg". If "lg" is set to NULL then progress will not be logged. Defaults to NULL.
void sqlrexport::setLogIndent | ( | uint32_t | logindent | ) |
Sets the log indent level to "logindent". Defaults to 0.
void sqlrexport::setSqlrConnection | ( | sqlrconnection * | sqlrcon | ) |
Sets the instance of sqlrconnection that this instance will use to fetch data for the export.
void sqlrexport::setSqlrCursor | ( | sqlrcursor * | sqlrcur | ) |
Sets the instance of sqlrcursor that this instance will use to fetch data for the export.
void sqlrexport::setTable | ( | const char * | table | ) |
Sets the name of the table associated with the export.
This may be used differently by different child classes. Eg. it may be the name of the table being exported, or the name of the table that data is being exported to.