Open Inventor Reference
SoInput Class Reference

Used to read Inventor data files. More...

#include <Inventor/SoInput.h>

Public Member Functions

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

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. More...
 
static void clearDirectories ()
 Clears the list of directories (including the current directory). More...
 
static const SbStringListgetDirectories ()
 Returns the list of directories as an SbStringList. More...
 
static void init ()
 Init function sets up global directory list. More...
 

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() [1/2]

SoInput::SoInput ( )

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

◆ ~SoInput()

SoInput::~SoInput ( )

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

◆ SoInput() [2/2]

SoInput::SoInput ( SoInput dictIn)

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

Member Function Documentation

◆ addDirectoryFirst()

static void SoInput::addDirectoryFirst ( const char *  dirName)
static

◆ addDirectoryLast()

static void SoInput::addDirectoryLast ( const char *  dirName)
static

◆ addEnvDirectoriesFirst()

static void SoInput::addEnvDirectoriesFirst ( const char *  envVarName)
static

◆ addEnvDirectoriesLast()

static void SoInput::addEnvDirectoriesLast ( const char *  envVarName)
static

◆ addReference()

void SoInput::addReference ( const SbName name,
SoBase base,
bool  addToGlobalDict = TRUE 
)

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

◆ clearDirectories()

static void SoInput::clearDirectories ( )
static

◆ closeFile()

void SoInput::closeFile ( )

◆ eof()

bool SoInput::eof ( ) const

◆ findReference()

SoBase* SoInput::findReference ( const SbName name) const

◆ get()

bool SoInput::get ( char &  c)

Returns FALSE on EOF or error.

◆ getASCIIBuffer()

bool SoInput::getASCIIBuffer ( char &  c)

Returns FALSE on EOF or error.

◆ getASCIIFile()

bool SoInput::getASCIIFile ( char &  c)

Returns FALSE on EOF or error.

◆ getCurFile()

FILE* SoInput::getCurFile ( ) const

◆ getCurFileName()

const char* SoInput::getCurFileName ( ) const

◆ getDirectories()

static const SbStringList& SoInput::getDirectories ( )
static

◆ getHeader()

SbString SoInput::getHeader ( )

◆ getIVVersion()

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.

◆ getLocationString()

void SoInput::getLocationString ( SbString string) const

◆ getNumBytesRead()

size_t SoInput::getNumBytesRead ( ) const

Returns 0 if not reading from a buffer.

◆ init()

static void SoInput::init ( )
static

◆ isBinary()

bool SoInput::isBinary ( )

◆ isValidFile()

bool SoInput::isValidFile ( )

◆ openFile()

bool SoInput::openFile ( const char *  fileName,
bool  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.

◆ pushFile()

bool SoInput::pushFile ( const char *  fileName)

Returns FALSE on error.

◆ putBack() [1/2]

void SoInput::putBack ( char  c)

◆ putBack() [2/2]

void SoInput::putBack ( const char *  string)

◆ read() [1/9]

bool SoInput::read ( char &  c)

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

◆ read() [2/9]

bool SoInput::read ( double &  d)

◆ read() [3/9]

bool SoInput::read ( float &  f)

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

◆ read() [4/9]

bool SoInput::read ( int &  i)

◆ read() [5/9]

bool SoInput::read ( SbName n,
bool  validIdent = FALSE 
)

◆ read() [6/9]

bool SoInput::read ( SbString s)

◆ read() [7/9]

bool SoInput::read ( short &  s)

◆ read() [8/9]

bool SoInput::read ( unsigned int &  i)

◆ read() [9/9]

bool SoInput::read ( unsigned short &  s)

◆ readBinaryArray() [1/4]

bool SoInput::readBinaryArray ( double *  d,
int  length 
)

◆ readBinaryArray() [2/4]

bool SoInput::readBinaryArray ( float *  f,
int  length 
)

◆ readBinaryArray() [3/4]

bool SoInput::readBinaryArray ( int32_t l,
int  length 
)

◆ readBinaryArray() [4/4]

bool SoInput::readBinaryArray ( unsigned char *  c,
int  length 
)

◆ readHex()

bool SoInput::readHex ( uint32_t l)

Returns FALSE on EOF or error.

◆ removeDirectory()

static void SoInput::removeDirectory ( const char *  dirName)
static

◆ removeReference()

void SoInput::removeReference ( const SbName name)

This may also remove a reference from the global dictionary.

◆ setBuffer()

void SoInput::setBuffer ( void *  bufPointer,
size_t  bufSize 
)

◆ setFilePointer()

void SoInput::setFilePointer ( FILE *  newFP)

Friends And Related Function Documentation

◆ SoBase

friend class SoBase
friend

Definition at line 363 of file SoInput.h.

◆ SoDB

friend class SoDB
friend

Definition at line 364 of file SoInput.h.


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