#include <Inventor/SoInput.h>
Public Methods | |
SoInput (void) | |
SoInput (SoInput *dictIn) | |
virtual | ~SoInput (void) |
virtual void | setFilePointer (FILE *newFP) |
virtual SbBool | openFile (const char *fileName, SbBool okIfNotFound=FALSE) |
virtual SbBool | pushFile (const char *fileName) |
virtual void | closeFile (void) |
virtual SbBool | isValidFile (void) |
virtual SbBool | isValidBuffer (void) |
virtual FILE * | getCurFile (void) const |
virtual const char * | getCurFileName (void) const |
virtual void | setBuffer (void *bufpointer, size_t bufsize) |
virtual size_t | getNumBytesRead (void) const |
virtual SbString | getHeader (void) |
virtual float | getIVVersion (void) |
virtual SbBool | isBinary (void) |
virtual SbBool | get (char &c) |
virtual SbBool | getASCIIBuffer (char &c) |
virtual SbBool | getASCIIFile (char &c) |
virtual SbBool | readHex (uint32_t &l) |
virtual SbBool | read (char &c) |
virtual SbBool | read (char &c, SbBool skip) |
virtual SbBool | read (SbString &s) |
virtual SbBool | read (SbName &n, SbBool validIdent=FALSE) |
virtual SbBool | read (int &i) |
virtual SbBool | read (unsigned int &i) |
virtual SbBool | read (short &s) |
virtual SbBool | read (unsigned short &s) |
virtual SbBool | read (float &f) |
virtual SbBool | read (double &d) |
virtual SbBool | readBinaryArray (unsigned char *c, int length) |
virtual SbBool | readBinaryArray (int32_t *l, int length) |
virtual SbBool | readBinaryArray (float *f, int length) |
virtual SbBool | readBinaryArray (double *d, int length) |
virtual SbBool | eof (void) const |
SbBool | isFileVRML1 (void) |
SbBool | isFileVRML2 (void) |
virtual void | resetFilePointer (FILE *fptr) |
virtual void | getLocationString (SbString &string) const |
virtual void | putBack (const char c) |
virtual void | putBack (const char *str) |
virtual void | addReference (const SbName &name, SoBase *base, SbBool addToGlobalDict=TRUE) |
virtual void | removeReference (const SbName &name) |
virtual SoBase * | findReference (const SbName &name) const |
Static Public Methods | |
void | addDirectoryFirst (const char *dirName) |
void | addDirectoryLast (const char *dirName) |
void | addEnvDirectoriesFirst (const char *envVarName, const char *separator=":\t") |
void | addEnvDirectoriesLast (const char *envVarName, const char *separator=":\t") |
void | removeDirectory (const char *dirName) |
void | clearDirectories (void) |
const SbStringList & | getDirectories (void) |
void | init (void) |
SbString | getPathname (const char *const filename) |
SbString | getPathname (const SbString &s) |
SbString | getBasename (const char *const filename) |
SbString | getBasename (const SbString &s) |
SbString | searchForFile (const SbString &basename, const SbStringList &directories, const SbStringList &subdirectories) |
Protected Methods | |
virtual SbBool | popFile (void) |
void | setIVVersion (float version) |
FILE * | findFile (const char *fileName, SbString &fullName) |
void | initFile (FILE *newFP, const char *fileName, SbString *fullName, SbBool openedHere, SbDict *refDict=(SbDict *) NULL) |
SbBool | checkHeader (SbBool bValidateBufferHeader=FALSE) |
SbBool | fromBuffer (void) const |
SbBool | skipWhiteSpace (void) |
size_t | freeBytesInBuf (void) const |
SbBool | readInteger (int32_t &l) |
SbBool | readUnsignedInteger (uint32_t &l) |
SbBool | readReal (double &d) |
SbBool | readUnsignedIntegerString (char *str) |
int | readDigits (char *str) |
int | readHexDigits (char *str) |
int | readChar (char *str, char charToRead) |
SbBool | makeRoomInBuf (size_t nBytes) |
void | convertShort (char *from, short *s) |
void | convertInt32 (char *from, int32_t *l) |
void | convertFloat (char *from, float *f) |
void | convertDouble (char *from, double *d) |
void | convertShortArray (char *from, short *to, int len) |
void | convertInt32Array (char *from, int32_t *to, int len) |
void | convertFloatArray (char *from, float *to, int len) |
void | convertDoubleArray (char *from, double *to, int len) |
SbBool | isFileURL (const char *url) |
char * | URLToFile (char *out_buf, const char *in_buf) |
SbBool | IsURL (const char *c_strng) |
Static Protected Methods | |
void | setDirectories (SbStringList *dirs) |
This class takes care of most of the chores of doing data import in Coin. It puts a layer of abstraction over the read operations to make it transparent for the rest of the Coin code whether or not we're reading from a file, from a memory buffer or from stdin.
SoInput also takes care of checking file validity, aswell as handling information about features in the various file formats which are supported.
Example usage:
int main(void) { SoDB::init(); SoInput in; if (in.openFile("fab_model.iv")) { SoSeparator * root = SoDB::readAll(&in); if (root) { // Do stuff with the imported scene graph here // ... return 0; } } return 1; }
Important note: there are several public and protected methods which makes it possible to pass in or get returned FILE* structures in this class. Do not use these methods 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.
This class supports one environment variable called COIN_SOINPUT_SEARCH_GLOBAL_DICT. When set to "1", the global dictionary is searched after the current file dictionary when resolving USE keywords. This makes it possible to reference nodes in other files. The reason for introducing this feature is that the SoFile node rereads the file whenever the name field changes. The first time the file is read, it's possible to reference nodes in the parent file, using the USE keyword. But, when the file is reread this is no longer possible, since the reading now starts at the SoFile node, with an empty dictionary.
|
Constructor. If no filepointer is set, input will be read from stdin. |
|
A constructor which copies the reference mappings from dictIn upon initialization. |
|
Destructor. |
|
Uses the given file pointer as the input file. The input stack of files will be emptied first. Closing a file passed in by it's file pointer is the library user's responsibility.
|
|
Open the given file, and make it the only one in the file stack. If okIfNotFound is
Returns Note: even if your attempt at opening a file is unsuccessful, the SoInput instance will not default to reading from stdin after a call has been made to this method.
|
|
Push a new file on top of the stack. Further read operations will take place with the new file until it reaches end-of-file, upon when the file will be popped of the stack and we'll continue with the next file in the stack.
Returns
|
|
Removes all files from the internal stack. Any files opened by openFile() or pushFile() will also be closed, but not the files coming from setFilePointer() -- which are the responsibility of the caller.
|
|
Checks to see if the current file is a valid file which can be read by the Coin library. |
|
Returns |
|
Returns file pointer of the file on top of the input stack. If the "file" is actually a memory buffer, returns
|
|
Returns the name of the file on top of the input stack.
|
|
Sets up the input stream for reading from a memory buffer. Closes all open files in the file stack first. |
|
Returns number of bytes read so far from the current file or memory buffer. |
|
Returns header of current file. |
|
Returns the library version needed to read a file with the given header. If the header of the current file is not valid, this method returns 0.0f. |
|
Returns |
|
Get next character in current stream. Returns
|
|
Returns next character in current stream. Don't use this method -- SoInput is supposed to hide whether or not you are reading from file or memory. It is only included for compatibility reasons. |
|
Returns next character in current stream. Don't use this method -- SoInput is supposed to hide whether or not you are reading from file or memory. It is only included for compatibility reasons. |
|
Reads an unsigned integer in hexidecimal format from the current stream. Note that no error checking is done to see if it actually is a hex format value. A number in hexadecimal format must have the "0x" prefix.
Returns |
|
Skips whitespace and reads next character in input stream. Returns |
|
Reads next character in input stream, returns |
|
Skips whitespace and extracts string. A string can be placed within quotes, in which case we will return all characters between the quotes (including spaces, tabs, newlines, etc). A quote character (i.e. ``"'') can also be part of the string, but must then be preceded by a ``\'' character. A string not contained in quotes is terminated by the first following whitespace character or left or right bracket (i.e. ``['' or ``]'').
Returns |
|
Read a name from the current stream and place it in n.
If validIdent is
Returns |
|
Read integer from current file or buffer position and place it in i. Returns |
|
Read unsigned integer from current file or buffer position and place it in i. Returns |
|
Read short integer from current file or buffer position and place it in s. Returns |
|
Read unsigned short integer from current file or buffer position and place it in s. Returns |
|
Read float value from current file or buffer position and place it in f. Returns |
|
Read double value from current file or buffer position and place it in d. Returns |
|
Reads length characters from the current stream into c. Returns |
|
Reads length 32-bit integers from the current stream into l. Returns |
|
Reads length floats from the current stream into f. Returns |
|
Reads length double floats from the current stream into d. Returns |
|
Returns |
|
Returns TRUE if current file is a VRML V1.0 file. This method is an extension versus the Open Inventor API. |
|
Returns |
|
This function has been obsoleted in Coin. |
|
Places the current line number location and file name in a string which is to be used in the output upon read errors. |
|
Insert character c in stream at the current position. |
|
Insert string str in stream at the current position. |
|
Adds a name<->SoBase mapping to our dictionary.
|
|
Removes a name<->SoBase mapping from our dictionary.
|
|
Finds an SoBase derived object which has been mapped to name earlier during the import process.
|
|
Add a directory to the search list. The added directory will be searched before any of the other directories in the list.
|
|
Add a directory to the search list. The added directory will be searched after any of the other directories in the list.
|
|
Add in front of the list all directories in the environment variable envVarName. The separator string should contain all characters to be interpreted as separators in the environment variable string list. The default separators are ':', tab and space.
|
|
Add at the end of the list all directories in the environment variable envVarName. The separator string should contain all characters to be interpreted as separators in the environment variable string list. The default separators are ':', tab and space.
|
|
Remove the given directory from the directory search list. The search list is scanned from last to first for the directory name, so directories can easily be "stacked" by pushing with addDirectoryLast() and then removed with this method.
|
|
Remove all entries from the directory search list.
|
|
Returns the list of directories which'll be searched upon loading Coin and VRML format files. Directory searches will be done whenever any external references appears in a file, for instance to texture images. |
|
Initialize static variables in class. Called from SoDB::init(). |
|
Finds and returns the part of the given filename which is the directory path name. |
|
Finds and returns the part of the given filename which is the directory path name. |
|
Finds and returns the part of the given filename which is the base name (i.e. the filename without the leading directory path). |
|
Finds and returns the part of the given filename which is the base name (i.e. the filename without the leading directory path). |
|
Given a basename for a file and an array of directories to search, returns the full name of the file found. In addition to looking at the root of each directory in directories, all subdirectories is also searched for each item in directories. If no file matching basename could be found in any of the directories, returns an empty string. This method is a Coin extension, not part of the original Inventor API. |
|
Pop the topmost file off the stack. Returns
|
|
Changes the file format version number for the stream at the top of the stack. |
|
Scan through the include directories in order and try to find a file with the given name in any one of them. If file is found, put the full name with complete path from current directory of process into fullname, open the file and return the file pointer.
If the file could either not be found or not opened for reading, return |
|
This function has been obsoleted in Coin. |
|
Returns
If bValidateBufferHeader is |
|
Returns |
|
Move file pointer past whitespace in the current file or buffer. Returns |
|
This function has been obsoleted in Coin. |
|
Reads 32-bit signed integer value from the current stream. Returns |
|
Reads 32-bit unsigned integer value from the current stream. Returns |
|
Reads a double-precision floating point value from the current stream. Returns |
|
Reads a set of bytes from the stream making up an unsigned integer and puts them at str.
Returns |
|
Read decimal base digits from the current input stream into str and returns the number of characters read. |
|
Read hexadecimal base digits from the current input stream into str and returns the number of characters read. |
|
Reads the next character in stream and compares it to charToRead. Returns |
|
This function has been obsoleted in Coin. |
|
Convert the bytes at from (which must be a short integer in network format (i.e. most significant byte first)) to a short integer in native format which is put at the s pointer. |
|
Convert the bytes at from (which must be a 32-bit integer in network format (i.e. most significant byte first)) to a 32-bit integer in native format which is put at the l pointer. |
|
Convert the bytes at from (which must be a single-precision floating point number in network format) to a single-precision floating point number in native format which is put at the f pointer. |
|
Convert the bytes at from (which must be a double-precision floating point number in network format) to a double-precision floating point number in native format which is put at the d pointer. |
|
Convert a block of short numbers in network format to native format.
|
|
Convert a block of 32-bit integer numbers in network format to native format.
|
|
Convert a b ock of single-precision floating point numbers in network format to native format.
|
|
Convert a block of double-precision floating point numbers in network format to native format.
|
|
This function is part of the TGS Inventor API, but is not implemented in Coin. |
|
This function is part of the TGS Inventor API, but is not implemented in Coin. |
|
This function is part of the TGS Inventor API, but is not implemented in Coin. |
|
Set up the directory search path directly with the list of directories in dirs. Note that "." should be part of the directory list if you want to handle files specified by a relative path. |