Class for reading and writing og "typedstream" archives. More...
#include <cmtkTypedStream.h>
Public Member Functions | |
TypedStream () | |
Default constructor. | |
TypedStream (const char *filename, const TypedStreamMode mode) | |
Open constructor. | |
TypedStream (const char *dir, const char *archive, const TypedStreamMode mode) | |
Open constructor for separate path and archive names. | |
virtual | ~TypedStream () |
Destructor. | |
void | Open (const char *filename, const TypedStreamMode mode) |
Open another archive without constructing a new object. | |
void | Open (const char *dir, const char *archive, const TypedStreamMode mode) |
Open another archive in explicit directory. | |
void | Close () |
Close an open archive. | |
TypedStreamCondition | Seek (const char *section, const bool forward=false) |
Move to a particular section in the open archive. | |
TypedStreamCondition | Rewind () |
Rewind archive. | |
int | IsValid () |
Return validity of archive. | |
TypedStreamStatus | GetStatus () const |
Return status of last operation. | |
TypedStreamCondition | Begin (const char *section=NULL) |
Begin a section. | |
TypedStreamCondition | End (const bool flush=false) |
End a section. | |
bool | ReadBool (const char *key, const bool defaultValue=false, const bool forward=false) |
Read boolean value from an open archive. | |
TypedStreamCondition | ReadBoolArray (const char *key, byte *const array, const int size, const bool forward=false) |
Read array of boole values from an open archive. | |
int | ReadInt (const char *key, const int defaultValue=0, const bool forward=false) |
Read integer value from an open archive. | |
TypedStreamCondition | ReadIntArray (const char *key, int *const array, const int size, const bool forward=false) |
Read array of integer values from an open archive. | |
float | ReadFloat (const char *key, const float defaultValue=0, const bool forward=false) |
Read single-precision value from an open archive. | |
TypedStreamCondition | ReadFloatArray (const char *key, float *const array, const int size, const bool forward=false) |
Read array of single-precision values from an open archive. | |
double | ReadDouble (const char *key, const double defaultValue=0, const bool forward=false) |
Read double-precision value from an open archive. | |
TypedStreamCondition | ReadDoubleArray (const char *key, double *const array, const int size, const bool forward=false) |
Read array of double-precision values from an open archive. | |
Types::Coordinate | ReadCoordinate (const char *key, const Types::Coordinate defaultValue=0, const bool forward=false) |
Read double- or single precision value from an open archive. | |
Types::DataItem | ReadItem (const char *key, const Types::DataItem defaultValue=0, const bool forward=false) |
Read double- or single precision value from an open archive. | |
TypedStreamCondition | ReadCoordinateArray (const char *key, Types::Coordinate *const array, const int size, const bool forward=false) |
Read array of double- or single precision values from an open archive. | |
TypedStreamCondition | ReadItemArray (const char *key, Types::DataItem *const array, const int size, const bool forward=false) |
Read array of double- or single precision values from an open archive. | |
char * | ReadString (const char *key, const char *defaultValue=NULL, const bool forward=false) |
Read null-terminated string from an open archive. | |
TypedStreamCondition | WriteBool (const char *key, const bool value) |
Write a boolean value to an open archive. | |
TypedStreamCondition | WriteInt (const char *key, const int value) |
Write an integer value to an open archive. | |
TypedStreamCondition | WriteFloat (const char *key, const float value) |
Write a float value to an open archive. | |
TypedStreamCondition | WriteDouble (const char *key, const double value) |
Write a double precision float value to an open archive. | |
TypedStreamCondition | WriteCoordinate (const char *key, const Types::Coordinate value) |
Write an Types::Coordinate value to an open archive. | |
TypedStreamCondition | WriteItem (const char *key, const Types::DataItem value) |
Write an Types::DataItem value to an open archive. | |
TypedStreamCondition | WriteString (const char *key, const char *value) |
Write a string to an open archive. | |
TypedStreamCondition | WriteString (const char *key, const std::string &value) |
Write a string to an open archive. | |
TypedStreamCondition | WriteComment (const char *fmt,...) |
Write a formated comment to an open archive. | |
TypedStreamCondition | WriteComment (const int argc, const char *argv[]) |
Write string array as comment to an open archive. | |
TypedStreamCondition | WriteComment (int argc, char *argv[]) |
Write string array as comment to an open archive. | |
TypedStreamCondition | WriteIntArray (const char *key, const int *array, const int size, const int valuesPerLine=10) |
Write array of integer values to an open archive. | |
TypedStreamCondition | WriteBoolArray (const char *key, const byte *array, const int size, const int valuesPerLine=10) |
Write array of binay encoded boole values to an open archive. | |
TypedStreamCondition | WriteFloatArray (const char *key, const float *array, const int size, const int valuesPerLine=10) |
Write array of single-precision values to an open archive. | |
TypedStreamCondition | WriteDoubleArray (const char *key, const double *array, const int size, const int valuesPerLine=10) |
Write array of double-precision values to an open archive. | |
TypedStreamCondition | WriteCoordinateArray (const char *key, const Types::Coordinate *array, const int size, const int valuesPerLine=10) |
Write array of double- or single precision values to an open archive. | |
TypedStreamCondition | WriteItemArray (const char *key, const Types::DataItem *array, const int size, const int valuesPerLine=10) |
Write array of double- or single precision values to an open archive. | |
void | SetDebugFlag (const TypedStreamDebugFlag debugFlag=TYPEDSTREAM_DEBUG_ON) |
Set debugging flag. | |
Private Member Functions | |
void | InitInternals () |
Initialize internal data structures. | |
TypedStreamCondition | GenericReadArray (const char *key, const int type, void *const array, const int arraySize, const bool forward=false) |
Utility function: Read an array of arbitrary type. | |
TypedStreamToken | ReadLineToken () |
Read the next archive line to the buffer. | |
char * | StringSplit (char *s1) const |
Separate next token. | |
void | DebugOutput (const char *format,...) |
Output diagnostic message if debug flag is set. | |
Static Private Member Functions | |
static int | StringCmp (const char *s1, const char *s2) |
Compare two strings. | |
static const char * | GetTypedStreamIdent () |
Return the identifier for the generated archive format (version). | |
Private Attributes | |
FILE * | File |
Pointer to the actual file. | |
gzFile | GzFile |
Pointer to the compressed file in decompression mode. | |
TypedStreamMode | Mode |
Mode the current archive was opened with. | |
TypedStreamStatus | Status |
Holds the status of the last operation. | |
int | PrecisionFloat |
Number of significant digits for "float" fields. | |
int | PrecisionDouble |
Number of significant digits for "double" fields. | |
char | Buffer [TYPEDSTREAM_LIMIT_BUFFER] |
Buffer for the current line read from the archive. | |
char * | BufferKey |
Pointer to the "key" part of the line currently in Buffer. | |
char * | BufferValue |
Pointer to the "value" part of the line currently in Buffer. | |
std::stack< int > | LevelStack |
Stack of open section levels. | |
char * | SplitPosition |
Internal position pointer for "StringSplit()". | |
TypedStreamDebugFlag | DebugFlag |
Debug flag. |
Class for reading and writing og "typedstream" archives.
This class provides the same functions as DHZB's old, C-based "typedstream" library. The interface has been remodelled, especially primitive read functions have been made more convenient to use. Also, the implementation of certain features has been made clearer, eg. using an explicit stack to keep track of the currently open archive levels.
Definition at line 186 of file cmtkTypedStream.h.