Nebula
Loading...
Searching...
No Matches
Db::Reader Class Reference

#include <reader.h>

Detailed Description

Wrapper to bulk-read the contents of a database table.

Inherits Core::RefCounted.

Public Member Functions

 Reader ()
 constructor
virtual ~Reader ()
 destructor
void SetDatabase (const Ptr< Database > &db)
 set database object
void SetTableName (const Util::String &n)
 set the database table name
void AddFilterAttr (const Attr::Attribute &attr)
 add an optional filter/WHERE attribute
bool Open ()
 open the reader, this will perform a query on the database
bool IsOpen () const
 return true if reader is open
void Close ()
 close the reader
int GetNumRows () const
 get number of rows in the result
void SetToRow (int rowIndex)
 set read cursor to specified row
int GetCurrentRowIndex () const
 get current row index
bool HasAttr (Attr::AttrId attrId) const
 return true if attribute exists at current row
bool GetBool (Attr::BoolAttrId attrId) const
 return bool attribute value
int GetInt (Attr::IntAttrId attrId) const
 return int attribute value
float GetFloat (Attr::FloatAttrId attrId) const
 return float attribute value
const Util::StringGetString (Attr::StringAttrId attrId) const
 return string attribute value
const Math::vec4 GetVec4 (Attr::Vec4AttrId attrId) const
 return vec4 attribute value
const Math::mat4 GetMat4 (Attr::Mat4AttrId attrId) const
 return mat4 attribute value
const Util::GuidGetGuid (Attr::GuidAttrId attrId) const
 return guid attribute value
const Util::BlobGetBlob (Attr::BlobAttrId attrId) const
 return blob attribute value
const Ptr< Db::ValueTable > & GetValueTable () const
 get direct pointer to value table
Public Member Functions inherited from Core::RefCounted
 RefCounted ()
 constructor
int GetRefCount () const
 get the current refcount
void AddRef ()
 increment refcount by one
void Release ()
 decrement refcount and destroy object if refcount is zero
bool IsInstanceOf (const Rtti &rtti) const
 return true if this object is instance of given class
bool IsInstanceOf (const Util::String &className) const
 return true if this object is instance of given class by string
bool IsInstanceOf (const Util::FourCC &classFourCC) const
 return true if this object is instance of given class by fourcc
bool IsA (const Rtti &rtti) const
 return true if this object is instance of given class, or a derived class
bool IsA (const Util::String &rttiName) const
 return true if this object is instance of given class, or a derived class, by string
bool IsA (const Util::FourCC &rttiFourCC) const
 return true if this object is instance of given class, or a derived class, by fourcc
const Util::StringGetClassName () const
 get the class name
Util::FourCC GetClassFourCC () const
 get the class FourCC code

Private Member Functions

 __DeclareClass (Reader)

Private Attributes

bool isOpen
Ptr< Databasedatabase
Util::String tableName
Util::Array< Attr::AttributefilterAttrs
Ptr< Datasetdataset
Ptr< ValueTablevalueTable
IndexT curRowIndex

Additional Inherited Members

Static Public Member Functions inherited from Core::RefCounted
static void DumpRefCountingLeaks ()
 dump refcounting leaks, call at end of application (NEBULA_DEBUG builds only!)
Protected Member Functions inherited from Core::RefCounted
virtual ~RefCounted ()
 destructor (called when refcount reaches zero)

Constructor & Destructor Documentation

◆ Reader()

Db::Reader::Reader ( )

constructor

◆ ~Reader()

Db::Reader::~Reader ( )
virtual

destructor

Member Function Documentation

◆ __DeclareClass()

Db::Reader::__DeclareClass ( Reader )
private

◆ AddFilterAttr()

void Db::Reader::AddFilterAttr ( const Attr::Attribute & attr)
inline

add an optional filter/WHERE attribute

Add a filter attribute to the reader.

The reader will create a database query where all filter attribute are ANDed.

◆ Close()

void Db::Reader::Close ( )

close the reader

Close the reader.

This deletes the query object created in the constructor.

◆ GetBlob()

const Util::Blob & Db::Reader::GetBlob ( Attr::BlobAttrId attrId) const

return blob attribute value

◆ GetBool()

bool Db::Reader::GetBool ( Attr::BoolAttrId attrId) const

return bool attribute value

◆ GetCurrentRowIndex()

int Db::Reader::GetCurrentRowIndex ( ) const
inline

get current row index

◆ GetFloat()

float Db::Reader::GetFloat ( Attr::FloatAttrId attrId) const

return float attribute value

◆ GetGuid()

const Util::Guid & Db::Reader::GetGuid ( Attr::GuidAttrId attrId) const

return guid attribute value

◆ GetInt()

int Db::Reader::GetInt ( Attr::IntAttrId attrId) const

return int attribute value

◆ GetMat4()

const Math::mat4 Db::Reader::GetMat4 ( Attr::Mat4AttrId attrId) const

return mat4 attribute value

◆ GetNumRows()

int Db::Reader::GetNumRows ( ) const
inline

get number of rows in the result

Returns the number of rows in the result.

Only valid while open.

◆ GetString()

const Util::String & Db::Reader::GetString ( Attr::StringAttrId attrId) const

return string attribute value

◆ GetValueTable()

const Ptr< Db::ValueTable > & Db::Reader::GetValueTable ( ) const
inline

get direct pointer to value table

◆ GetVec4()

const Math::vec4 Db::Reader::GetVec4 ( Attr::Vec4AttrId attrId) const

return vec4 attribute value

◆ HasAttr()

bool Db::Reader::HasAttr ( Attr::AttrId attrId) const

return true if attribute exists at current row

Return true if a specific attribute exists in the current row.

◆ IsOpen()

bool Db::Reader::IsOpen ( ) const
inline

return true if reader is open

◆ Open()

bool Db::Reader::Open ( )

open the reader, this will perform a query on the database

Open the reader.

This will create a dataset which performs a query on the database.

◆ SetDatabase()

void Db::Reader::SetDatabase ( const Ptr< Database > & db)
inline

set database object

◆ SetTableName()

void Db::Reader::SetTableName ( const Util::String & n)
inline

set the database table name

Set the name of database table the reader will work on.

◆ SetToRow()

void Db::Reader::SetToRow ( int rowIndex)
inline

set read cursor to specified row

Sets the reader cursor to the specified row.

Only valid while open.

Member Data Documentation

◆ curRowIndex

IndexT Db::Reader::curRowIndex
private

◆ database

Ptr<Database> Db::Reader::database
private

◆ dataset

Ptr<Dataset> Db::Reader::dataset
private

◆ filterAttrs

Util::Array<Attr::Attribute> Db::Reader::filterAttrs
private

◆ isOpen

bool Db::Reader::isOpen
private

◆ tableName

Util::String Db::Reader::tableName
private

◆ valueTable

Ptr<ValueTable> Db::Reader::valueTable
private

The documentation for this class was generated from the following files:
  • /github/workspace/code/addons/db/reader.h
  • /github/workspace/code/addons/db/reader.cc