C3D Toolkit
Kernel - 117950, Vision - 2.7.5.29
|
Stream buffer. More...
#include <io_buffer.h>
Public Member Functions | |
iobuf_Seq (uint16 clusterSize) | |
Constructor. | |
virtual | ~iobuf_Seq () |
Destructor. | |
void | Reserve (size_t n, bool addAdditionalSpace=true) |
< Reserve space for a given number of elements. More... | |
void | Flush () |
Free the whole memory. | |
void | HardFlush () |
Free the unnecessary memory. | |
void | Adjust () |
Add an element to the end of the array. | |
Cluster * | Add () |
Add a given element to the end of the array. | |
Cluster * | Add (const Cluster &e) |
Get the number of elements in array. | |
Cluster & | operator[] (size_t loc) const |
Access by index operator. More... | |
int | gc () |
Get the next byte from the buffer. | |
size_t | getn (void *, size_t) |
Get the next n bytes from the buffer elementwise. | |
size_t | getln (void *, size_t) |
Get the next n bytes from the buffer by copying the storage area. | |
int | pc (uint8 c) |
Get the next byte from the buffer but don't shift the pointer to the next one. More... | |
size_t | putn (const void *, size_t) |
Put the next n bytes to the buffer elementwise. | |
size_t | putln (const void *, size_t) |
Put the next n bytes to the buffer by copying the storage area. | |
void | advance () |
If current buffer exhausted, advance pointer to the next one. | |
bool | good () const |
Whether the buffer state is correct. | |
bool | eof () const |
Is the end of file reached? | |
uint32 | state () const |
Get the buffer state. | |
void | setState (io::state add) |
Add the buffer state. | |
void | clearState (io::state sub) |
Remove the buffer state. | |
io::pos | size () const |
Calculate the current file size. | |
io::pos | tell () const |
Returns the current position in the file. | |
void | lseek (size_t pos=SYS_MAX_T) |
Set current position in the buffer. | |
bool | attach (FileSpace &file, bool check=true) |
Attach the file to the buffer with or without checking. | |
virtual bool | open (FileSpace &file, uint8 om, const VersionContainer &, bool fullCheck=true) |
Open the file if it is one's own file. The flag fullCheck == false switches off excessive checks (for the sake of performance). | |
bool | openSys (uint8 om) |
Open the system file. | |
virtual void | close () |
Close the file. | |
virtual void | closeBuff () |
Close the buffer. | |
virtual FileSpace * | enterFileSpace (uint8) |
Set FileSpace with given index for writing (create if necessary). | |
virtual FileSpace * | enterFileSpace (const ClusterReference &, bool) |
Set position for for writing/reading by given ClusterReference. If saveCurr = true, save previous position. | |
virtual FileSpace * | enterFileSpace (const ClusterReference &, FileSpace *, bool) |
Set position for writing/reading by given FileSpace and ClusterReference. Warning: in this function, ClusterReference.clusterIndex should contain an index in array of cluster indices in FileSpace! If saveCurr = true, save previous position. | |
virtual FileSpace * | returnToPreviousFileSpace () |
Set previous FileSpace for writing/reading. | |
ClusterReference | getCurrentClusterPos () |
Get current position in the buffer. | |
FileSpace & | sysFile () |
Get access to the system file. | |
FileSpace * | openedFile () const |
Get access to the open file. | |
virtual size_t | DOSFileLen () const |
The storage data size (of the file on the disk). | |
virtual const TCHAR * | DOSFileName () const |
Storage name (of file on the disk). | |
bool | fresh () const |
Is the buffer fresh? | |
void | fresh (bool f) |
Set the state of buffer freshness. | |
bool | modified () const |
Is the buffer modified? | |
void | modified (bool m) |
Set the state of modified buffer. | |
uint8 | mode () const |
Get the buffer mode. | |
void | mode (uint8 m) |
Set the buffer mode. | |
bool | IsInMode () const |
Is in the reading mode? | |
bool | IsOutMode () const |
Is in the writing mode? | |
bool | IsInOrOutMode () const |
Is in the reading or writing mode? | |
bool | deleteIfEmpty () const |
Is the empty file to be deleted? | |
void | deleteIfEmpty (bool s) |
Set the flag of deleting the empty file. | |
bool | deleteOnClose () const |
Is the file to be deleted while closing the buffer? | |
void | deleteOnClose (bool s) |
Set the flag of deleting the file while closing the buffer. | |
void | SetVersionsByStorage () |
Set the current version to be equal to the storage version. | |
VERSION | MathVersion () const |
Return the main version (of the mathematical kernel). | |
VERSION | AppVersion (size_t ind=-1) const |
Return the additional version (of the target application). | |
const VersionContainer & | GetVersionsContainer () const |
Get the buffer versions. | |
VERSION | GetStorageVersion () |
Get the storage version. | |
VERSION | GetFormatVersion () const |
Get the format version. | |
void | SetFormatVersion (VERSION version) |
Set the format version. | |
Protected Member Functions | |
int | underflow () |
Called when the whole buffer are read, but it is necessary to continue reading. | |
int | overflow (uint8 ch) |
Called when the buffer is full but it is necessary to continue writing. | |
virtual int | setup ()=0 |
Set the next buffer. | |
virtual int | flush ()=0 |
Flush the buffer. | |
void | checkEof () |
Set the end of file if necessary. | |
size_t | avail () const |
Get the number of unprocessed bytes in the buffer. | |
size_t | waiting () const |
Get the number of processed bytes in the buffer. | |
bool | mine (FileSpace &) |
Check if the file is mine. | |
void | SetVersionsContainer (const VersionContainer &vers) |
Set the version of open file. | |
VERSION | SetStorageVersion (VERSION) |
Set the storage version. | |
Protected Attributes | |
uint8 * | base |
Pointer to the beginning of the buffer. | |
uint8 * | ptr |
Pointer to the next byte. | |
uint8 * | end |
Pointer to the end of the file. | |
VERSION | storageVers |
The storage version (must be before 'curFileVers'). | |
VersionContainer | curFileVers |
Version of the current open file (stream). | |
VERSION | formatVersion |
The format version. | |
FileSpace | sys |
System file. | |
PArray< FileSpace > | files |
List of files contained in iobuf_Seq (the first element is the address of 'sys'). | |
FileSpace * | curr |
Current open file (stream). | |
size_t | part |
Current cluster in the current open file. | |
uint16 | clusterSize |
Cluster size. | |
uint8 | bufferMode |
Buffer mode. | |
uint8 | curFileMode |
Mode of opening the current file. | |
bool | modifiedFlag |
The buffer has been modified. | |
bool | freshFlag |
Is the buffer fresh. | |
Friends | |
class | tape |
Stream buffer.
Stream buffer - the base class.
Buffer iobuf_Seq and its descendants are used for read and write operations in the interest of the stream (class tape).
Classes iobuf_Seq, tape, Catalog and their descendants should be considered together.
Terminology:
Function flush() - flush the buffer. Called before getting the next cluster. Do nothing while reading. When writing, when working with the disk, saves the previos cluster on the disk, and, when working with the memory, stores the size of the last filled cluster.
Read operations are performed inside the file which is open at the moment, no read after end of the file.
void iobuf_Seq::Reserve | ( | size_t | n, |
bool | addAdditionalSpace = true |
||
) |
< Reserve space for a given number of elements.
Set the number of elements to null.
Cluster& iobuf_Seq::operator[] | ( | size_t | loc | ) | const |
Access by index operator.
Reserve space for a given number of FileSpace.
int iobuf_Seq::pc | ( | uint8 | c | ) |
Get the next byte from the buffer but don't shift the pointer to the next one.
Put byte to the buffer.