sptk2 logo
SPTK Home Page
Public Member Functions | Protected Member Functions | Friends | List of all members
sptk::DataSource Class Referenceabstract

#include <DataSource.h>

Inheritance diagram for sptk::DataSource:
sptk::MemoryDS sptk::QueryStatementManagement sptk::DirectoryDS sptk::ImapDS sptk::Query sptk::InsertQuery

Public Member Functions

 DataSource ()=default
 
virtual ~DataSource ()=default
 
virtual Fieldoperator[] (size_t fieldIndex)=0
 
virtual Fieldoperator[] (const String &fieldName)=0
 
virtual size_t fieldCount () const =0
 
virtual size_t recordCount () const =0
 
virtual bool readField (const char *fieldName, Variant &fieldValue)=0
 
virtual bool writeField (const char *fieldName, const Variant &fieldValue)=0
 
virtual bool open ()
 
virtual bool close ()
 
virtual bool first ()
 
virtual bool next ()
 
virtual bool prior ()
 
virtual bool last ()
 
virtual bool find (const String &, const Variant &)
 
virtual bool eof () const
 
bool load ()
 
bool save ()
 
void exportRowTo (const xdoc::SNode &node, bool compactXmlMode, bool nullLargeData=false)
 
virtual void exportTo (xdoc::Node &parentNode, const String &nodeName, bool compactXmlMode)
 

Protected Member Functions

virtual bool loadData ()
 
virtual bool saveData ()
 

Friends

class Fl_Group
 

Detailed Description

Universal data source for many SPTK widgets.

It's designed as a base class for multiple datasources available in SPTK. The main idea is to provide the simple interface that allows to open the datasource with certain parameters and read or write the datasource fields. And don't you forget to close it :)

Constructor & Destructor Documentation

◆ DataSource()

sptk::DataSource::DataSource ( )
default

Default constructor

◆ ~DataSource()

virtual sptk::DataSource::~DataSource ( )
virtualdefault

Destructor

Member Function Documentation

◆ close()

virtual bool sptk::DataSource::close ( )
inlinevirtual

Closes the datasource. Implemented in derved class.

Reimplemented in sptk::Query, and sptk::MemoryDS.

◆ eof()

virtual bool sptk::DataSource::eof ( ) const
inlinevirtual

Returns true if there are no more records in the datasource. Implemented in derved class.

Reimplemented in sptk::QueryStatementManagement, and sptk::MemoryDS.

◆ exportRowTo()

void sptk::DataSource::exportRowTo ( const xdoc::SNode &  node,
bool  compactXmlMode,
bool  nullLargeData = false 
)

Saves dataset row data into XDoc

If the compactXmlMode is true, the node would have fields presented as attributues. Otherwise, the fields are stored as subnodes.

Parameters
nodeXDoc node to fill in
compactXmlModeCompact XML flag
nullLargeDataSet text data longer than 256 bytes to null

◆ exportTo()

virtual void sptk::DataSource::exportTo ( xdoc::Node parentNode,
const String nodeName,
bool  compactXmlMode 
)
virtual

Saves data into XDoc

Opens the dataset, reads every row, and closes dataset. For every row in the dataset, creates the node with the name nodeName. If the compactXmlMode is true, the nodes would have fields presented as attributues. Otherwise, the fields are stored as subnodes.

Parameters
parentNodeXDoc node to add subnodes to
nodeNameName for subnodes
compactXmlModeCompact XML flag

◆ fieldCount()

virtual size_t sptk::DataSource::fieldCount ( ) const
pure virtual

Returns field count in the datasource.

Purely virtual. Should be implemented in derived class

Returns
field count

Implemented in sptk::Query, and sptk::MemoryDS.

◆ find()

virtual bool sptk::DataSource::find ( const String ,
const Variant  
)
inlinevirtual

Moves to the specified record position of the datasource. Implemented in derved class.

Reimplemented in sptk::MemoryDS.

◆ first()

virtual bool sptk::DataSource::first ( )
inlinevirtual

Moves to the first record of the datasource. Implemented in derved class.

Reimplemented in sptk::MemoryDS.

◆ last()

virtual bool sptk::DataSource::last ( )
inlinevirtual

Moves to the last record of the datasource. Implemented in derved class.

Reimplemented in sptk::MemoryDS.

◆ load()

bool sptk::DataSource::load ( )

Loads data into the datasource

◆ loadData()

virtual bool sptk::DataSource::loadData ( )
inlineprotectedvirtual

Loads datasource data. Should be implemented in derived class

Reimplemented in sptk::Query.

◆ next()

virtual bool sptk::DataSource::next ( )
inlinevirtual

Moves to the next record of the datasource. Implemented in derved class.

Reimplemented in sptk::Query, and sptk::MemoryDS.

◆ open()

virtual bool sptk::DataSource::open ( )
inlinevirtual

Opens the datasource. Implemented in derved class.

Reimplemented in sptk::Query, sptk::DirectoryDS, sptk::MemoryDS, and sptk::ImapDS.

◆ operator[]() [1/2]

virtual Field & sptk::DataSource::operator[] ( const String fieldName)
pure virtual

Field access by the field name, const version.

Purely virtual. Should be implemented in derived class

Parameters
fieldNameField name
Returns
field reference

Implemented in sptk::Query, and sptk::MemoryDS.

◆ operator[]() [2/2]

virtual Field & sptk::DataSource::operator[] ( size_t  fieldIndex)
pure virtual

Field access by the field index, non-const version

Purely virtual. Should be implemented in derived class

Parameters
fieldIndexField index
Returns
field reference

Implemented in sptk::Query, and sptk::MemoryDS.

◆ prior()

virtual bool sptk::DataSource::prior ( )
inlinevirtual

Moves to the prior record of the datasource. Implemented in derved class.

Reimplemented in sptk::MemoryDS.

◆ readField()

virtual bool sptk::DataSource::readField ( const char *  fieldName,
Variant fieldValue 
)
pure virtual

Reads the field by name from the datasource.

Purely virtual. Should be implemented in derived class

Parameters
fieldNameField name
fieldValueField value

Implemented in sptk::MemoryDS, and sptk::Query.

◆ recordCount()

virtual size_t sptk::DataSource::recordCount ( ) const
pure virtual

Returns record count in the datasource.

Purely virtual. Should be implemented in derived class

Returns
record count

Implemented in sptk::Query, and sptk::MemoryDS.

◆ save()

bool sptk::DataSource::save ( )

Saves data from the datasource

◆ saveData()

virtual bool sptk::DataSource::saveData ( )
inlineprotectedvirtual

Saves data from datasource. Should be implemented in derived class

Reimplemented in sptk::Query.

◆ writeField()

virtual bool sptk::DataSource::writeField ( const char *  fieldName,
const Variant fieldValue 
)
pure virtual

Writes the field by name from the datasource.

Purely virtual. Should be implemented in derived class

Parameters
fieldNameField name
fieldValueField value

Implemented in sptk::MemoryDS, and sptk::Query.


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

Fri Oct 14 2022 09:58:41: SPTK 5.4.1