| 1 |
NAME SoInput SoIn "" { used to read Inventor data files } |
| 2 |
|
| 3 |
INCLUDE SoInput.h |
| 4 |
|
| 5 |
DESC { |
| 6 |
This class is used by the \cSoDB\. reading routines when reading |
| 7 |
Inventor data files. It supports both ASCII (default) and binary |
| 8 |
Inventor formats. Users can also register additional |
| 9 |
valid file headers. |
| 10 |
When reading, \cSoInput\. skips over Inventor comments |
| 11 |
(from '#' to end of |
| 12 |
line) and can stack input files. When EOF is reached, the stack is |
| 13 |
popped. This class can also be used to read from a buffer in memory. |
| 14 |
} |
| 15 |
|
| 16 |
METHOD "" SoInput() {} |
| 17 |
METHOD "" ~SoInput() { |
| 18 |
Constructor and destructor. The default \cSoInput\. reads from \xstdin\.. |
| 19 |
The destructor closes any files opened by the \cSoInput\.. |
| 20 |
} |
| 21 |
|
| 22 |
METHOD addDirFirst static void addDirectoryFirst(const char *dirName) {} |
| 23 |
METHOD addDirLast static void addDirectoryLast(const char *dirName) {} |
| 24 |
METHOD addEnvDirsFirst static void addEnvDirectoriesFirst(const char |
| 25 |
*envVarName) {} |
| 26 |
METHOD addEnvDirsLast static void addEnvDirectoriesLast(const char |
| 27 |
*envVarName) { |
| 28 |
The \cSoInput\. class maintains a global list of directories that is |
| 29 |
searched to find files when opening them. Directories are searched in |
| 30 |
order. Each of these routines adds directories to the list, either at |
| 31 |
the beginning ("First") or the end ("Last"). The last two routines add |
| 32 |
directories named in the value of the given environment variable. |
| 33 |
Directories may be separated by colons or whitespace in the variable's |
| 34 |
value. |
| 35 |
} |
| 36 |
|
| 37 |
METHOD removeDir static void removeDirectory(const char *dirName) { |
| 38 |
Removes named directory from the list. |
| 39 |
} |
| 40 |
|
| 41 |
METHOD clearDirs static void clearDirectories() { |
| 42 |
Clears the list of directories (including the current directory). |
| 43 |
} |
| 44 |
|
| 45 |
METHOD getDirs static const SbStringList & getDirectories() { |
| 46 |
Returns the list of directories as an \cSbStringList\.. |
| 47 |
} |
| 48 |
|
| 49 |
METHOD setFilePtr void setFilePointer(FILE *newFP) { |
| 50 |
Sets file pointer to read from. Clears the stack of input files if necessary. |
| 51 |
} |
| 52 |
|
| 53 |
METHOD "" SbBool openFile(const char *fileName, SbBool okIfNotFound = FALSE) { |
| 54 |
Opens named file, sets file pointer to result. Clears the stack of |
| 55 |
input files if necessary. This returns FALSE on error; if |
| 56 |
\aokIfNotFound\. is FALSE (the default), this prints an error message |
| 57 |
if the file could not be found. |
| 58 |
} |
| 59 |
|
| 60 |
METHOD "" SbBool pushFile(const char *fileName) { |
| 61 |
Opens named file, pushing the resulting file pointer onto the stack. Returns |
| 62 |
FALSE on error. |
| 63 |
} |
| 64 |
|
| 65 |
METHOD "" closeFile() { |
| 66 |
Closes all files on stack opened with |
| 67 |
\+\mopenFile()\. or \mpushFile()\..\. |
| 68 |
\-\mSoInOpenFile()\. or \mSoInPushFile()\..\. |
| 69 |
} |
| 70 |
|
| 71 |
METHOD "" SbBool isValidFile() { |
| 72 |
Returns TRUE if the currently open file is a valid Inventor file; that is, |
| 73 |
it begins with a valid Inventor header, or one that has been |
| 74 |
registered with \cSoDB::registerHeader\.. |
| 75 |
} |
| 76 |
|
| 77 |
METHOD "" FILE * getCurFile() const { |
| 78 |
Returns a pointer to the current file, or NULL if reading from a buffer. |
| 79 |
} |
| 80 |
|
| 81 |
METHOD "" const char * getCurFileName() const { |
| 82 |
Returns full name (including directory path) of current file, or NULL |
| 83 |
if reading from a buffer. |
| 84 |
} |
| 85 |
|
| 86 |
METHOD setBuf void setBuffer(void *bufPointer, size_t bufSize) { |
| 87 |
Sets an in-memory buffer to read from, along with its size. |
| 88 |
} |
| 89 |
|
| 90 |
METHOD "" SbString getHeader() { |
| 91 |
Returns the header of the file being read. |
| 92 |
} |
| 93 |
|
| 94 |
METHOD "" float getIVVersion() { |
| 95 |
Returns the Inventor file version of the file being read (e.g. 2.1). |
| 96 |
If the file has a header registered through \cSoDB::registerHeader()\., |
| 97 |
the returned version is the Inventor version registered with the |
| 98 |
header. |
| 99 |
} |
| 100 |
|
| 101 |
ALSO { SoDB, SoOutput, SoTranReceiver } |