Open Inventor Reference
|
Used to write Inventor data files. More...
#include <Inventor/SoOutput.h>
Public Types | |
enum | Stage { COUNT_REFS , WRITE } |
Enum that determines stage of operation of writing. More... | |
enum | Annotations { ADDRESSES = (1<<0) , REF_COUNTS = (1<<1) } |
Bit mask for various output annotations. More... | |
Public Member Functions | |
SoOutput () | |
Constructor and destructor. | |
~SoOutput () | |
Constructor and destructor. | |
void | setFilePointer (FILE *newFP) |
Sets file pointer to write to. | |
FILE * | getFilePointer () const |
Returns the file pointer in use, or NULL if using a buffer. | |
bool | openFile (const char *fileName) |
Opens named file, sets file pointer to result. This returns FALSE on error. | |
void | closeFile () |
Closes current file if opened with openFile(). | |
void | setBuffer (void *bufPointer, size_t initSize, SoOutputReallocCB *reallocFunc, int32_t offset=0) |
Sets up memory buffer to write to, initial size, reallocation function (which is called if there is not enough room in the buffer), and offset in the buffer at which to begin writing. | |
bool | getBuffer (void *&bufPointer, size_t &nBytes) const |
Returns pointer to memory buffer being written to and the new size of the buffer. | |
size_t | getBufferSize () const |
The total number of bytes allocated to a memory buffer may be larger than the number of bytes written. | |
void | resetBuffer () |
Resets buffer for output again. Output starts over at beginning of buffer. | |
void | setBinary (bool flag) |
Sets whether output should be ASCII (default) or binary. | |
bool | isBinary () const |
Returns current state of binary flag. | |
void | setHeaderString (const SbString &str) |
Sets the header for output files. | |
void | resetHeaderString () |
Resets the header for output files to be the default header. | |
void | setFloatPrecision (int precision) |
Sets the precision for writing floating point numbers, i.e. | |
void | setStage (Stage stage) |
Sets/returns current stage of operation of action. | |
Stage | getStage () const |
void | incrementIndent (int amount=1) |
Increments/decrements indentation level by amount (default 1). | |
void | decrementIndent (int amount=1) |
void | write (char c) |
Writes item of particular type to current file pointer/buffer. | |
void | write (const char *s) |
void | write (const SbString &s) |
void | write (const SbName &n) |
void | write (int i) |
void | write (unsigned int i) |
void | write (short s) |
void | write (unsigned short s) |
void | write (float f) |
was ... C-api: name=writeInt32 but typedef makes this redundant void write(int32_t l); was ... C-api: name=writeUInt32 but typedef makes this redundant void write(uint32_t l); | |
void | write (double d) |
void | writeBinaryArray (unsigned char *c, int length) |
void | writeBinaryArray (int32_t *l, int length) |
void | writeBinaryArray (float *f, int length) |
void | writeBinaryArray (double *d, int length) |
void | indent () |
Writes indentation to file/buffer based on current indentation level. | |
SoOutput (SoOutput *dictOut) | |
Constructor and destructor. | |
void | reset () |
Resets things for writing to a new file or changing files. | |
void | setCompact (bool flag) |
Prevents header and extra white space from being written. | |
bool | isCompact () const |
void | setAnnotation (uint32_t bits) |
uint32_t | getAnnotation () |
Static Public Member Functions | |
static SbString | getDefaultASCIIHeader () |
Returns the string representing the default ASCII header. | |
static SbString | getDefaultBinaryHeader () |
Returns the string representing the default binary header. | |
Friends | |
class | SoBase |
class | SoDB |
This class is used for writing Inventor data files. It supports both ASCII (default) and binary formats and provides some convenience functions for handling files. It can also write to a buffer in memory as well as to a file pointer.
A user-defined header can be specified for the output file. An instance of SoOutput is contained in an SoWriteAction; this is typically the only instance needed.
Definition at line 90 of file SoOutput.h.
Note that annotation is automatically disabled for non-compact or binary format.
Enumerator | |
---|---|
ADDRESSES | pointer values |
REF_COUNTS | node reference counts |
Definition at line 225 of file SoOutput.h.
enum SoOutput::Stage |
Enumerator | |
---|---|
COUNT_REFS | Count write references. |
WRITE | Actually write to file. |
Definition at line 168 of file SoOutput.h.
SoOutput::SoOutput | ( | ) |
SoOutput::~SoOutput | ( | ) |
SoOutput::SoOutput | ( | SoOutput * | dictOut | ) |
void SoOutput::closeFile | ( | ) |
|
inline |
Definition at line 181 of file SoOutput.h.
|
inline |
Definition at line 231 of file SoOutput.h.
bool SoOutput::getBuffer | ( | void *& | bufPointer, |
size_t & | nBytes | ||
) | const |
Returns FALSE if not writing into a buffer.
|
inline |
This returns that total number.
Definition at line 128 of file SoOutput.h.
|
static |
|
static |
FILE * SoOutput::getFilePointer | ( | ) | const |
|
inline |
Definition at line 175 of file SoOutput.h.
|
inline |
Each indentation level is 4 spaces.
Definition at line 179 of file SoOutput.h.
void SoOutput::indent | ( | ) |
|
inline |
Definition at line 137 of file SoOutput.h.
|
inline |
Definition at line 221 of file SoOutput.h.
bool SoOutput::openFile | ( | const char * | fileName | ) |
void SoOutput::reset | ( | ) |
void SoOutput::resetBuffer | ( | ) |
void SoOutput::resetHeaderString | ( | ) |
|
inline |
Definition at line 229 of file SoOutput.h.
void SoOutput::setBinary | ( | bool | flag | ) |
void SoOutput::setBuffer | ( | void * | bufPointer, |
size_t | initSize, | ||
SoOutputReallocCB * | reallocFunc, | ||
int32_t | offset = 0 |
||
) |
If the reallocation function returns NULL, writing will be disabled.
|
inline |
Useful for producing compact strings of data.
Definition at line 220 of file SoOutput.h.
void SoOutput::setFilePointer | ( | FILE * | newFP | ) |
void SoOutput::setFloatPrecision | ( | int | precision | ) |
the number of significant digits. Floating point numbers are written using %.xg format, where 'x' is the value of the precision argument.
void SoOutput::setHeaderString | ( | const SbString & | str | ) |
This is useful, for example, if you have a file format that is a superset of the Inventor file format and you want Inventor to read the files. It is highly recommend that in your new header you simply append to the header of the Inventor file format you are extending. For example, if a new file format is based on the Inventor 2.1 file format, register a header similar to: "#Inventor V2.1 ascii MY FILE FORMAT EXTENSION"
Then all Inventor 2.1 applications (and later) can read the file.
|
inline |
Definition at line 174 of file SoOutput.h.
void SoOutput::write | ( | char | c | ) |
void SoOutput::write | ( | const char * | s | ) |
void SoOutput::write | ( | const SbName & | n | ) |
void SoOutput::write | ( | const SbString & | s | ) |
void SoOutput::write | ( | double | d | ) |
void SoOutput::write | ( | float | f | ) |
void SoOutput::write | ( | int | i | ) |
void SoOutput::write | ( | short | s | ) |
void SoOutput::write | ( | unsigned int | i | ) |
void SoOutput::write | ( | unsigned short | s | ) |
void SoOutput::writeBinaryArray | ( | double * | d, |
int | length | ||
) |
void SoOutput::writeBinaryArray | ( | float * | f, |
int | length | ||
) |
void SoOutput::writeBinaryArray | ( | int32_t * | l, |
int | length | ||
) |
void SoOutput::writeBinaryArray | ( | unsigned char * | c, |
int | length | ||
) |
|
friend |
Definition at line 296 of file SoOutput.h.
|
friend |
Definition at line 297 of file SoOutput.h.