Main Page | Modules | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | Related Pages

SoInput.h

00001 #ifndef COIN_SOINPUT_H
00002 #define COIN_SOINPUT_H
00003 
00004 /**************************************************************************\
00005  *
00006  *  This file is part of the Coin 3D visualization library.
00007  *  Copyright (C) 1998-2003 by Systems in Motion.  All rights reserved.
00008  *
00009  *  This library is free software; you can redistribute it and/or
00010  *  modify it under the terms of the GNU General Public License
00011  *  ("GPL") version 2 as published by the Free Software Foundation.
00012  *  See the file LICENSE.GPL at the root directory of this source
00013  *  distribution for additional information about the GNU GPL.
00014  *
00015  *  For using Coin with software that can not be combined with the GNU
00016  *  GPL, and for taking advantage of the additional benefits of our
00017  *  support services, please contact Systems in Motion about acquiring
00018  *  a Coin Professional Edition License.
00019  *
00020  *  See <URL:http://www.coin3d.org> for  more information.
00021  *
00022  *  Systems in Motion, Teknobyen, Abels Gate 5, 7030 Trondheim, NORWAY.
00023  *  <URL:http://www.sim.no>.
00024  *
00025 \**************************************************************************/
00026 
00027 #include <Inventor/system/inttypes.h>
00028 #include <Inventor/SbBasic.h>
00029 #include <Inventor/SbDict.h>
00030 #include <Inventor/lists/SbList.h>
00031 #include <stdio.h> // FILE
00032 #ifndef COIN_INTERNAL
00033  // For Open Inventor compatibility.
00034  #include <Inventor/SoDB.h>
00035 #endif // COIN_INTERNAL
00036 
00037 class SoBase;
00038 class SbString;
00039 class SbTime;
00040 class SbName;
00041 class SbStringList;
00042 class SoInput_FileInfo;
00043 class SoProto;
00044 class SoField;
00045 class SoFieldContainer;
00046 
00047 class COIN_DLL_API SoInput {
00048 public:
00049   SoInput(void);
00050   SoInput(SoInput * dictIn);
00051 
00052   void addProto(SoProto * proto);
00053 
00054   void pushProto(SoProto * proto);
00055   SoProto * getCurrentProto(void) const;
00056   void popProto(void);
00057 
00058   void addRoute(const SbName & fromnode, const SbName & fromfield,
00059                 const SbName & tonode, const SbName & tofield);
00060   SbBool checkISReference(SoFieldContainer * container, const SbName & fieldname, 
00061                           SbBool & readok);
00062   
00063   virtual ~SoInput(void);
00064 
00065   virtual void setFilePointer(FILE * newFP);
00066   virtual SbBool openFile(const char * fileName, SbBool okIfNotFound = FALSE);
00067   virtual SbBool pushFile(const char * fileName);
00068   virtual void closeFile(void);
00069   virtual SbBool isValidFile(void);
00070   virtual SbBool isValidBuffer(void);
00071   virtual FILE * getCurFile(void) const;
00072   virtual const char * getCurFileName(void) const;
00073   virtual void setBuffer(void * bufpointer, size_t bufsize);
00074           void setStringArray(const char * strings[]);
00075   virtual size_t getNumBytesRead(void) const;
00076   virtual SbString getHeader(void);
00077   virtual float getIVVersion(void);
00078   virtual SbBool isBinary(void);
00079 
00080   virtual SbBool get(char & c);
00081   virtual SbBool getASCIIBuffer(char & c);
00082   virtual SbBool getASCIIFile(char & c);
00083   virtual SbBool readHex(uint32_t & l);
00084   virtual SbBool read(char & c);
00085   virtual SbBool read(char & c, SbBool skip);
00086   virtual SbBool read(SbString & s);
00087   virtual SbBool read(SbName & n, SbBool validIdent = FALSE);
00088   virtual SbBool read(int & i);
00089   virtual SbBool read(unsigned int & i);
00090   virtual SbBool read(short & s);
00091   virtual SbBool read(unsigned short & s);
00092   virtual SbBool read(float & f);
00093   virtual SbBool read(double & d);
00094   virtual SbBool readBinaryArray(unsigned char * c, int length);
00095   virtual SbBool readBinaryArray(int32_t * l, int length);
00096   virtual SbBool readBinaryArray(float * f, int length);
00097   virtual SbBool readBinaryArray(double * d, int length);
00098   virtual SbBool eof(void) const;
00099 
00100   SbBool isFileVRML1(void);
00101   SbBool isFileVRML2(void);
00102   virtual void resetFilePointer(FILE * fptr);
00103 
00104   virtual void getLocationString(SbString & string) const;
00105   virtual void putBack(const char c);
00106   virtual void putBack(const char * str);
00107   virtual void addReference(const SbName & name, SoBase * base,
00108                             SbBool addToGlobalDict = TRUE);
00109   virtual void removeReference(const SbName & name);
00110   virtual SoBase * findReference(const SbName & name) const;
00111 
00112   static void addDirectoryFirst(const char * dirName);
00113   static void addDirectoryLast(const char * dirName);
00114   static void addEnvDirectoriesFirst(const char * envVarName,
00115                                      const char * separator = ":\t ");
00116   static void addEnvDirectoriesLast(const char * envVarName,
00117                                     const char * separator = ":\t ");
00118   static void removeDirectory(const char * dirName);
00119   static void clearDirectories(void);
00120   static const SbStringList & getDirectories(void);
00121 
00122   static void init(void);
00123 
00124   static SbString getPathname(const char * const filename);
00125   static SbString getPathname(const SbString & s);
00126   static SbString getBasename(const char * const filename);
00127   static SbString getBasename(const SbString & s);
00128 
00129   static SbString searchForFile(const SbString & basename,
00130                                 const SbStringList & directories,
00131                                 const SbStringList & subdirectories);
00132 
00133 
00134 protected:
00135   virtual SbBool popFile(void);
00136   void setIVVersion(float version);
00137   FILE * findFile(const char * fileName, SbString & fullName);
00138   void initFile(FILE * newFP, const char * fileName, SbString * fullName,
00139                 SbBool openedHere, SbDict * refDict = (SbDict *) NULL);
00140   SbBool checkHeader(SbBool bValidateBufferHeader = FALSE);
00141   SbBool fromBuffer(void) const;
00142   SbBool skipWhiteSpace(void);
00143   size_t freeBytesInBuf(void) const;
00144   SbBool readInteger(int32_t & l);
00145   SbBool readUnsignedInteger(uint32_t & l);
00146   SbBool readReal(double & d);
00147   SbBool readUnsignedIntegerString(char * str);
00148   int readDigits(char * str);
00149   int readHexDigits(char * str);
00150   int readChar(char * str, char charToRead);
00151 
00152   SbBool makeRoomInBuf(size_t nBytes);
00153   void convertShort(char * from, short * s);
00154   void convertInt32(char * from, int32_t * l);
00155   void convertFloat(char * from, float * f);
00156   void convertDouble(char * from, double * d);
00157   void convertShortArray(char * from, short * to, int len);
00158   void convertInt32Array(char * from, int32_t * to, int len);
00159   void convertFloatArray(char * from, float * to, int len);
00160   void convertDoubleArray(char * from, double * to, int len);
00161   SbBool isFileURL(const char * url);
00162   char * URLToFile(char * out_buf, const char * in_buf);
00163   SbBool IsURL(const char * c_strng);
00164 
00165   static void setDirectories(SbStringList * dirs);
00166 
00167 private:
00168   friend class SoDB;
00169 
00170   static void clean(void);
00171   void constructorsCommon(void);
00172 
00173   static void addDirectoryIdx(const int idx, const char * dirName);
00174   static void addEnvDirectoriesIdx(int startidx, const char * envVarName,
00175                                    const char * separator);
00176   static SbStringList * dirsearchlist;
00177 
00178   SbList<SoInput_FileInfo *> filestack;
00179   SoInput_FileInfo * getTopOfStack(void) const;
00180 
00181   SbDict refdict;
00182 };
00183 
00184 #endif // !COIN_SOINPUT_H

Generated on Sun Dec 14 15:49:00 2003 for Coin by doxygen 1.3.3