Isis 3 Developer 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... | |
virtual | ~SqlRecord () |
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... | |
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.
Isis::SqlRecord::SqlRecord | ( | ) |
Default Constructor.
Construct a SqlRecord object with no content. Not very useful, really.
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. |
|
inlinevirtual |
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 |
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. |
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. |
Referenced by Isis::SqlQuery::fieldTypeList().
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 |
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. |
References Isis::toString().
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. |
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. |
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 |
|
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.