libdballe  6.8
Data Structures | Public Member Functions | Data Fields | Protected Member Functions
dballe::db::v6::Cursor Struct Referenceabstract

Structure used to build and execute a query, and to iterate through the results. More...

#include <cursor.h>

Inheritance diagram for dballe::db::v6::Cursor:
dballe::db::Cursor dballe::db::v6::CursorBest dballe::db::v6::CursorLinear dballe::db::v6::CursorData dballe::db::v6::CursorDataIDs dballe::db::v6::CursorStations dballe::db::v6::CursorSummary

Data Structures

struct  SQLRecord
 Query results from SQL output. More...
 

Public Member Functions

virtual dballe::DBget_db () const
 Get the database that created this cursor.
 
int remaining () const
 Get the number of rows still to be fetched. More...
 
virtual void query (const Record &query)=0
 Perform the query.
 
virtual bool next ()=0
 Get a new item from the results of a query. More...
 
virtual void discard_rest ()=0
 Discard the results that have not been read yet.
 
unsigned query_attrs (const AttrList &qcs, Record &attrs)
 Query attributes for the current variable.
 
virtual void attr_insert (const Record &attrs)
 Insert/overwrite new attributes for the current variable. More...
 
virtual void attr_remove (const AttrList &qcs)
 Delete attributes for the current variable. More...
 
virtual int get_station_id () const
 Get the station identifier.
 
virtual double get_lat () const
 Get the station latitude.
 
virtual double get_lon () const
 Get the station longitude.
 
virtual const char * get_ident (const char *def=0) const
 Get the station identifier, or NULL if missing.
 
virtual const char * get_rep_memo (const char *def=0) const
 Get the report name.
 
virtual Level get_level () const
 Get the level.
 
virtual Trange get_trange () const
 Get the level.
 
virtual void get_datetime (int(&dt)[6]) const
 Get the datetime.
 
virtual wreport::Varcode get_varcode () const
 Get the variable code.
 
virtual wreport::Var get_var () const
 Get the variable.
 
virtual int attr_reference_id () const
 Return an integer value that can be used to refer to the current variable for attribute access.
 
virtual unsigned test_iterate (FILE *dump=0)=0
 Iterate the cursor until the end, returning the number of items. More...
 
- Public Member Functions inherited from dballe::db::Cursor
virtual void to_record (Record &rec)=0
 Fill in a record with the contents of a dba_db_cursor. More...
 

Data Fields

v6::DBdb
 Database to operate on.
 
const unsigned int modifiers
 Modifier flags to enable special query behaviours.
 
DBALLE_SQL_C_SINT_TYPE count
 Number of results still to be fetched.
 
SQLRecord sqlrec
 Results written by fetch.
 

Protected Member Functions

 Cursor (v6::DB &db, unsigned int modifiers)
 Create a query cursor. More...
 
void to_record_pseudoana (Record &rec)
 
void to_record_repinfo (Record &rec)
 
void to_record_ltr (Record &rec)
 
void to_record_datetime (Record &rec)
 
void to_record_varcode (Record &rec)
 
int query_stations (db::Statement &stm, const Record &rec)
 
int query_data (db::Statement &stm, const Record &rec)
 
void add_station_info (Record &rec)
 Query extra station info and add it to rec.
 

Detailed Description

Structure used to build and execute a query, and to iterate through the results.

Constructor & Destructor Documentation

dballe::db::v6::Cursor::Cursor ( v6::DB db,
unsigned int  modifiers 
)
protected

Create a query cursor.

Parameters
wantedThe values wanted in output
modifiersOptional modifiers to ask for special query behaviours

Member Function Documentation

virtual void dballe::db::v6::Cursor::attr_insert ( const Record attrs)
virtual

Insert/overwrite new attributes for the current variable.

Parameters
attrsThe record with the attributes to be added

Implements dballe::db::Cursor.

virtual void dballe::db::v6::Cursor::attr_remove ( const AttrList &  qcs)
virtual

Delete attributes for the current variable.

Parameters
qcsArray of WMO codes of the attributes to delete. If empty, all attributes associated to id_data will be deleted.

Implements dballe::db::Cursor.

virtual bool dballe::db::v6::Cursor::next ( )
pure virtual

Get a new item from the results of a query.

Returns
true if a new record has been read, false if there is no more data to read

Implements dballe::db::Cursor.

Implemented in dballe::db::v6::CursorBest, and dballe::db::v6::CursorLinear.

int dballe::db::v6::Cursor::remaining ( ) const
virtual

Get the number of rows still to be fetched.

Returns
The number of rows still to be queried. The value is undefined if no query has been successfully peformed yet using this cursor.

Implements dballe::db::Cursor.

virtual unsigned dballe::db::v6::Cursor::test_iterate ( FILE *  dump = 0)
pure virtual

Iterate the cursor until the end, returning the number of items.

If dump is a FILE pointer, also dump the cursor values to it

Reimplemented from dballe::db::Cursor.

Implemented in dballe::db::v6::CursorBest, dballe::db::v6::CursorDataIDs, dballe::db::v6::CursorSummary, dballe::db::v6::CursorData, and dballe::db::v6::CursorStations.


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