Isis 3 Developer Reference
Isis::SqlRecord Class Reference

Provide simplified access to resulting SQL query row. More...

#include <SqlRecord.h>

Inheritance diagram for Isis::SqlRecord:
Inheritance graph
Collaboration diagram for Isis::SqlRecord:
Collaboration graph

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...
 

Detailed Description

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.

See also
SqlQuery.
Author
2006-08-18 Kris Becker

Constructor & Destructor Documentation

◆ SqlRecord() [1/2]

Isis::SqlRecord::SqlRecord ( )

Default Constructor.

Construct a SqlRecord object with no content. Not very useful, really.

◆ SqlRecord() [2/2]

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.

Parameters
queryA valid SqlQuery with an active row that will be accessable upon successful completion of this constructor.

◆ ~SqlRecord()

virtual Isis::SqlRecord::~SqlRecord ( )
inlinevirtual

Member Function Documentation

◆ getFieldIndex()

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.

Parameters
nameName of field/column to return an index for
Returns
int Index of the named column

◆ getFieldName()

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.

Parameters
indexIndex of the desired column name to return.
Returns
QString Name of the column at the requested index

◆ getType() [1/2]

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.

See also
QtTypeField().
getType(const QString &name).
Parameters
indexIndex of the desired field/column to return type for.
Returns
QString Type of the field/column at given index.

Referenced by Isis::SqlQuery::fieldTypeList().

◆ getType() [2/2]

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.

See also
QtTypeField().
getType(int index).
Parameters
nameField/column name to determine type for
Returns
QString Type of the field/column

◆ getValue() [1/2]

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.

Parameters
indexIndex of field/column get value from.
Returns
QString Value of the field/column index.

References Isis::toString().

◆ getValue() [2/2]

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.

Parameters
nameName of the field/column to get value for.
Returns
QString Value of the named field/column.

References Isis::toString().

◆ hasField()

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.

Parameters
nameName of field/column to test for. This is case insensitive.
Returns
bool True if the field/column exists, false otherwise.

◆ isNull()

bool Isis::SqlRecord::isNull ( const QString &  name) const

Determines if the value of the field/column is NULL.

Parameters
nameName of field/column to check for NULL
Returns
bool True if NULL, otherwise false.

◆ size()

int Isis::SqlRecord::size ( ) const
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.

Returns
int Number of fields/columns in row

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