Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

DBF_Reader Class Reference

DBase-compatible database reader class. More...

#include <dbf.h>

Inheritance diagram for rs::dbf::DBF_Reader:

Inheritance graph
[legend]
Collaboration diagram for DBF_Reader:

Collaboration graph
[legend]
List of all members.

Public Methods

 DBF_Reader (const std::string &filename_)
virtual ~DBF_Reader ()
void dumpEntryDefinition (std::ostream &out) const
unsigned Fields () const
const std::string & FieldName (unsigned num) const
unsigned Records () const
bool nextRecord ()
bool gotoRecord (unsigned index)
std::string FieldContent (const std::string &fieldName, bool crop=true) const

Private Methods

void read_record (unsigned record_number)

Private Attributes

std::string filename
std::ifstream in
tm created
unsigned no_of_records
unsigned length_of_header
unsigned record_size
DBF_EntryDeclarationList entryTypes
unsigned current_record
char * current_record_data

Detailed Description

DBase-compatible database reader class.

Definition at line 87 of file dbf.h.


Constructor & Destructor Documentation

DBF_Reader const std::string &    filename_
 

Start reading an existing database

Parameters:
filename_  name of database file
The record pointer is positioned onto the first record.

See also:
gotoRecord , nextRecord
Exceptions:
rs::Error  if file not found, wrong filetype or database empty.

Definition at line 79 of file dbf.cpp.

virtual ~DBF_Reader   [inline, virtual]
 

Definition at line 122 of file dbf.h.


Member Function Documentation

void read_record unsigned    record_number [inline, private]
 

Definition at line 102 of file dbf.h.

Referenced by DBF_Reader::DBF_Reader().

void dumpEntryDefinition std::ostream &    out const
 

Dump entries defined in database (use this to detect which fields are declared in a database)

Parameters:
out  output stream to which the entries will be dumped

Definition at line 174 of file dbf.cpp.

unsigned Fields   const [inline]
 

Get number of fields in each record

Returns:
number of fields

Definition at line 131 of file dbf.h.

const string & FieldName unsigned    num const
 

Get name of field

Parameters:
num  number of field (range: 0..(Fields()-1))
Returns:
string containing name of field
Exceptions:
Error  if index out of range

Definition at line 194 of file dbf.cpp.

unsigned Records   const [inline]
 

Get number of records stored in database

Returns:
number of records

Definition at line 142 of file dbf.h.

bool nextRecord   [inline]
 

Proceed to next record

Returns:
true if successful

Definition at line 146 of file dbf.h.

bool gotoRecord unsigned    index [inline]
 

Goto specific record

Parameters:
index  index of record (range: 0..(Records()-1))
Returns:
true if successful

Definition at line 155 of file dbf.h.

string FieldContent const std::string &    fieldName,
bool    crop = true
const
 

Read content of current record

Parameters:
fieldName  name of field to read
See also:
FieldName (to get legal values for fieldName)
Parameters:
crop  if true -> crop leading and trailing spaces from result (defaults to true)
Returns:
string containing content
Exceptions:
Error  if fieldName is illegal

Definition at line 205 of file dbf.cpp.


Member Data Documentation

std::string filename [private]
 

Definition at line 89 of file dbf.h.

Referenced by DBF_Reader::DBF_Reader().

std::ifstream in [private]
 

Definition at line 90 of file dbf.h.

Referenced by DBF_Reader::DBF_Reader().

struct tm created [private]
 

Definition at line 92 of file dbf.h.

Referenced by DBF_Reader::DBF_Reader().

unsigned no_of_records [private]
 

Definition at line 93 of file dbf.h.

Referenced by DBF_Reader::DBF_Reader().

unsigned length_of_header [private]
 

Definition at line 94 of file dbf.h.

Referenced by DBF_Reader::DBF_Reader().

unsigned record_size [private]
 

Definition at line 95 of file dbf.h.

Referenced by DBF_Reader::DBF_Reader().

DBF_EntryDeclarationList entryTypes [private]
 

Definition at line 97 of file dbf.h.

Referenced by DBF_Reader::DBF_Reader(), DBF_Reader::dumpEntryDefinition(), DBF_Reader::FieldContent(), and DBF_Reader::FieldName().

unsigned current_record [private]
 

Definition at line 99 of file dbf.h.

Referenced by DBF_Reader::DBF_Reader().

char* current_record_data [private]
 

Definition at line 100 of file dbf.h.

Referenced by DBF_Reader::DBF_Reader(), and DBF_Reader::FieldContent().


The documentation for this class was generated from the following files:
Contact me in case of errors or questions.
This documentation is powered by Doxygen.
(C) 2000-2002 Doxygen