xoreos
0.0.5
|
A database in FoxPro 2.0 format. More...
#include <foxpro.h>
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) |
SeekableReadStream * | getMemo (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 |
enum Common::FoxPro::Type |
Common::FoxPro::FoxPro | ( | ) |
Definition at line 38 of file foxpro.cpp.
References updateUpdate().
Common::FoxPro::~FoxPro | ( | ) |
Definition at line 42 of file foxpro.cpp.
|
private |
Definition at line 683 of file foxpro.cpp.
References _pool, and _records.
Referenced by addFieldBool(), addFieldDate(), addFieldInt(), addFieldMemo(), addFieldNumber(), and addFieldString().
size_t Common::FoxPro::addFieldBool | ( | const UString & | name | ) |
Definition at line 603 of file foxpro.cpp.
References _fields, addField(), Common::FoxPro::Field::autoIncNext, Common::FoxPro::Field::autoIncStep, checkName(), Common::FoxPro::Field::decimals, Common::FoxPro::Field::flags, kTypeBool, Common::FoxPro::Field::name, Common::FoxPro::Field::offset, Common::FoxPro::Field::size, Common::FoxPro::Field::type, and updateUpdate().
size_t Common::FoxPro::addFieldDate | ( | const UString & | name | ) |
Definition at line 629 of file foxpro.cpp.
References _fields, addField(), Common::FoxPro::Field::autoIncNext, Common::FoxPro::Field::autoIncStep, checkName(), Common::FoxPro::Field::decimals, Common::FoxPro::Field::flags, kTypeDate, Common::FoxPro::Field::name, Common::FoxPro::Field::offset, Common::FoxPro::Field::size, Common::FoxPro::Field::type, and updateUpdate().
size_t Common::FoxPro::addFieldInt | ( | const UString & | name | ) |
Definition at line 577 of file foxpro.cpp.
References _fields, addField(), Common::FoxPro::Field::autoIncNext, Common::FoxPro::Field::autoIncStep, checkName(), Common::FoxPro::Field::decimals, Common::FoxPro::Field::flags, kTypeInteger, Common::FoxPro::Field::name, Common::FoxPro::Field::offset, Common::FoxPro::Field::size, Common::FoxPro::Field::type, and updateUpdate().
size_t Common::FoxPro::addFieldMemo | ( | const UString & | name | ) |
Definition at line 655 of file foxpro.cpp.
References _fields, _hasMemo, addField(), Common::FoxPro::Field::autoIncNext, Common::FoxPro::Field::autoIncStep, checkName(), Common::FoxPro::Field::decimals, Common::FoxPro::Field::flags, kTypeMemo, Common::FoxPro::Field::name, Common::FoxPro::Field::offset, Common::FoxPro::Field::size, Common::FoxPro::Field::type, and updateUpdate().
Definition at line 551 of file foxpro.cpp.
References _fields, addField(), Common::FoxPro::Field::autoIncNext, Common::FoxPro::Field::autoIncStep, checkName(), Common::FoxPro::Field::decimals, Common::FoxPro::Field::flags, kTypeNumber, Common::FoxPro::Field::name, Common::FoxPro::Field::offset, Common::FoxPro::Field::size, Common::FoxPro::Field::type, and updateUpdate().
Definition at line 525 of file foxpro.cpp.
References _fields, addField(), Common::FoxPro::Field::autoIncNext, Common::FoxPro::Field::autoIncStep, checkName(), Common::FoxPro::Field::decimals, Common::FoxPro::Field::flags, kTypeString, Common::FoxPro::Field::name, Common::FoxPro::Field::offset, Common::FoxPro::Field::size, Common::FoxPro::Field::type, and updateUpdate().
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().
|
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().
void Common::FoxPro::deleteRecord | ( | size_t | record | ) |
Definition at line 507 of file foxpro.cpp.
References _records, and updateUpdate().
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.
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.
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.
size_t Common::FoxPro::getFieldCount | ( | ) | const |
Definition at line 321 of file foxpro.cpp.
References _fields.
const std::vector< FoxPro::Field > & Common::FoxPro::getFields | ( | ) | const |
Definition at line 329 of file foxpro.cpp.
References _fields.
Definition at line 354 of file foxpro.cpp.
References _fields, Common::FoxPro::Record::fields, kTypeInteger, and kTypeNumber.
Referenced by getMemo().
Definition at line 902 of file foxpro.cpp.
void Common::FoxPro::getLastUpdate | ( | uint16 & | lastUpdateYear, |
uint8 & | lastUpdateMonth, | ||
uint8 & | lastUpdateDay | ||
) | const |
Definition at line 307 of file foxpro.cpp.
References _lastUpdateDay, _lastUpdateMonth, and _lastUpdateYear.
SeekableReadStream * Common::FoxPro::getMemo | ( | const Record & | record, |
size_t | field | ||
) | const |
Definition at line 459 of file foxpro.cpp.
References _fields, _memoBlockSize, _memos, Common::FoxPro::Record::fields, Common::ScopedPtrBase< T, Deallocator >::get(), getInt(), kTypeMemo, and Common::ScopedPtrBase< T, Deallocator >::release().
size_t Common::FoxPro::getRecordCount | ( | ) | const |
Definition at line 325 of file foxpro.cpp.
References _records.
const std::vector< FoxPro::Record > & Common::FoxPro::getRecords | ( | ) | const |
Definition at line 333 of file foxpro.cpp.
References _records.
Definition at line 337 of file foxpro.cpp.
References _fields, Common::FoxPro::Record::fields, Common::kEncodingLatin9, kTypeString, Common::readStringFixed(), and Common::UString::trimRight().
bool Common::FoxPro::hasIndex | ( | ) | const |
Definition at line 313 of file foxpro.cpp.
References _hasIndex.
bool Common::FoxPro::hasMemo | ( | ) | const |
Definition at line 317 of file foxpro.cpp.
References _hasMemo.
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().
|
private |
Definition at line 105 of file foxpro.cpp.
References _fields, _hasMemo, Common::FoxPro::Field::autoIncNext, Common::FoxPro::Field::autoIncStep, Common::FoxPro::Field::decimals, Common::ReadStream::eos(), Common::FoxPro::Field::flags, Common::kEncodingASCII, Common::SeekableReadStream::kOriginCurrent, kTypeMemo, Common::FoxPro::Field::name, Common::FoxPro::Field::offset, Common::ReadStream::readByte(), Common::readStringFixed(), Common::ReadStream::readUint32LE(), Common::SeekableReadStream::seek(), Common::FoxPro::Field::size, Common::SeekableReadStream::skip(), and Common::FoxPro::Field::type.
Referenced by load().
|
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().
|
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().
|
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().
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().
|
private |
Definition at line 249 of file foxpro.cpp.
References _fields, Common::FoxPro::Field::autoIncNext, Common::FoxPro::Field::autoIncStep, Common::UString::c_str(), Common::FoxPro::Field::decimals, Common::FoxPro::Field::flags, Common::FoxPro::Field::name, Common::FoxPro::Field::offset, Common::FoxPro::Field::size, Common::FoxPro::Field::type, Common::WriteStream::write(), Common::WriteStream::writeByte(), and Common::WriteStream::writeUint32LE().
Referenced by save().
|
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().
|
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().
|
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().
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().
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().
void Common::FoxPro::setDouble | ( | size_t | record, |
size_t | field, | ||
double | value | ||
) |
Definition at line 793 of file foxpro.cpp.
References _fields, _records, convertIEEEDouble(), convertIEEEFloat(), Common::FoxPro::Field::decimals, Common::FoxPro::Record::fields, kTypeDouble, kTypeFloat, kTypeNumber, Common::FoxPro::Field::size, Common::FoxPro::Field::type, and updateUpdate().
void Common::FoxPro::setInt | ( | size_t | record, |
size_t | field, | ||
int32 | value | ||
) |
Definition at line 746 of file foxpro.cpp.
References _fields, _records, Common::FoxPro::Field::decimals, Common::FoxPro::Record::fields, kTypeInteger, kTypeNumber, Common::FoxPro::Field::size, Common::FoxPro::Field::type, and updateUpdate().
void Common::FoxPro::setMemo | ( | size_t | record, |
size_t | field, | ||
SeekableReadStream * | value = 0 |
||
) |
Definition at line 849 of file foxpro.cpp.
References _fields, _memoBlockSize, _memos, _records, Common::FoxPro::Field::decimals, Common::FoxPro::Record::fields, Common::kReadError, kTypeMemo, Common::ReadStream::read(), Common::SeekableReadStream::seek(), Common::FoxPro::Field::size, Common::SeekableReadStream::size(), Common::FoxPro::Field::type, and updateUpdate().
void Common::FoxPro::setString | ( | size_t | record, |
size_t | field, | ||
const UString & | value | ||
) |
Definition at line 724 of file foxpro.cpp.
References _fields, _records, Common::UString::c_str(), Common::FoxPro::Record::fields, kTypeString, Common::FoxPro::Field::size, Common::FoxPro::Field::type, and 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().
|
private |
Definition at line 137 of file foxpro.h.
Referenced by addFieldBool(), addFieldDate(), addFieldInt(), addFieldMemo(), addFieldNumber(), addFieldString(), addRecord(), getBool(), getDate(), getDouble(), getFieldCount(), getFields(), getInt(), getMemo(), getString(), loadFields(), loadRecords(), save(), saveFields(), saveHeader(), saveRecords(), setBool(), setDate(), setDouble(), setInt(), setMemo(), and setString().
|
private |
Definition at line 134 of file foxpro.h.
Referenced by hasIndex(), load(), loadHeader(), save(), and saveHeader().
|
private |
Definition at line 135 of file foxpro.h.
Referenced by addFieldMemo(), hasMemo(), load(), loadFields(), loadHeader(), save(), and saveHeader().
|
private |
Definition at line 132 of file foxpro.h.
Referenced by getLastUpdate(), loadHeader(), saveHeader(), and updateUpdate().
|
private |
Definition at line 131 of file foxpro.h.
Referenced by getLastUpdate(), loadHeader(), saveHeader(), and updateUpdate().
|
private |
Definition at line 130 of file foxpro.h.
Referenced by getLastUpdate(), loadHeader(), saveHeader(), and updateUpdate().
|
private |
Definition at line 142 of file foxpro.h.
Referenced by getMemo(), loadMemos(), saveMemos(), and setMemo().
|
private |
Definition at line 143 of file foxpro.h.
Referenced by getMemo(), loadMemos(), saveMemos(), and setMemo().
|
private |
Definition at line 140 of file foxpro.h.
Referenced by addField(), addRecord(), and loadRecords().
|
private |
Definition at line 138 of file foxpro.h.
Referenced by addField(), addRecord(), deleteRecord(), getRecordCount(), getRecords(), loadRecords(), save(), saveHeader(), saveRecords(), setBool(), setDate(), setDouble(), setInt(), setMemo(), and setString().