SoInput.h
#ifndef COIN_SOINPUT_H
#define COIN_SOINPUT_H
/**************************************************************************\
* Copyright (c) Kongsberg Oil & Gas Technologies AS
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\**************************************************************************/
#include <Inventor/system/inttypes.h>
#include <Inventor/SbBasic.h>
#include <Inventor/lists/SbList.h>
#include <cstdio> // FILE
#ifndef COIN_INTERNAL
// For Open Inventor compatibility.
#include <Inventor/SoDB.h>
#endif // COIN_INTERNAL
// *************************************************************************
class SbDict;
class SoBase;
class SbString;
class SbTime;
class SbName;
class SbStringList;
class SoInput_FileInfo;
class SoProto;
class SoField;
class SoFieldContainer;
class SoInputP;
// *************************************************************************
class COIN_DLL_API SoInput {
public:
SoInput(void);
SoInput(SoInput * dictIn);
SoProto * findProto(const SbName & name);
void addProto(SoProto * proto);
void pushProto(SoProto * proto);
SoProto * getCurrentProto(void) const;
void popProto(void);
void addRoute(const SbName & fromnode, const SbName & fromfield,
const SbName & tonode, const SbName & tofield);
SbBool checkISReference(SoFieldContainer * container, const SbName & fieldname,
SbBool & readok);
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(const void * bufpointer, size_t bufsize);
void setStringArray(const char * strings[]);
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 readByte(int8_t & b);
virtual SbBool readByte(uint8_t & b);
#ifdef __CYGWIN__
//These function are not virtual as they are meant to be only wrappers to the real function calls, due to limitations in Cygwin g++ type demangling.
SbBool read(long int & i);
SbBool read(long unsigned int & i);
#endif //__CYGWIN__
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 void addDirectoryFirst(const char * dirName);
static void addDirectoryLast(const char * dirName);
static void addEnvDirectoriesFirst(const char * envVarName,
const char * separator = ":\t ");
static void addEnvDirectoriesLast(const char * envVarName,
const char * separator = ":\t ");
static void removeDirectory(const char * dirName);
static void clearDirectories(void);
static const SbStringList & getDirectories(void);
static void init(void);
static SbString getPathname(const char * const filename);
static SbString getPathname(const SbString & s);
static SbString getBasename(const char * const filename);
static SbString getBasename(const SbString & s);
static SbString searchForFile(const SbString & basename,
const SbStringList & directories,
const SbStringList & subdirectories);
protected:
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 = 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 void setDirectories(SbStringList * dirs);
private:
friend class SoDB;
friend class SoInputP;
static void clean(void);
void constructorsCommon(void);
static void addDirectoryIdx(const int idx, const char * dirName);
static void addEnvDirectoriesIdx(int startidx, const char * envVarName,
const char * separator);
static SbStringList * dirsearchlist;
SbList<SoInput_FileInfo *> filestack;
SoInput_FileInfo * getTopOfStack(void) const {
return this->filestack[0];
}
SoInputP * pimpl;
};
#endif // !COIN_SOINPUT_H
SbDict
The SbDict class organizes a dictionary of keys and values.
Definition SbDict.h:63
SbList
The SbList class is a template container class for lists.
Definition SbList.h:70
SbName
The SbName class stores strings by reference.
Definition SbName.h:40
SbStringList
The SbStringList class is a container for pointers to SbString objects.
Definition SbStringList.h:40
SbString
The SbString class is a string class with convenience functions for string operations.
Definition SbString.h:52
SbTime
The SbTime class instances represents time values.
Definition SbTime.h:50
SoBase
The SoBase class is the top-level superclass for a number of class-hierarchies.
Definition SoBase.h:45
SoFieldContainer
The SoFieldContainer class is a base class for all classes that contain fields.
Definition SoFieldContainer.h:43
SoField
The SoField class is the top-level abstract base class for fields.
Definition SoField.h:47
SoInput::addEnvDirectoriesLast
static void addEnvDirectoriesLast(const char *envVarName, const char *separator=":\t ")
Definition SoInput.cpp:1723
SoInput::closeFile
virtual void closeFile(void)
Definition SoInput.cpp:580
SoInput::convertDouble
void convertDouble(char *from, double *d)
Definition SoInput.cpp:2337
SoInput::getNumBytesRead
virtual size_t getNumBytesRead(void) const
Definition SoInput.cpp:767
SoInput::setFilePointer
virtual void setFilePointer(FILE *newFP)
Definition SoInput.cpp:462
SoInput::getCurFileName
virtual const char * getCurFileName(void) const
Definition SoInput.cpp:663
SoInput::eof
virtual SbBool eof(void) const
Definition SoInput.cpp:1511
SoInput::readChar
int readChar(char *str, char charToRead)
Definition SoInput.cpp:2281
SoInput::skipWhiteSpace
SbBool skipWhiteSpace(void)
Definition SoInput.cpp:2146
SoInput::isFileVRML1
SbBool isFileVRML1(void)
Definition SoInput.cpp:2410
SoInput::popFile
virtual SbBool popFile(void)
Definition SoInput.cpp:2161
SoInput::getIVVersion
virtual float getIVVersion(void)
Definition SoInput.cpp:792
SoInput::readDigits
int readDigits(char *str)
Definition SoInput.cpp:2255
SoInput::convertShort
void convertShort(char *from, short *s)
Definition SoInput.cpp:2304
SoInput::getHeader
virtual SbString getHeader(void)
Definition SoInput.cpp:778
SoInput::checkISReference
SbBool checkISReference(SoFieldContainer *container, const SbName &fieldname, SbBool &readok)
Definition SoInput.cpp:385
SoInput::readUnsignedIntegerString
SbBool readUnsignedIntegerString(char *str)
Definition SoInput.cpp:2243
SoInput::convertInt32
void convertInt32(char *from, int32_t *l)
Definition SoInput.cpp:2315
SoInput::isFileURL
SbBool isFileURL(const char *url)
Definition SoInput.cpp:2446
SoInput::isBinary
virtual SbBool isBinary(void)
Definition SoInput.cpp:802
SoInput::addRoute
void addRoute(const SbName &fromnode, const SbName &fromfield, const SbName &tonode, const SbName &tofield)
Definition SoInput.cpp:284
SoInput::addEnvDirectoriesFirst
static void addEnvDirectoriesFirst(const char *envVarName, const char *separator=":\t ")
Definition SoInput.cpp:1706
SoInput::removeReference
virtual void removeReference(const SbName &name)
Definition SoInput.cpp:1591
SoInput::get
virtual SbBool get(char &c)
Definition SoInput.cpp:819
SoInput::init
static void init(void)
Definition SoInput.cpp:1858
SoInput::isValidFile
virtual SbBool isValidFile(void)
Definition SoInput.cpp:602
SoInput::clearDirectories
static void clearDirectories(void)
Definition SoInput.cpp:1830
SoInput::isValidBuffer
virtual SbBool isValidBuffer(void)
Definition SoInput.cpp:624
SoInput::addProto
void addProto(SoProto *proto)
Definition SoInput.cpp:318
SoInput::putBack
virtual void putBack(const char c)
Definition SoInput.cpp:1549
SoInput::resetFilePointer
virtual void resetFilePointer(FILE *fptr)
Definition SoInput.cpp:2436
SoInput::readHex
virtual SbBool readHex(uint32_t &l)
Definition SoInput.cpp:860
SoInput::readReal
SbBool readReal(double &d)
Definition SoInput.cpp:2228
SoInput::setBuffer
virtual void setBuffer(const void *bufpointer, size_t bufsize)
Definition SoInput.cpp:733
SoInput::initFile
void initFile(FILE *newFP, const char *fileName, SbString *fullName, SbBool openedHere, SbDict *refDict=NULL)
Definition SoInput.cpp:2090
SoInput::searchForFile
static SbString searchForFile(const SbString &basename, const SbStringList &directories, const SbStringList &subdirectories)
Definition SoInput.cpp:2005
SoInput::makeRoomInBuf
SbBool makeRoomInBuf(size_t nBytes)
Definition SoInput.cpp:2292
SoInput::convertInt32Array
void convertInt32Array(char *from, int32_t *to, int len)
Definition SoInput.cpp:2363
SoInput::openFile
virtual SbBool openFile(const char *fileName, SbBool okIfNotFound=FALSE)
Definition SoInput.cpp:495
SoInput::getBasename
static SbString getBasename(const char *const filename)
Definition SoInput.cpp:1935
SoInput::pushFile
virtual SbBool pushFile(const char *fileName)
Definition SoInput.cpp:529
SoInput::getASCIIFile
virtual SbBool getASCIIFile(char &c)
Definition SoInput.cpp:845
SoInput::removeDirectory
static void removeDirectory(const char *dirName)
Definition SoInput.cpp:1792
SoInput::checkHeader
SbBool checkHeader(SbBool bValidateBufferHeader=FALSE)
Definition SoInput.cpp:2107
SoInput::fromBuffer
SbBool fromBuffer(void) const
Definition SoInput.cpp:2134
SoInput::freeBytesInBuf
size_t freeBytesInBuf(void) const
Definition SoInput.cpp:2192
SoInput::setIVVersion
void setIVVersion(float version)
Definition SoInput.cpp:2079
SoInput::getLocationString
virtual void getLocationString(SbString &string) const
Definition SoInput.cpp:1523
SoInput::setDirectories
static void setDirectories(SbStringList *dirs)
Definition SoInput.cpp:2480
SoInput::convertFloat
void convertFloat(char *from, float *f)
Definition SoInput.cpp:2326
SoInput::convertFloatArray
void convertFloatArray(char *from, float *to, int len)
Definition SoInput.cpp:2379
SoInput::isFileVRML2
SbBool isFileVRML2(void)
Definition SoInput.cpp:2424
SoInput::pushProto
void pushProto(SoProto *proto)
Definition SoInput.cpp:336
SoInput::readBinaryArray
virtual SbBool readBinaryArray(unsigned char *c, int length)
Definition SoInput.cpp:1445
SoInput::findReference
virtual SoBase * findReference(const SbName &name) const
Definition SoInput.cpp:1615
SoInput::getASCIIBuffer
virtual SbBool getASCIIBuffer(char &c)
Definition SoInput.cpp:834
SoInput::SoInput
SoInput(void)
Definition SoInput.cpp:185
SoInput::readByte
virtual SbBool readByte(int8_t &b)
Definition SoInput.cpp:1328
SoInput::readHexDigits
int readHexDigits(char *str)
Definition SoInput.cpp:2267
SoInput::addDirectoryLast
static void addDirectoryLast(const char *dirName)
Definition SoInput.cpp:1660
SoInput::addReference
virtual void addReference(const SbName &name, SoBase *base, SbBool addToGlobalDict=TRUE)
Definition SoInput.cpp:1573
SoInput::readInteger
SbBool readInteger(int32_t &l)
Definition SoInput.cpp:2203
SoInput::IsURL
SbBool IsURL(const char *c_strng)
Definition SoInput.cpp:2468
SoInput::addDirectoryFirst
static void addDirectoryFirst(const char *dirName)
Definition SoInput.cpp:1647
SoInput::URLToFile
char * URLToFile(char *out_buf, const char *in_buf)
Definition SoInput.cpp:2457
SoInput::findProto
SoProto * findProto(const SbName &name)
Definition SoInput.cpp:301
SoInput::getCurFile
virtual FILE * getCurFile(void) const
Definition SoInput.cpp:649
SoInput::getDirectories
static const SbStringList & getDirectories(void)
Definition SoInput.cpp:1844
SoInput::read
virtual SbBool read(char &c)
Definition SoInput.cpp:886
SoInput::readUnsignedInteger
SbBool readUnsignedInteger(uint32_t &l)
Definition SoInput.cpp:2215
SoInput::convertShortArray
void convertShortArray(char *from, short *to, int len)
Definition SoInput.cpp:2348
SoInput::setStringArray
void setStringArray(const char *strings[])
Definition SoInput.cpp:707
SoInput::findFile
FILE * findFile(const char *fileName, SbString &fullName)
Definition SoInput.cpp:2521
SoInput::popProto
void popProto(void)
Definition SoInput.cpp:352
SoInput::getPathname
static SbString getPathname(const char *const filename)
Definition SoInput.cpp:1892
SoInput::getCurrentProto
SoProto * getCurrentProto(void) const
Definition SoInput.cpp:368
SoInput::convertDoubleArray
void convertDoubleArray(char *from, double *to, int len)
Definition SoInput.cpp:2395
SoProto
The SoProto class handles PROTO definitions.
Definition SoProto.h:50