Open Inventor Reference
SoInput Class Reference

Used to read Inventor data files. More...

#include <Inventor/SoInput.h>

List of all members.

Public Member Functions

 SoInput ()
 Constructor and destructor.
 ~SoInput ()
 Constructor and destructor.
void setFilePointer (FILE *newFP)
 Sets file pointer to read from. Clears the stack of input files if necessary.
SbBool openFile (const char *fileName, SbBool okIfNotFound=FALSE)
 Opens named file, sets file pointer to result.
SbBool pushFile (const char *fileName)
 Opens named file, pushing the resulting file pointer onto the stack.
void closeFile ()
 Closes all files on stack opened with openFile() or pushFile().
SbBool isValidFile ()
 Returns TRUE if the currently open file is a valid Inventor file; that is, it begins with a valid Inventor header, or one that has been registered with SoDB::registerHeader.
FILE * getCurFile () const
 Returns a pointer to the current file, or NULL if reading from a buffer.
const char * getCurFileName () const
 Returns full name (including directory path) of current file, or NULL if reading from a buffer.
void setBuffer (void *bufPointer, size_t bufSize)
 Sets an in-memory buffer to read from, along with its size.
size_t getNumBytesRead () const
 Returns number of bytes read from buffer.
SbString getHeader ()
 Returns the header of the file being read.
float getIVVersion ()
 Returns the Inventor file version of the file being read (e.g.
SbBool isBinary ()
 Returns whether current file/buffer being read is binary.
SbBool get (char &c)
 Reads next character from current file/buffer.
SbBool getASCIIBuffer (char &c)
 Reads next ASCII character from current buffer.
SbBool getASCIIFile (char &c)
 Reads next ASCII character from current file.
SbBool readHex (uint32_t &l)
 Reads next ASCII format hex value from current file/buffer.
SbBool read (char &c)
 Reads item of particular type from current file pointer/buffer.
SbBool read (SbString &s)
SbBool read (SbName &n, SbBool validIdent=FALSE)
SbBool read (int &i)
SbBool read (unsigned int &i)
SbBool read (short &s)
SbBool read (unsigned short &s)
SbBool read (float &f)
 was ...
SbBool read (double &d)
SbBool readBinaryArray (unsigned char *c, int length)
SbBool readBinaryArray (int32_t *l, int length)
SbBool readBinaryArray (float *f, int length)
SbBool readBinaryArray (double *d, int length)
SbBool eof () const
 Returns TRUE if current file/buffer is at EOF.
 SoInput (SoInput *dictIn)
 Constructor and destructor.
void getLocationString (SbString &string) const
 Fills in passed string to contain description of current location in all open input files.
void putBack (char c)
 Puts a just-read character or string back in input stream/buffer.
void putBack (const char *string)
void addReference (const SbName &name, SoBase *base, SbBool addToGlobalDict=TRUE)
 Adds a reference to dictionary in current file.
void removeReference (const SbName &name)
 Removes a reference to dictionary in current file.
SoBasefindReference (const SbName &name) const
 Looks up a reference, returning the base pointer or NULL.

Static Public Member Functions

static void addDirectoryFirst (const char *dirName)
static void addDirectoryLast (const char *dirName)
static void addEnvDirectoriesFirst (const char *envVarName)
static void addEnvDirectoriesLast (const char *envVarName)
static void removeDirectory (const char *dirName)
 Removes named directory from the list.
static void clearDirectories ()
 Clears the list of directories (including the current directory).
static const SbStringListgetDirectories ()
 Returns the list of directories as an SbStringList.
static void init ()
 Init function sets up global directory list.

Friends

class SoBase
class SoDB

Detailed Description

This class is used by the SoDB reading routines when reading Inventor data files. It supports both ASCII (default) and binary Inventor formats. Users can also register additional valid file headers. When reading, SoInput skips over Inventor comments (from '#' to end of line) and can stack input files. When EOF is reached, the stack is popped. This class can also be used to read from a buffer in memory.

See Also
SoDB, SoOutput, SoTranReceiver

Definition at line 128 of file SoInput.h.


Constructor & Destructor Documentation

SoInput::SoInput ( )

The default SoInput reads from stdin. The destructor closes any files opened by the SoInput.

SoInput::~SoInput ( )

The default SoInput reads from stdin. The destructor closes any files opened by the SoInput.

SoInput::SoInput ( SoInput dictIn)

The default SoInput reads from stdin. The destructor closes any files opened by the SoInput.


Member Function Documentation

static void SoInput::addDirectoryFirst ( const char *  dirName) [static]
static void SoInput::addDirectoryLast ( const char *  dirName) [static]
static void SoInput::addEnvDirectoriesFirst ( const char *  envVarName) [static]
static void SoInput::addEnvDirectoriesLast ( const char *  envVarName) [static]
void SoInput::addReference ( const SbName name,
SoBase base,
SbBool  addToGlobalDict = TRUE 
)

This may also add a reference to the global dictionary if addToGlobalDict is TRUE (the default).

static void SoInput::clearDirectories ( ) [static]
void SoInput::closeFile ( )
SbBool SoInput::eof ( ) const
SoBase* SoInput::findReference ( const SbName name) const
SbBool SoInput::get ( char &  c)

Returns FALSE on EOF or error.

SbBool SoInput::getASCIIBuffer ( char &  c)

Returns FALSE on EOF or error.

SbBool SoInput::getASCIIFile ( char &  c)

Returns FALSE on EOF or error.

FILE* SoInput::getCurFile ( ) const
const char* SoInput::getCurFileName ( ) const
static const SbStringList& SoInput::getDirectories ( ) [static]
SbString SoInput::getHeader ( )
float SoInput::getIVVersion ( ) [inline]

2.1). If the file has a header registered through SoDB::registerHeader(), the returned version is the Inventor version registered with the header.

Definition at line 202 of file SoInput.h.

void SoInput::getLocationString ( SbString string) const
size_t SoInput::getNumBytesRead ( ) const

Returns 0 if not reading from a buffer.

static void SoInput::init ( ) [static]
SbBool SoInput::isBinary ( )
SbBool SoInput::isValidFile ( )
SbBool SoInput::openFile ( const char *  fileName,
SbBool  okIfNotFound = FALSE 
)

Clears the stack of input files if necessary. This returns FALSE on error; if okIfNotFound is FALSE (the default), this prints an error message if the file could not be found.

SbBool SoInput::pushFile ( const char *  fileName)

Returns FALSE on error.

void SoInput::putBack ( char  c)
void SoInput::putBack ( const char *  string)
SbBool SoInput::read ( SbString s)
SbBool SoInput::read ( double &  d)
SbBool SoInput::read ( int &  i)
SbBool SoInput::read ( float &  f)

C-api: name=readInt32 but typedef makes this redundant. SbBool read(int32_t &l); was ... C-api: name=readUInt32 but typedef makes this redundant. SbBool read(uint32_t &l);

SbBool SoInput::read ( unsigned short &  s)
SbBool SoInput::read ( short &  s)
SbBool SoInput::read ( char &  c)

All skip white space before reading and return FALSE on EOF or if item could not be read.

SbBool SoInput::read ( SbName n,
SbBool  validIdent = FALSE 
)
SbBool SoInput::read ( unsigned int &  i)
SbBool SoInput::readBinaryArray ( unsigned char *  c,
int  length 
)
SbBool SoInput::readBinaryArray ( int32_t l,
int  length 
)
SbBool SoInput::readBinaryArray ( float *  f,
int  length 
)
SbBool SoInput::readBinaryArray ( double *  d,
int  length 
)
SbBool SoInput::readHex ( uint32_t l)

Returns FALSE on EOF or error.

static void SoInput::removeDirectory ( const char *  dirName) [static]
void SoInput::removeReference ( const SbName name)

This may also remove a reference from the global dictionary.

void SoInput::setBuffer ( void *  bufPointer,
size_t  bufSize 
)
void SoInput::setFilePointer ( FILE *  newFP)

Friends And Related Function Documentation

friend class SoBase [friend]

Definition at line 363 of file SoInput.h.

friend class SoDB [friend]

Definition at line 364 of file SoInput.h.


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