An object of this class accesses tables and writes data records (Record) and binary files (eut::Blob) into text tables resp. the file system.
More...
#include <GloTableWriterInterface.h>
|
| TableWriterInterface () |
|
int | appendOnTable (std::streampos &rspFileIndexPosition, const std::string &rsTableName, unsigned long ulClassID, const std::string &rsDataRow) |
|
int | getFirstDeletedRecordItem (std::streampos &rspFileIndexPosition, unsigned long ulClassID) |
|
int | readLastMagicNumber (eut::UnsignedMagicNumber &rRetVal, const std::string &rsFileName) |
|
int | readLastObjCounter (unsigned long &rulObjCounter) |
|
int | readLastUL (unsigned long &rulRetVal, const std::string &rsFileName) |
|
void | removeForbiddenCharacters (std::string &rsField) const |
|
int | updateExternFiles (BaseRecordAttribute *pRecordAttribute, DATA_REFERENCE_INFO MethodInfo) |
|
int | updateInsert (Record *pInputUpdateRecord, EnInUd eInUd) |
|
int | updateObjectDataAttribute (BaseRecordAttribute *pRecordAttribute, ObjID ObjID) |
|
int | writeInTable (const std::string &rsTableName, const std::string &rsContents, const std::streampos spFileIndexPosition) |
|
int | writeLastMagicNumber (const eut::UnsignedMagicNumber &rVal, const std::string &rsFileName, bool bNew) |
|
int | writeLastObjCounter (const unsigned long &rulObjCounter, bool bNew) |
|
int | writeLastUL (const unsigned long &rulVal, const std::string &rsFileName, bool bNew) |
|
| TableInterface () |
|
int | openFile (std::fstream *&prFStream, const std::string &sFullFileName, std::ios_base::openmode OpenMode) |
|
An object of this class accesses tables and writes data records (Record) and binary files (eut::Blob) into text tables resp. the file system.
- Copyright
- © 2010 Helmut Jakoby
- Author
- Helmut Jakoby
◆ EnInUd
An enumeration to indicate whether a record in a table file should be newly inserted or overwritten.
Enumerator |
---|
eINSERT | Der Datensatz soll in die Tabellen-Datei neu eingefügt werden
|
eUPDATE | The record is to be overwritten in the table file
|
◆ TableWriterInterface() [1/3]
glo::TableWriterInterface::TableWriterInterface |
( |
| ) |
|
|
protected |
The default constructor is not available.
◆ TableWriterInterface() [2/3]
Constructor with parameter passing.
- Parameters
-
[in] | rScheme | Cannot be used without schema, will be copied. |
[in] | pRealIndexPool | Accelerates the access to records. |
- Exceptions
-
◆ ~TableWriterInterface()
virtual glo::TableWriterInterface::~TableWriterInterface |
( |
| ) |
|
|
virtual |
Destructor, all open table files are closed and the memory is cleaned up.
◆ TableWriterInterface() [3/3]
The copy constructor is not available.
◆ appendOnTable()
int glo::TableWriterInterface::appendOnTable |
( |
std::streampos & | rspFileIndexPosition, |
|
|
const std::string & | rsTableName, |
|
|
unsigned long | ulClassID, |
|
|
const std::string & | rsDataRow ) |
|
protected |
Writes a new record either at the end of the table or, if a deleted record exists, in its place.
- Parameters
-
[in,out] | rspFileIndexPosition | The position in the table file where the record was written (is the position of the object ID needed for the index). |
[in] | rsTableName | The complete name of the table file. |
[in] | ulClassID | The class ID, needed to determine the position of a possibly deleted data set from the TableInterface::m_pRealIndexPool. |
[in] | rsDataRow | The row with the data set attributes to be written to the table file. |
- Returns
- A return value < 0 indicates an error.
◆ deleteObjectData()
int glo::TableWriterInterface::deleteObjectData |
( |
Record * | pRecord, |
|
|
std::vector< TransactionIndexPool * > * | pTransactionIndexPoolVector = 0 ) |
Marks the passed record in the tables as deleted (ObjID == 0). External files are deleted if they exist.
Indexes are adjusted in the RealIndexPool
- Parameters
-
[in] | pRecord | The record to be deleted. |
[in] | pTransactionIndexPoolVector | If passed, then not only in the RealIndexPool but also in this TransactionIndexPools the indexes are updated |
- Returns
- A return value < 0 indicates an error.
◆ getFirstDeletedRecordItem()
int glo::TableWriterInterface::getFirstDeletedRecordItem |
( |
std::streampos & | rspFileIndexPosition, |
|
|
unsigned long | ulClassID ) |
|
protected |
Returns the position of a record in a table file of the class of the passed class ID, which has been deleted (from the TableInterface::m_pRealIndexPool).
- Parameters
-
[in,out] | rspFileIndexPosition | The position in the table file where a record was deleted. |
[in] | ulClassID | The class ID is needed to determine the position of a possibly deleted data set from the TableInterface::m_pRealIndexPool. |
◆ getNewObjID()
int glo::TableWriterInterface::getNewObjID |
( |
ObjID & | rObjID | ) |
|
Returns in passed ObjID a new unique object ID, without class ID.
- Parameters
-
[in,out] | rObjID | The object ID is set. |
- Returns
- A return value < 0 indicates an error.
◆ openTable()
virtual int glo::TableWriterInterface::openTable |
( |
const std::string & | sTableName | ) |
|
|
virtual |
Opens a table file and adds it to the list of opened table files if successful.
- Parameters
-
[in] | sTableName | The table file name. |
- Returns
- A return value < 0 indicates an error.
Implements glo::TableInterface.
◆ operator=()
The assignment operator is not available.
◆ readLastMagicNumber()
int glo::TableWriterInterface::readLastMagicNumber |
( |
eut::UnsignedMagicNumber & | rRetVal, |
|
|
const std::string & | rsFileName ) |
|
protected |
Reads an eut::UnsignedMagicNumber from a file with the passed name (the file with the passed name is expected in the data directory) .
- Parameters
-
- Returns
- A return value < 0 indicates an error.
◆ readLastObjCounter()
int glo::TableWriterInterface::readLastObjCounter |
( |
unsigned long & | rulObjCounter | ) |
|
|
protected |
◆ readLastUL()
int glo::TableWriterInterface::readLastUL |
( |
unsigned long & | rulRetVal, |
|
|
const std::string & | rsFileName ) |
|
protected |
Reads an unsigned long from a file with the passed name (the file with the passed name is expected in the data directory) .
- Parameters
-
[in,out] | rulRetVal | The value is set. |
[in,out] | rsFileName | The file from which rulRetVal is read. |
- Returns
- A return value < 0 indicates an error.
◆ removeForbiddenCharacters()
void glo::TableWriterInterface::removeForbiddenCharacters |
( |
std::string & | rsField | ) |
const |
|
protected |
Removes forbidden characters from passed string.
Two characters are always replaced with substitute characters.
The TableInterface::TableColumnDelimiter is reserved as separator for the individual table fields and is changed to a '^'.
A '\n' would destroy the text table due to the line break and is changed to a '_'.
- Parameters
-
[in] | rsField | The string which is checked. |
◆ storeObjectData()
int glo::TableWriterInterface::storeObjectData |
( |
Record * | pRecord, |
|
|
std::vector< TransactionIndexPool * > * | pTransactionIndexPoolVector = 0 ) |
Inserts or appends the record to/from the tables. External files are written if necessary.
- Parameters
-
[in] | pRecord | The data set to be written. |
[in] | pTransactionIndexPoolVector | If passed, not only in the RealIndexPool but also in this TransactionIndexPools the indexes are updated |
- Returns
- return == 1 Newly inserted in database
Return == 0 Changed in database
A return value < 0 indicates an error.
◆ updateExternFiles()
Deletes resp. rewrites or writes new an external file depending on the passed DATA_REFERENCE_INFO.
- Parameters
-
[in] | pRecordAttribute | Pointer to the record attribute whose data is to be written to an external file or whose external file is to be deleted. |
[in] | MethodInfo | The information how to handle the external file. |
- Returns
- A return value < 0 indicates an error.
◆ updateInsert()
int glo::TableWriterInterface::updateInsert |
( |
Record * | pInputUpdateRecord, |
|
|
EnInUd | eInUd ) |
|
protected |
Inserts or appends the record to/from the tables. External files are written if necessary.
- Parameters
-
[in] | pInputUpdateRecord | The data set to be written. |
[in] | eInUd | If eINSERT a record is rewritten, if eUPDATE the existing record is overwritten. |
- Returns
- A return value < 0 indicates an error.
◆ updateObjectDataAttribute()
Writes a single record attribute to a table file.
- Parameters
-
[in] | pRecordAttribute | Pointer to the record attribute to be written. |
[in] | ObjID | If a file name must be created, it will be generated from this object ID. |
- Returns
- A return value < 0 indicates an error.
◆ writeInTable()
int glo::TableWriterInterface::writeInTable |
( |
const std::string & | rsTableName, |
|
|
const std::string & | rsContents, |
|
|
const std::streampos | spFileIndexPosition ) |
|
protected |
Writes the passed table field (rsContents) into the table with the passed name (rsTableName) at the passed position (spFileIndexPosition).
This method is used to write a data set (see call of this method in TableWriterInterface::updateInsert (...) ) or to write a BaseRecordAttribute in a table row (see call in TableWriterInterface::updateObjectDataAttribute (...) ).
- Parameters
-
[in] | rsTableName | The complete name of the table file. |
[in] | rsContents | The formatted table field (it is assumed that the content has the correct length and all forbidden characters have been removed or replaced). |
[in] | spFileIndexPosition | The position of the table field in the table file. |
- Returns
- A return value < 0 indicates an error.
◆ writeLastMagicNumber()
int glo::TableWriterInterface::writeLastMagicNumber |
( |
const eut::UnsignedMagicNumber & | rVal, |
|
|
const std::string & | rsFileName, |
|
|
bool | bNew ) |
|
protected |
Writes an eut::UnsignedMagicNumber to a file with the passed name (the file with the passed name is expected in the data directory).
- Parameters
-
[in] | rVal | The value is written. |
[in,out] | rsFileName | The file in which rVal is written. |
[in] | bNew | If true, the file will be recreated, otherwise rVal will be overwritten in the file. |
- Returns
- A return value < 0 indicates an error.
◆ writeLastObjCounter()
int glo::TableWriterInterface::writeLastObjCounter |
( |
const unsigned long & | rulObjCounter, |
|
|
bool | bNew ) |
|
protected |
Writes an object counter (for ObjID::m_ulObjCounter) to the file "LastObjID" (the file "LastObjID" is located in the data directory).
Used by TableWriterInterface::getNewObjID(ObjID&)
- Parameters
-
[in] | rulObjCounter | The object counter. |
[in] | bNew | If true, the file will be recreated, otherwise the object counter in the file "LastObjID" will be overwritten. |
- Returns
- A return value < 0 indicates an error.
◆ writeLastUL()
int glo::TableWriterInterface::writeLastUL |
( |
const unsigned long & | rulVal, |
|
|
const std::string & | rsFileName, |
|
|
bool | bNew ) |
|
protected |
Writes an unsigned long to a file with the passed name (the file with the passed name is expected in the data directory).
- Parameters
-
[in] | rulVal | The value is written. |
[in,out] | rsFileName | The file in which rulVal is written. |
[in] | bNew | If true, the file will be recreated, otherwise rulVal will be overwritten in the file. |
- Returns
- A return value < 0 indicates an error.
◆ m_pTransactionIndexPoolVector
The documentation for this class was generated from the following file: