Isis 3 Programmer Reference
|
Provide simplified access to resulting SQL query row. More...
#include <SqlRecord.h>
Public Member Functions | |
SqlRecord () | |
Default Constructor. More... | |
SqlRecord (const SqlQuery &query) | |
Construct a SqlRecord from a SqlQuery. More... | |
int | size () const |
Returns the number of fields/columns in query. More... | |
bool | hasField (const QString &name) const |
Indicates the existance/non-existance of a field in the row. More... | |
int | getFieldIndex (const QString &name) const |
Return the index of a named field/column This method will determine the index of the named field after a query has been successfully issued and results have been returned. More... | |
QString | getFieldName (int index) const |
Returns the name of a field/column at a particular index. More... | |
QString | getType (int index) const |
Returns the type of a field/column at the specified index. More... | |
QString | getType (const QString &name) const |
Returns the type of a named field/column. More... | |
bool | isNull (const QString &name) const |
Determines if the value of the field/column is NULL. More... | |
QString | getValue (int index) const |
Returns the value of the field/column at specified index. More... | |
QString | getValue (const QString &name) const |
Returns the value of the named field/column. More... | |
Private Member Functions | |
QString | QtTypeField (const char *ctype) const |
Returns a generic field type given a Qt QVariant type. More... | |
Provide simplified access to resulting SQL query row.
This class is derived from Qt's QSqlRecord class and is provided for convenience and simplifed use in a standard C++ environment. Mainly, it provides strings and values as Standard QStrings and other more common C++ constructs as well as taking advantage of some unique Isis provisions (e.g., QString). One can still use Qt's rich features interchangeably with this class.
SqlRecord is intended to be used by the SqlQuery class provided in this interface.
Definition at line 48 of file SqlRecord.h.
Isis::SqlRecord::SqlRecord | ( | ) |
Default Constructor.
Construct a SqlRecord object with no content. Not very useful, really.
Definition at line 30 of file SqlRecord.cpp.
Isis::SqlRecord::SqlRecord | ( | const SqlQuery & | query | ) |
Construct a SqlRecord from a SqlQuery.
This constructor takes a SqlQuery object and constructs an object from the current active row. This is only valid after an initial call to the next() method in the (derived) SqlQuery class.
query | A valid SqlQuery with an active row that will be accessable upon successful completion of this constructor. |
Definition at line 42 of file SqlRecord.cpp.
int Isis::SqlRecord::getFieldIndex | ( | const QString & | name | ) | const |
Return the index of a named field/column This method will determine the index of the named field after a query has been successfully issued and results have been returned.
name | Name of field/column to return an index for |
Definition at line 81 of file SqlRecord.cpp.
QString Isis::SqlRecord::getFieldName | ( | int | index | ) | const |
Returns the name of a field/column at a particular index.
For valid indexes, the name of the field/colunm is returned. See the Qt documentation on precise behavior.
index | Index of the desired column name to return. |
Definition at line 68 of file SqlRecord.cpp.
QString Isis::SqlRecord::getType | ( | const QString & | name | ) | const |
Returns the type of a named field/column.
This method returns the type of a named column. Types are derived from the Qt type as defined here in the QVariant type description.
What is returned is a type as named in the Description column of that table without the Q and the resulting characters returned as a lower case string. For example the QVariant::Type of QChar is return as char. The double type is returned as is, double.
name | Field/column name to determine type for |
Definition at line 105 of file SqlRecord.cpp.
References QtTypeField().
QString Isis::SqlRecord::getType | ( | int | index | ) | const |
Returns the type of a field/column at the specified index.
This method returns the type of a columnat the specfied index. Types are derived from the Qt type as defined here in the QVariant type description.
What is returned is a type as named in the Description column of that table without the Q and the resulting characters returned as a lower case string. For example the QVariant::Type of QChar is return as char. The double type is returned as is, double.
index | Index of the desired field/column to return type for. |
Definition at line 130 of file SqlRecord.cpp.
References QtTypeField().
Referenced by Isis::SqlQuery::fieldTypeList().
QString Isis::SqlRecord::getValue | ( | const QString & | name | ) | const |
Returns the value of the named field/column.
This method will return the value of the named field/column as a string. It is left to the caller to handle ant conversion of the returned type.
name | Name of the field/column to get value for. |
Definition at line 170 of file SqlRecord.cpp.
References Isis::toString().
QString Isis::SqlRecord::getValue | ( | int | index | ) | const |
Returns the value of the field/column at specified index.
This method will return the value of the field/column at the index. It is returned as a string and conversion handling is left to the caller.
index | Index of field/column get value from. |
Definition at line 156 of file SqlRecord.cpp.
References Isis::toString().
bool Isis::SqlRecord::hasField | ( | const QString & | name | ) | const |
Indicates the existance/non-existance of a field in the row.
This method can be used to determine if a field/column name exists within the row.
name | Name of field/column to test for. This is case insensitive. |
Definition at line 54 of file SqlRecord.cpp.
bool Isis::SqlRecord::isNull | ( | const QString & | name | ) | const |
Determines if the value of the field/column is NULL.
name | Name of field/column to check for NULL |
Definition at line 142 of file SqlRecord.cpp.
|
private |
Returns a generic field type given a Qt QVariant type.
This routine converts the Qt QVariant type to a more generic type. It is pretty simplistic in nature at this point. It will strip Q if it is the first character in the Description of the type and convert the result to lower case.
ctype | A Qt QVariant::Type description |
Definition at line 187 of file SqlRecord.cpp.
Referenced by getType().
|
inline |
Returns the number of fields/columns in query.
This result is the number of fields/columns returned in the query as a result of the SQL statement issued to generate the resultant row set.
Definition at line 62 of file SqlRecord.h.