Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

SoOutput Class Reference

The SoOutput class is an abstraction of an output stream. More...

#include <Inventor/SoOutput.h>

List of all members.

Public Types

enum  Stage { COUNT_REFS, WRITE }
enum  Annotations { ADDRESSES = 0x01, REF_COUNTS = 0x02 }

Public Methods

 SoOutput (void)
 SoOutput (SoOutput *dictOut)
virtual ~SoOutput ()
virtual void setFilePointer (FILE *newFP)
virtual FILE * getFilePointer (void) const
virtual SbBool openFile (const char *const fileName)
virtual void closeFile (void)
virtual void setBuffer (void *bufPointer, size_t initSize, SoOutputReallocCB *reallocFunc, int32_t offset=0)
virtual SbBool getBuffer (void *&bufPointer, size_t &nBytes) const
virtual size_t getBufferSize (void) const
virtual void resetBuffer (void)
virtual void setBinary (const SbBool flag)
virtual SbBool isBinary (void) const
virtual void setHeaderString (const SbString &str)
virtual void resetHeaderString (void)
virtual void setFloatPrecision (const int precision)
void setStage (Stage stage)
Stage getStage (void) const
void incrementIndent (const int levels=1)
void decrementIndent (const int levels=1)
virtual void write (const char c)
virtual void write (const char *s)
virtual void write (const SbString &s)
virtual void write (const SbName &n)
virtual void write (const int i)
virtual void write (const unsigned int i)
virtual void write (const short s)
virtual void write (const unsigned short s)
virtual void write (const float f)
virtual void write (const double d)
virtual void writeBinaryArray (const unsigned char *c, const int length)
virtual void writeBinaryArray (const int32_t *const l, const int length)
virtual void writeBinaryArray (const float *const f, const int length)
virtual void writeBinaryArray (const double *const d, const int length)
virtual void indent (void)
virtual void reset (void)
void setCompact (SbBool flag)
SbBool isCompact (void) const
void setAnnotation (uint32_t bits)
uint32_t getAnnotation (void)
int addReference (const SoBase *base)
int findReference (const SoBase *base) const

Static Public Methods

SbString getDefaultASCIIHeader (void)
SbString getDefaultBinaryHeader (void)

Protected Methods

SbBool isToBuffer (void) const
size_t bytesInBuf (void) const
SbBool makeRoomInBuf (size_t nBytes)
void convertShort (short s, char *to)
void convertInt32 (int32_t l, char *to)
void convertFloat (float f, char *to)
void convertDouble (double d, char *to)
void convertShortArray (short *from, char *to, int len)
void convertInt32Array (int32_t *from, char *to, int len)
void convertFloatArray (float *from, char *to, int len)
void convertDoubleArray (double *from, char *to, int len)

Static Protected Methods

SbString padHeader (const SbString &inString)

Protected Attributes

SbBool wroteHeader


Detailed Description

The SoOutput class is an abstraction of an output stream.

SoOutput offers the ability to write basic types to a file or a memory buffer in either ASCII or binary format.

See also:
SoInput


Member Enumeration Documentation

enum SoOutput::Stage
 

SoOutput::WRITE Signifies that actual data export should take place during this pass.

enum SoOutput::Annotations
 

SoOutput::REF_COUNTS Annotate output with reference counts of the objects written.


Constructor & Destructor Documentation

SoOutput::SoOutput void
 

The default constructor makes an SoOutput instance which will write to the standard output.

See also:
setFilePointer(), openFile(), setBuffer()

SoOutput::SoOutput SoOutput * dictOut
 

Constructs an SoOutput which has a copy of the reference SbDict instance from dictOut.

SoOutput::~SoOutput void [virtual]
 

Destructor.


Member Function Documentation

void SoOutput::setFilePointer FILE * newFP [virtual]
 

Set up a new file pointer which we will write to.

Important note: do not use this method when the Coin library has been compiled as an MSWindows DLL, as passing FILE* instances back or forth to DLLs is dangerous and will most likely cause a crash. This is an intrinsic limitation for MSWindows DLLs.

See also:
openFile(), setBuffer(), getFilePointer()

FILE * SoOutput::getFilePointer void const [virtual]
 

Returns the current filepointer. If we're writing to a memory buffer, NULL is returned.

Important note: do not use this method when the Coin library has been compiled as an MSWindows DLL, as passing FILE* instances back or forth to DLLs is dangerous and will most likely cause a crash. This is an intrinsic limitation for MSWindows DLLs.

See also:
setFilePointer()

SbBool SoOutput::openFile const char *const fileName [virtual]
 

Opens a file for writing. If the file can not be opened or is not writeable, FALSE will be returned.

Files opened by this method will automatically be closed if the user supplies another filepointer, another filename for writing, or if the SoOutput instance is deleted.

See also:
setFilePointer(), setBuffer(), closeFile()

void SoOutput::closeFile void [virtual]
 

Closes the currently opened file, but only if the file was passed to SoOutput through the openFile() method.

See also:
openFile()

void SoOutput::setBuffer void * bufPointer,
size_t initSize,
SoOutputReallocCB * reallocFunc,
int32_t offset = 0
[virtual]
 

Sets up a memory buffer of size initSize for writing. Writing will start at bufPointer + offset.

If the buffer is filled up, reallocFunc is called to get more memory. If reallocFunc returns NULL, further writing is disabled.

Important note: remember that the resultant memory buffer after write operations have completed may reside somewhere else in memory than on bufPointer if reallocFunc is set. It is a good idea to make it a habit to always use getBuffer() to retrieve the memory buffer pointer after write operations.

See also:
getBuffer(), getBufferSize(), resetBuffer()

SbBool SoOutput::getBuffer void *& bufPointer,
size_t & nBytes
const [virtual]
 

Returns the current buffer in bufPointer and the current write position of the buffer in nBytes. If we're writing into a file and not a memory buffer, FALSE is returned and the other return values will be undefined.

See also:
getBufferSize()

size_t SoOutput::getBufferSize void const [virtual]
 

Returns total size of memory buffer.

See also:
getBuffer()

void SoOutput::resetBuffer void [virtual]
 

Reset the memory buffer write pointer back to the beginning of the buffer.

void SoOutput::setBinary const SbBool flag [virtual]
 

Set whether or not to write the output as a binary stream.

See also:
isBinary()

SbBool SoOutput::isBinary void const [virtual]
 

Returns a flag which indicates whether or not we're writing the output as a binary stream.

See also:
setBinary()

void SoOutput::setHeaderString const SbString & str [virtual]
 

Set the output file header string.

See also:
resetHeaderString(), getDefaultASCIIHeader(), getDefaultBinaryHeader()

void SoOutput::resetHeaderString void [virtual]
 

Reset the header string to the default one.

See also:
setHeaderString(), getDefaultASCIIHeader(), getDefaultBinaryHeader()

void SoOutput::setFloatPrecision const int precision [virtual]
 

Set the precision used when writing floating point numbers to ASCII files.

void SoOutput::setStage Stage stage
 

Sets an indicator on the current stage. This is necessary to do as writing has to be done in multiple stages to account for the export of references/connections within the scene graphs.

This method is basically just used from within SoWriteAction.

See also:
getStage()

SoOutput::Stage SoOutput::getStage void const
 

Returns an indicator on the current write stage. Writing is done in two passes, one to count and check connections, one to do the actual ascii or binary export of data.

You should not need to use this method, as it is meant for internal purposes in Coin.

See also:
setStage()

void SoOutput::incrementIndent const int levels = 1
 

Increase indentation level in the file.

See also:
decrementIndent(), indent()

void SoOutput::decrementIndent const int levels = 1
 

Decrease indentation level in the file.

See also:
incrementIndent(), indent()

void SoOutput::write const char c [virtual]
 

Write the character in c.

For binary write, the character plus 3 padding zero characters will be written.

void SoOutput::write const char * s [virtual]
 

Write the character string pointed to by s.

For binary write, a 4-byte MSB-ordered integer with the string length, plus the string plus padding zero characters to get on a 4-byte boundary (if necessary) will be written.

void SoOutput::write const SbString & s [virtual]
 

Write the character string in s. The string will be written with apostrophes. Cast SbString to char * to write without apostrophes.

If we are supposed to write in binary format, no apostrophes will be added, and writing will be done in the exact same manner as with SoOutput::write(const char * s).

void SoOutput::write const SbName & n [virtual]
 

Write the character string in n. The name will be enclosed by apostrophes. If you want to write an SbName instance without the apostrophes, cast the argument to a char *.

If we are supposed to write in binary format, no apostrophes will be added, and writing will be done in the exact same manner as with SoOutput::write(const char * s).

void SoOutput::write const int i [virtual]
 

Write i as a character string, or as an architecture independent binary pattern if the setBinary() flag is activated.

void SoOutput::write const unsigned int i [virtual]
 

Write i as a character string, or as an architecture independent binary pattern if the setBinary() flag is activated.

void SoOutput::write const short s [virtual]
 

Write s as a character string, or as an architecture independent binary pattern if the setBinary() flag is activated.

void SoOutput::write const unsigned short s [virtual]
 

Write s as a character string, or as an architecture independent binary pattern if the setBinary() flag is activated. If we're writing in ASCII format, the value will be written in base 16 (hexadecimal).

void SoOutput::write const float f [virtual]
 

Write f as a character string.

void SoOutput::write const double d [virtual]
 

Write d as a character string.

void SoOutput::writeBinaryArray const unsigned char * constc,
const int length
[virtual]
 

Write the given number of bytes to either a file or a memory buffer in binary format.

void SoOutput::writeBinaryArray const int32_t *const l,
const int length
[virtual]
 

Write an length array of int32_t values in binary format.

void SoOutput::writeBinaryArray const float *const f,
const int length
[virtual]
 

Write an array of float values in binary format.

void SoOutput::writeBinaryArray const double *const d,
const int length
[virtual]
 

Write an array of double values in binary format.

void SoOutput::indent void [virtual]
 

Call this method after writing a newline to a file to indent the next line to the correct position.

See also:
incrementIndent(), decrementIndent()

void SoOutput::reset void [virtual]
 

Reset all value and make ready for using another filepointer or buffer.

void SoOutput::setCompact SbBool flag
 

Set up the output to be more compact than with the default write routines.

SbBool SoOutput::isCompact void const
 

Returns whether or not the write routines tries to compact the data when writing it (i.e. using less whitespace, etc).

Note that "compact" in this sense does not mean "bitwise compression", as it could easily be mistaken for.

void SoOutput::setAnnotation uint32_t bits
 

Set up annotation of different aspects of the output data. This is not useful for much else than debugging purposes, I s'pose.

uint32_t SoOutput::getAnnotation void
 

Returns the current annotation debug bitflag settings.

SbString SoOutput::getDefaultASCIIHeader void [static]
 

Return the default header string written to ASCII files.

See also:
setHeaderString(), resetHeaderString(), getDefaultBinaryHeader()

SbString SoOutput::getDefaultBinaryHeader void [static]
 

Return the default header string written to binary files.

See also:
setHeaderString(), resetHeaderString(), getDefaultASCIIHeader()

int SoOutput::addReference const SoBase * base
 

Makes a unique id for base and adds a mapping into our dictionary.

int SoOutput::findReference const SoBase * base const
 

Returns the unique identifier for base.

SbBool SoOutput::isToBuffer void const [protected]
 

Returns TRUE of we're set up to write to a memory buffer.

size_t SoOutput::bytesInBuf void const [protected]
 

Returns number of bytes written to file or pushed into memory buffer.

SbBool SoOutput::makeRoomInBuf size_t bytes [protected]
 

Check that the current memory buffer has enough space to contain the given number of bytes needed for the next write operation.

Returns FALSE if there's not enough space left, otherwise TRUE.

Note that there will automatically be made an attempt at allocating more memory if the realloction callback function argument of setBuffer() was not NULL.

void SoOutput::convertShort short s,
char * to
[protected]
 

Convert the short integer in s to most-significant-byte first format and put the resulting bytes sequentially at to.

See also:
SoInput::convertShort()

void SoOutput::convertInt32 int32_t l,
char * to
[protected]
 

Convert the 32-bit integer in l to most-significant-byte first format and put the resulting bytes sequentially at to.

See also:
SoInput::convertInt32()

void SoOutput::convertFloat float f,
char * to
[protected]
 

Convert the single-precision floating point number in f to most-significant-byte first format and put the resulting bytes sequentially at to.

See also:
SoInput::convertFloat()

void SoOutput::convertDouble double d,
char * to
[protected]
 

Convert the double-precision floating point number in d to most-significant-byte first format and put the resulting bytes sequentially at to.

See also:
SoInput::convertDouble()

void SoOutput::convertShortArray short * from,
char * to,
int len
[protected]
 

Convert len short integer values from the array at from into the array at to from native host format to network independent format (i.e. most significant byte first).

void SoOutput::convertInt32Array int32_t * from,
char * to,
int len
[protected]
 

Convert len 32-bit integer values from the array at from into the array at to from native host format to network independent format (i.e. most significant byte first).

void SoOutput::convertFloatArray float * from,
char * to,
int len
[protected]
 

Convert len single-precision floating point values from the array at from into the array at to from native host format to network independent format (i.e. most significant byte first).

void SoOutput::convertDoubleArray double * from,
char * to,
int len
[protected]
 

Convert len double-precision floating point values from the array at from into the array at to from native host format to network independent format (i.e. most significant byte first).

SbString SoOutput::padHeader const SbString & inString [static, protected]
 

Pads the header we're writing so it contains the correct amount of bytes for the alignment of the following binary writes.


Member Data Documentation

SbBool SoOutput::wroteHeader [protected]
 

Indicates whether or not the file format header has been written out. As long as this is FALSE, the header will be written once upon the first invocation of any write method in the class.


The documentation for this class was generated from the following files:
Generated at Tue Mar 5 03:31:28 2002 for Coin by doxygen1.2.9 written by Dimitri van Heesch, © 1997-2001