xoreos  0.0.5
Classes | Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
Common::FoxPro Class Reference

A database in FoxPro 2.0 format. More...

#include <foxpro.h>

Inheritance diagram for Common::FoxPro:
Inheritance graph
[legend]
Collaboration diagram for Common::FoxPro:
Collaboration graph
[legend]

Classes

struct  Field
 A field description. More...
 
struct  Record
 A record. More...
 

Public Types

enum  Type {
  kTypeDouble = 0x42, kTypeString = 0x43, kTypeDate = 0x44, kTypeFloat = 0x46,
  kTypeGeneral = 0x47, kTypeInteger = 0x49, kTypeBool = 0x4C, kTypeMemo = 0x4D,
  kTypeNumber = 0x4E, kTypePicture = 0x50, kTypeDateTime = 0x54, kTypeCurrency = 0x59
}
 A field type. More...
 

Public Member Functions

 FoxPro ()
 
 ~FoxPro ()
 
void load (SeekableReadStream *dbf, SeekableReadStream *cdx=0, SeekableReadStream *fpt=0)
 
void save (WriteStream *dbf, WriteStream *cdx=0, WriteStream *fpt=0) const
 
void getLastUpdate (uint16 &lastUpdateYear, uint8 &lastUpdateMonth, uint8 &lastUpdateDay) const
 
bool hasIndex () const
 
bool hasMemo () const
 
size_t getFieldCount () const
 
size_t getRecordCount () const
 
const std::vector< Field > & getFields () const
 
const std::vector< Record > & getRecords () const
 
UString getString (const Record &record, size_t field) const
 
int32 getInt (const Record &record, size_t field) const
 
bool getBool (const Record &record, size_t field) const
 
double getDouble (const Record &record, size_t field) const
 
void getDate (const Record &record, size_t field, uint16 &year, uint8 &month, uint8 &day)
 
SeekableReadStreamgetMemo (const Record &record, size_t field) const
 
void deleteRecord (size_t record)
 
size_t addFieldString (const UString &name, uint8 size)
 
size_t addFieldNumber (const UString &name, uint8 size, uint8 decimals)
 
size_t addFieldInt (const UString &name)
 
size_t addFieldBool (const UString &name)
 
size_t addFieldDate (const UString &name)
 
size_t addFieldMemo (const UString &name)
 
size_t addRecord ()
 
void setString (size_t record, size_t field, const UString &value)
 
void setInt (size_t record, size_t field, int32 value)
 
void setBool (size_t record, size_t field, bool value)
 
void setDouble (size_t record, size_t field, double value)
 
void setDate (size_t record, size_t field, uint16 year, uint8 month, uint8 day)
 
void setMemo (size_t record, size_t field, SeekableReadStream *value=0)
 

Private Member Functions

void loadHeader (SeekableReadStream &dbf, uint32 &recordSize, uint32 &recordCount, uint32 &firstRecordPos)
 
void loadFields (SeekableReadStream &dbf, uint32 recordSize)
 
void loadRecords (SeekableReadStream &dbf, uint32 recordSize, uint32 recordCount)
 
void loadMemos (SeekableReadStream &fpt)
 
void saveHeader (WriteStream &dbf) const
 
void saveFields (WriteStream &dbf) const
 
void saveRecords (WriteStream &dbf) const
 
void saveMemos (WriteStream &fpt) const
 
void addField (uint8 size)
 
void updateUpdate ()
 

Static Private Member Functions

static void checkName (const UString &name)
 
static bool getInt (const byte *data, size_t size, int32 &i)
 

Private Attributes

uint16 _lastUpdateYear
 
uint8 _lastUpdateMonth
 
uint8 _lastUpdateDay
 
bool _hasIndex
 
bool _hasMemo
 
std::vector< Field_fields
 
std::vector< Record_records
 
PtrList< byte, DeallocatorArray_pool
 
uint16 _memoBlockSize
 
PtrVector< byte, DeallocatorArray_memos
 

Detailed Description

A database in FoxPro 2.0 format.

Definition at line 41 of file foxpro.h.

Member Enumeration Documentation

◆ Type

A field type.

Enumerator
kTypeDouble 
kTypeString 
kTypeDate 
kTypeFloat 
kTypeGeneral 
kTypeInteger 
kTypeBool 
kTypeMemo 
kTypeNumber 
kTypePicture 
kTypeDateTime 
kTypeCurrency 

Definition at line 44 of file foxpro.h.

Constructor & Destructor Documentation

◆ FoxPro()

Common::FoxPro::FoxPro ( )

Definition at line 38 of file foxpro.cpp.

References updateUpdate().

Here is the call graph for this function:

◆ ~FoxPro()

Common::FoxPro::~FoxPro ( )

Definition at line 42 of file foxpro.cpp.

Member Function Documentation

◆ addField()

void Common::FoxPro::addField ( uint8  size)
private

Definition at line 683 of file foxpro.cpp.

References _pool, and _records.

Referenced by addFieldBool(), addFieldDate(), addFieldInt(), addFieldMemo(), addFieldNumber(), and addFieldString().

Here is the caller graph for this function:

◆ addFieldBool()

size_t Common::FoxPro::addFieldBool ( const UString name)

◆ addFieldDate()

size_t Common::FoxPro::addFieldDate ( const UString name)

◆ addFieldInt()

size_t Common::FoxPro::addFieldInt ( const UString name)

◆ addFieldMemo()

size_t Common::FoxPro::addFieldMemo ( const UString name)

◆ addFieldNumber()

size_t Common::FoxPro::addFieldNumber ( const UString name,
uint8  size,
uint8  decimals 
)

◆ addFieldString()

size_t Common::FoxPro::addFieldString ( const UString name,
uint8  size 
)

◆ addRecord()

size_t Common::FoxPro::addRecord ( )

Definition at line 699 of file foxpro.cpp.

References _fields, _pool, _records, Common::FoxPro::Record::deleted, Common::FoxPro::Record::fields, and updateUpdate().

Here is the call graph for this function:

◆ checkName()

void Common::FoxPro::checkName ( const UString name)
staticprivate

Definition at line 519 of file foxpro.cpp.

References Common::UString::begin(), Common::UString::end(), and Common::UString::isASCII().

Referenced by addFieldBool(), addFieldDate(), addFieldInt(), addFieldMemo(), addFieldNumber(), and addFieldString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ deleteRecord()

void Common::FoxPro::deleteRecord ( size_t  record)

Definition at line 507 of file foxpro.cpp.

References _records, and updateUpdate().

Here is the call graph for this function:

◆ getBool()

bool Common::FoxPro::getBool ( const Record record,
size_t  field 
) const

Definition at line 378 of file foxpro.cpp.

References _fields, Common::FoxPro::Record::fields, and kTypeBool.

◆ getDate()

void Common::FoxPro::getDate ( const Record record,
size_t  field,
uint16 year,
uint8 month,
uint8 day 
)

Definition at line 434 of file foxpro.cpp.

References _fields, Common::FoxPro::Record::fields, and kTypeDate.

◆ getDouble()

double Common::FoxPro::getDouble ( const Record record,
size_t  field 
) const

Definition at line 396 of file foxpro.cpp.

References _fields, convertIEEEDouble(), convertIEEEFloat(), Common::FoxPro::Record::fields, kTypeDouble, kTypeFloat, and kTypeNumber.

Here is the call graph for this function:

◆ getFieldCount()

size_t Common::FoxPro::getFieldCount ( ) const

Definition at line 321 of file foxpro.cpp.

References _fields.

◆ getFields()

const std::vector< FoxPro::Field > & Common::FoxPro::getFields ( ) const

Definition at line 329 of file foxpro.cpp.

References _fields.

◆ getInt() [1/2]

int32 Common::FoxPro::getInt ( const Record record,
size_t  field 
) const

Definition at line 354 of file foxpro.cpp.

References _fields, Common::FoxPro::Record::fields, kTypeInteger, and kTypeNumber.

Referenced by getMemo().

Here is the caller graph for this function:

◆ getInt() [2/2]

bool Common::FoxPro::getInt ( const byte data,
size_t  size,
int32 i 
)
staticprivate

Definition at line 902 of file foxpro.cpp.

◆ getLastUpdate()

void Common::FoxPro::getLastUpdate ( uint16 lastUpdateYear,
uint8 lastUpdateMonth,
uint8 lastUpdateDay 
) const

Definition at line 307 of file foxpro.cpp.

References _lastUpdateDay, _lastUpdateMonth, and _lastUpdateYear.

◆ getMemo()

SeekableReadStream * Common::FoxPro::getMemo ( const Record record,
size_t  field 
) const

◆ getRecordCount()

size_t Common::FoxPro::getRecordCount ( ) const

Definition at line 325 of file foxpro.cpp.

References _records.

◆ getRecords()

const std::vector< FoxPro::Record > & Common::FoxPro::getRecords ( ) const

Definition at line 333 of file foxpro.cpp.

References _records.

◆ getString()

UString Common::FoxPro::getString ( const Record record,
size_t  field 
) const

Definition at line 337 of file foxpro.cpp.

References _fields, Common::FoxPro::Record::fields, Common::kEncodingLatin9, kTypeString, Common::readStringFixed(), and Common::UString::trimRight().

Here is the call graph for this function:

◆ hasIndex()

bool Common::FoxPro::hasIndex ( ) const

Definition at line 313 of file foxpro.cpp.

References _hasIndex.

◆ hasMemo()

bool Common::FoxPro::hasMemo ( ) const

Definition at line 317 of file foxpro.cpp.

References _hasMemo.

◆ load()

void Common::FoxPro::load ( SeekableReadStream dbf,
SeekableReadStream cdx = 0,
SeekableReadStream fpt = 0 
)

Definition at line 45 of file foxpro.cpp.

References _hasIndex, _hasMemo, loadFields(), loadHeader(), loadMemos(), loadRecords(), and Common::SeekableReadStream::seek().

Here is the call graph for this function:

◆ loadFields()

void Common::FoxPro::loadFields ( SeekableReadStream dbf,
uint32  recordSize 
)
private

◆ loadHeader()

void Common::FoxPro::loadHeader ( SeekableReadStream dbf,
uint32 recordSize,
uint32 recordCount,
uint32 firstRecordPos 
)
private

Definition at line 74 of file foxpro.cpp.

References _hasIndex, _hasMemo, _lastUpdateDay, _lastUpdateMonth, _lastUpdateYear, Common::ReadStream::readByte(), Common::ReadStream::readUint16LE(), Common::ReadStream::readUint32LE(), and Common::SeekableReadStream::skip().

Referenced by load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadMemos()

void Common::FoxPro::loadMemos ( SeekableReadStream fpt)
private

Definition at line 175 of file foxpro.cpp.

References _memoBlockSize, _memos, Common::ReadStream::eos(), Common::ReadStream::read(), Common::ReadStream::readUint16BE(), and Common::SeekableReadStream::skip().

Referenced by load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadRecords()

void Common::FoxPro::loadRecords ( SeekableReadStream dbf,
uint32  recordSize,
uint32  recordCount 
)
private

Definition at line 143 of file foxpro.cpp.

References _fields, _pool, _records, Common::FoxPro::Record::deleted, Common::FoxPro::Record::fields, Common::kReadError, Common::ReadStream::read(), Common::ReadStream::readByte(), and status().

Referenced by load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ save()

void Common::FoxPro::save ( WriteStream dbf,
WriteStream cdx = 0,
WriteStream fpt = 0 
) const

Definition at line 193 of file foxpro.cpp.

References _fields, _hasIndex, _hasMemo, _records, Common::WriteStream::flush(), saveFields(), saveHeader(), saveMemos(), and saveRecords().

Here is the call graph for this function:

◆ saveFields()

void Common::FoxPro::saveFields ( WriteStream dbf) const
private

◆ saveHeader()

void Common::FoxPro::saveHeader ( WriteStream dbf) const
private

Definition at line 220 of file foxpro.cpp.

References _fields, _hasIndex, _hasMemo, _lastUpdateDay, _lastUpdateMonth, _lastUpdateYear, _records, Common::WriteStream::writeByte(), Common::WriteStream::writeUint16LE(), and Common::WriteStream::writeUint32LE().

Referenced by save().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveMemos()

void Common::FoxPro::saveMemos ( WriteStream fpt) const
private

Definition at line 294 of file foxpro.cpp.

References _memoBlockSize, _memos, Common::WriteStream::write(), Common::WriteStream::writeUint16BE(), and Common::WriteStream::writeUint32BE().

Referenced by save().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveRecords()

void Common::FoxPro::saveRecords ( WriteStream dbf) const
private

Definition at line 280 of file foxpro.cpp.

References _fields, _records, Common::FoxPro::Record::deleted, Common::FoxPro::Record::fields, Common::WriteStream::write(), and Common::WriteStream::writeByte().

Referenced by save().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setBool()

void Common::FoxPro::setBool ( size_t  record,
size_t  field,
bool  value 
)

Definition at line 774 of file foxpro.cpp.

References _fields, _records, Common::FoxPro::Record::fields, kTypeBool, Common::FoxPro::Field::size, Common::FoxPro::Field::type, and updateUpdate().

Here is the call graph for this function:

◆ setDate()

void Common::FoxPro::setDate ( size_t  record,
size_t  field,
uint16  year,
uint8  month,
uint8  day 
)

Definition at line 828 of file foxpro.cpp.

References _fields, _records, Common::FoxPro::Record::fields, kTypeDate, Common::FoxPro::Field::size, Common::FoxPro::Field::type, and updateUpdate().

Here is the call graph for this function:

◆ setDouble()

void Common::FoxPro::setDouble ( size_t  record,
size_t  field,
double  value 
)

◆ setInt()

void Common::FoxPro::setInt ( size_t  record,
size_t  field,
int32  value 
)

◆ setMemo()

void Common::FoxPro::setMemo ( size_t  record,
size_t  field,
SeekableReadStream value = 0 
)

◆ setString()

void Common::FoxPro::setString ( size_t  record,
size_t  field,
const UString value 
)

◆ updateUpdate()

void Common::FoxPro::updateUpdate ( )
private

Definition at line 914 of file foxpro.cpp.

References _lastUpdateDay, _lastUpdateMonth, _lastUpdateYear, Common::DateTime::getDate(), and Common::DateTime::kUTC.

Referenced by addFieldBool(), addFieldDate(), addFieldInt(), addFieldMemo(), addFieldNumber(), addFieldString(), addRecord(), deleteRecord(), FoxPro(), setBool(), setDate(), setDouble(), setInt(), setMemo(), and setString().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _fields

std::vector<Field> Common::FoxPro::_fields
private

◆ _hasIndex

bool Common::FoxPro::_hasIndex
private

Definition at line 134 of file foxpro.h.

Referenced by hasIndex(), load(), loadHeader(), save(), and saveHeader().

◆ _hasMemo

bool Common::FoxPro::_hasMemo
private

Definition at line 135 of file foxpro.h.

Referenced by addFieldMemo(), hasMemo(), load(), loadFields(), loadHeader(), save(), and saveHeader().

◆ _lastUpdateDay

uint8 Common::FoxPro::_lastUpdateDay
private

Definition at line 132 of file foxpro.h.

Referenced by getLastUpdate(), loadHeader(), saveHeader(), and updateUpdate().

◆ _lastUpdateMonth

uint8 Common::FoxPro::_lastUpdateMonth
private

Definition at line 131 of file foxpro.h.

Referenced by getLastUpdate(), loadHeader(), saveHeader(), and updateUpdate().

◆ _lastUpdateYear

uint16 Common::FoxPro::_lastUpdateYear
private

Definition at line 130 of file foxpro.h.

Referenced by getLastUpdate(), loadHeader(), saveHeader(), and updateUpdate().

◆ _memoBlockSize

uint16 Common::FoxPro::_memoBlockSize
private

Definition at line 142 of file foxpro.h.

Referenced by getMemo(), loadMemos(), saveMemos(), and setMemo().

◆ _memos

PtrVector<byte, DeallocatorArray> Common::FoxPro::_memos
private

Definition at line 143 of file foxpro.h.

Referenced by getMemo(), loadMemos(), saveMemos(), and setMemo().

◆ _pool

PtrList<byte, DeallocatorArray> Common::FoxPro::_pool
private

Definition at line 140 of file foxpro.h.

Referenced by addField(), addRecord(), and loadRecords().

◆ _records

std::vector<Record> Common::FoxPro::_records
private

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