Isis 3 Programmer 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.
 
 SqlRecord (const SqlQuery &query)
 Construct a SqlRecord from a SqlQuery.
 
int size () const
 Returns the number of fields/columns in query.
 
bool hasField (const QString &name) const
 Indicates the existance/non-existance of a field in the row.
 
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.
 
QString getFieldName (int index) const
 Returns the name of a field/column at a particular index.
 
QString getType (int index) const
 Returns the type of a field/column at the specified index.
 
QString getType (const QString &name) const
 Returns the type of a named field/column.
 
bool isNull (const QString &name) const
 Determines if the value of the field/column is NULL.
 
QString getValue (int index) const
 Returns the value of the field/column at specified index.
 
QString getValue (const QString &name) const
 Returns the value of the named field/column.
 

Private Member Functions

QString QtTypeField (const char *ctype) const
 Returns a generic field type given a Qt QVariant type.
 

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
History
2007-06-05 Brendan George - Modified to work with QString/StringTools merge

Definition at line 48 of file SqlRecord.h.

Constructor & Destructor Documentation

◆ SqlRecord() [1/2]

Isis::SqlRecord::SqlRecord ( )

Default Constructor.

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

Definition at line 30 of file SqlRecord.cpp.

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

Definition at line 42 of file SqlRecord.cpp.

◆ ~SqlRecord()

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

Definition at line 52 of file SqlRecord.h.

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

Definition at line 81 of file SqlRecord.cpp.

◆ 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

Definition at line 68 of file SqlRecord.cpp.

◆ getType() [1/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

Definition at line 105 of file SqlRecord.cpp.

References QtTypeField().

◆ getType() [2/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.

Definition at line 130 of file SqlRecord.cpp.

References QtTypeField().

◆ getValue() [1/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.

Definition at line 170 of file SqlRecord.cpp.

References Isis::toString().

◆ getValue() [2/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.

Definition at line 156 of file SqlRecord.cpp.

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.

Definition at line 54 of file SqlRecord.cpp.

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

Definition at line 142 of file SqlRecord.cpp.

References isNull().

Referenced by isNull().

◆ QtTypeField()

QString Isis::SqlRecord::QtTypeField ( const char * ctype) const
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.

Parameters
ctypeA Qt QVariant::Type description
Returns
QString A generic type for the Qt type.

Definition at line 187 of file SqlRecord.cpp.

Referenced by getType(), and getType().

◆ 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

Definition at line 62 of file SqlRecord.h.


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