Open Inventor Reference
SoOutput Class 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. More...
 
 ~SoOutput ()
 Constructor and destructor. More...
 
void setFilePointer (FILE *newFP)
 Sets file pointer to write to. More...
 
FILE * getFilePointer () const
 Returns the file pointer in use, or NULL if using a buffer. More...
 
bool openFile (const char *fileName)
 Opens named file, sets file pointer to result. This returns FALSE on error. More...
 
void closeFile ()
 Closes current file if opened with openFile(). More...
 
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. More...
 
bool getBuffer (void *&bufPointer, size_t &nBytes) const
 Returns pointer to memory buffer being written to and the new size of the buffer. More...
 
size_t getBufferSize () const
 The total number of bytes allocated to a memory buffer may be larger than the number of bytes written. More...
 
void resetBuffer ()
 Resets buffer for output again. Output starts over at beginning of buffer. More...
 
void setBinary (bool flag)
 Sets whether output should be ASCII (default) or binary. More...
 
bool isBinary () const
 Returns current state of binary flag. More...
 
void setHeaderString (const SbString &str)
 Sets the header for output files. More...
 
void resetHeaderString ()
 Resets the header for output files to be the default header. More...
 
void setFloatPrecision (int precision)
 Sets the precision for writing floating point numbers, i.e. More...
 
void setStage (Stage stage)
 Sets/returns current stage of operation of action. More...
 
Stage getStage () const
 
void incrementIndent (int amount=1)
 Increments/decrements indentation level by amount (default 1). More...
 
void decrementIndent (int amount=1)
 
void write (char c)
 Writes item of particular type to current file pointer/buffer. More...
 
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 ... More...
 
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. More...
 
 SoOutput (SoOutput *dictOut)
 Constructor and destructor. More...
 
void reset ()
 Resets things for writing to a new file or changing files. More...
 
void setCompact (bool flag)
 Prevents header and extra white space from being written. More...
 
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. More...
 
static SbString getDefaultBinaryHeader ()
 Returns the string representing the default binary header. More...
 

Friends

class SoBase
 
class SoDB
 

Detailed Description

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.

See Also
SoInput, SoWriteAction, SoTranSender

Definition at line 90 of file SoOutput.h.

Member Enumeration Documentation

◆ Annotations

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.

◆ Stage

Enumerator
COUNT_REFS 

Count write references.

WRITE 

Actually write to file.

Definition at line 168 of file SoOutput.h.

Constructor & Destructor Documentation

◆ SoOutput() [1/2]

SoOutput::SoOutput ( )

The default SoOutput writes to stdout. The destructor closes any files opened by the SoOutput.

◆ ~SoOutput()

SoOutput::~SoOutput ( )

The default SoOutput writes to stdout. The destructor closes any files opened by the SoOutput.

◆ SoOutput() [2/2]

SoOutput::SoOutput ( SoOutput dictOut)

The default SoOutput writes to stdout. The destructor closes any files opened by the SoOutput.

Member Function Documentation

◆ closeFile()

void SoOutput::closeFile ( )

◆ decrementIndent()

void SoOutput::decrementIndent ( int  amount = 1)
inline

Definition at line 181 of file SoOutput.h.

◆ getAnnotation()

uint32_t SoOutput::getAnnotation ( )
inline

Definition at line 231 of file SoOutput.h.

◆ getBuffer()

bool SoOutput::getBuffer ( void *&  bufPointer,
size_t &  nBytes 
) const

Returns FALSE if not writing into a buffer.

◆ getBufferSize()

size_t SoOutput::getBufferSize ( ) const
inline

This returns that total number.

Definition at line 128 of file SoOutput.h.

◆ getDefaultASCIIHeader()

static SbString SoOutput::getDefaultASCIIHeader ( )
static

◆ getDefaultBinaryHeader()

static SbString SoOutput::getDefaultBinaryHeader ( )
static

◆ getFilePointer()

FILE* SoOutput::getFilePointer ( ) const

◆ getStage()

Stage SoOutput::getStage ( ) const
inline

Definition at line 175 of file SoOutput.h.

◆ incrementIndent()

void SoOutput::incrementIndent ( int  amount = 1)
inline

Each indentation level is 4 spaces.

Definition at line 179 of file SoOutput.h.

◆ indent()

void SoOutput::indent ( )

◆ isBinary()

bool SoOutput::isBinary ( ) const
inline

Definition at line 137 of file SoOutput.h.

◆ isCompact()

bool SoOutput::isCompact ( ) const
inline

Definition at line 221 of file SoOutput.h.

◆ openFile()

bool SoOutput::openFile ( const char *  fileName)

◆ reset()

void SoOutput::reset ( )

◆ resetBuffer()

void SoOutput::resetBuffer ( )

◆ resetHeaderString()

void SoOutput::resetHeaderString ( )

◆ setAnnotation()

void SoOutput::setAnnotation ( uint32_t  bits)
inline

Definition at line 229 of file SoOutput.h.

◆ setBinary()

void SoOutput::setBinary ( bool  flag)

◆ setBuffer()

void SoOutput::setBuffer ( void *  bufPointer,
size_t  initSize,
SoOutputReallocCB reallocFunc,
int32_t  offset = 0 
)

If the reallocation function returns NULL, writing will be disabled.

◆ setCompact()

void SoOutput::setCompact ( bool  flag)
inline

Useful for producing compact strings of data.

Definition at line 220 of file SoOutput.h.

◆ setFilePointer()

void SoOutput::setFilePointer ( FILE *  newFP)

◆ setFloatPrecision()

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.

◆ setHeaderString()

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.

◆ setStage()

void SoOutput::setStage ( Stage  stage)
inline

Definition at line 174 of file SoOutput.h.

◆ write() [1/10]

void SoOutput::write ( char  c)

◆ write() [2/10]

void SoOutput::write ( const char *  s)

◆ write() [3/10]

void SoOutput::write ( const SbName n)

◆ write() [4/10]

void SoOutput::write ( const SbString s)

◆ write() [5/10]

void SoOutput::write ( double  d)

◆ write() [6/10]

void SoOutput::write ( float  f)

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);

◆ write() [7/10]

void SoOutput::write ( int  i)

◆ write() [8/10]

void SoOutput::write ( short  s)

◆ write() [9/10]

void SoOutput::write ( unsigned int  i)

◆ write() [10/10]

void SoOutput::write ( unsigned short  s)

◆ writeBinaryArray() [1/4]

void SoOutput::writeBinaryArray ( double *  d,
int  length 
)

◆ writeBinaryArray() [2/4]

void SoOutput::writeBinaryArray ( float *  f,
int  length 
)

◆ writeBinaryArray() [3/4]

void SoOutput::writeBinaryArray ( int32_t l,
int  length 
)

◆ writeBinaryArray() [4/4]

void SoOutput::writeBinaryArray ( unsigned char *  c,
int  length 
)

Friends And Related Function Documentation

◆ SoBase

friend class SoBase
friend

Definition at line 296 of file SoOutput.h.

◆ SoDB

friend class SoDB
friend

Definition at line 297 of file SoOutput.h.


The documentation for this class was generated from the following file: