Coin Logo http://www.sim.no
http://www.coin3d.org

Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class 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-2006 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 http://www.coin3d.org/ for more information.
00021  *
00022  *  Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY.
00023  *  http://www.sim.no/  sales@sim.no  coin-support@coin3d.org
00024  *
00025 \**************************************************************************/
00026 
00027 #include <Inventor/system/inttypes.h>
00028 #include <Inventor/SbBasic.h>
00029 #include <Inventor/lists/SbList.h>
00030 #include <stdio.h> // FILE
00031 #ifndef COIN_INTERNAL
00032  // For Open Inventor compatibility.
00033  #include <Inventor/SoDB.h>
00034  #include <Inventor/SbDict.h>
00035 #else
00036  #define COIN_ALLOW_SBDICT // Coin 2.x hack, for ABI compatibility
00037  #include <Inventor/SbDict.h>
00038  #undef COIN_ALLOW_SBDICT
00039 #endif // COIN_INTERNAL
00040 
00041 // *************************************************************************
00042 
00043 class SoBase;
00044 class SbString;
00045 class SbTime;
00046 class SbName;
00047 class SbStringList;
00048 class SoInput_FileInfo;
00049 class SoProto;
00050 class SoField;
00051 class SoFieldContainer;
00052 
00053 // *************************************************************************
00054 
00055 class COIN_DLL_API SoInput {
00056 public:
00057   SoInput(void);
00058   SoInput(SoInput * dictIn);
00059 
00060   SoProto * findProto(const SbName & name);
00061   void addProto(SoProto * proto);
00062   void pushProto(SoProto * proto);
00063   SoProto * getCurrentProto(void) const;
00064   void popProto(void);
00065 
00066   void addRoute(const SbName & fromnode, const SbName & fromfield,
00067                 const SbName & tonode, const SbName & tofield);
00068   SbBool checkISReference(SoFieldContainer * container, const SbName & fieldname, 
00069                           SbBool & readok);
00070   
00071   virtual ~SoInput(void);
00072 
00073   virtual void setFilePointer(FILE * newFP);
00074   virtual SbBool openFile(const char * fileName, SbBool okIfNotFound = FALSE);
00075   virtual SbBool pushFile(const char * fileName);
00076   virtual void closeFile(void);
00077   virtual SbBool isValidFile(void);
00078   virtual SbBool isValidBuffer(void);
00079   virtual FILE * getCurFile(void) const;
00080   virtual const char * getCurFileName(void) const;
00081   virtual void setBuffer(void * bufpointer, size_t bufsize);
00082           void setStringArray(const char * strings[]);
00083   virtual size_t getNumBytesRead(void) const;
00084   virtual SbString getHeader(void);
00085   virtual float getIVVersion(void);
00086   virtual SbBool isBinary(void);
00087 
00088   virtual SbBool get(char & c);
00089   virtual SbBool getASCIIBuffer(char & c);
00090   virtual SbBool getASCIIFile(char & c);
00091   virtual SbBool readHex(uint32_t & l);
00092   virtual SbBool read(char & c);
00093   virtual SbBool read(char & c, SbBool skip);
00094   virtual SbBool read(SbString & s);
00095   virtual SbBool read(SbName & n, SbBool validIdent = FALSE);
00096   virtual SbBool read(int & i);
00097   virtual SbBool read(unsigned int & i);
00098   virtual SbBool read(short & s);
00099   virtual SbBool read(unsigned short & s);
00100   virtual SbBool read(float & f);
00101   virtual SbBool read(double & d);
00102   virtual SbBool readBinaryArray(unsigned char * c, int length);
00103   virtual SbBool readBinaryArray(int32_t * l, int length);
00104   virtual SbBool readBinaryArray(float * f, int length);
00105   virtual SbBool readBinaryArray(double * d, int length);
00106   virtual SbBool eof(void) const;
00107 
00108   SbBool isFileVRML1(void);
00109   SbBool isFileVRML2(void);
00110   virtual void resetFilePointer(FILE * fptr);
00111 
00112   virtual void getLocationString(SbString & string) const;
00113   virtual void putBack(const char c);
00114   virtual void putBack(const char * str);
00115   virtual void addReference(const SbName & name, SoBase * base,
00116                             SbBool addToGlobalDict = TRUE);
00117   virtual void removeReference(const SbName & name);
00118   virtual SoBase * findReference(const SbName & name) const;
00119 
00120   static void addDirectoryFirst(const char * dirName);
00121   static void addDirectoryLast(const char * dirName);
00122   static void addEnvDirectoriesFirst(const char * envVarName,
00123                                      const char * separator = ":\t ");
00124   static void addEnvDirectoriesLast(const char * envVarName,
00125                                     const char * separator = ":\t ");
00126   static void removeDirectory(const char * dirName);
00127   static void clearDirectories(void);
00128   static const SbStringList & getDirectories(void);
00129 
00130   static void init(void);
00131 
00132   static SbString getPathname(const char * const filename);
00133   static SbString getPathname(const SbString & s);
00134   static SbString getBasename(const char * const filename);
00135   static SbString getBasename(const SbString & s);
00136 
00137   static SbString searchForFile(const SbString & basename,
00138                                 const SbStringList & directories,
00139                                 const SbStringList & subdirectories);
00140 
00141 
00142 protected:
00143   virtual SbBool popFile(void);
00144   void setIVVersion(float version);
00145   FILE * findFile(const char * fileName, SbString & fullName);
00146   void initFile(FILE * newFP, const char * fileName, SbString * fullName,
00147                 SbBool openedHere, SbDict * refDict = (SbDict *) NULL);
00148   SbBool checkHeader(SbBool bValidateBufferHeader = FALSE);
00149   SbBool fromBuffer(void) const;
00150   SbBool skipWhiteSpace(void);
00151   size_t freeBytesInBuf(void) const;
00152   SbBool readInteger(int32_t & l);
00153   SbBool readUnsignedInteger(uint32_t & l);
00154   SbBool readReal(double & d);
00155   SbBool readUnsignedIntegerString(char * str);
00156   int readDigits(char * str);
00157   int readHexDigits(char * str);
00158   int readChar(char * str, char charToRead);
00159 
00160   SbBool makeRoomInBuf(size_t nBytes);
00161   void convertShort(char * from, short * s);
00162   void convertInt32(char * from, int32_t * l);
00163   void convertFloat(char * from, float * f);
00164   void convertDouble(char * from, double * d);
00165   void convertShortArray(char * from, short * to, int len);
00166   void convertInt32Array(char * from, int32_t * to, int len);
00167   void convertFloatArray(char * from, float * to, int len);
00168   void convertDoubleArray(char * from, double * to, int len);
00169   SbBool isFileURL(const char * url);
00170   char * URLToFile(char * out_buf, const char * in_buf);
00171   SbBool IsURL(const char * c_strng);
00172 
00173   static void setDirectories(SbStringList * dirs);
00174 
00175 private:
00176   friend class SoDB;
00177   friend class SoInputP;
00178 
00179   static void clean(void);
00180   void constructorsCommon(void);
00181 
00182   static void addDirectoryIdx(const int idx, const char * dirName);
00183   static void addEnvDirectoriesIdx(int startidx, const char * envVarName,
00184                                    const char * separator);
00185   static SbStringList * dirsearchlist;
00186 
00187   SbList<SoInput_FileInfo *> filestack;
00188   SoInput_FileInfo * getTopOfStack(void) const;
00189 
00190   // OBSOLETE, only kept for Coin 2.x ABI compatibility.
00191   SbDict refdict;
00192 };
00193 
00194 #endif // !COIN_SOINPUT_H

Copyright © 1998-2005 by Systems in Motion AS. All rights reserved.

Generated on Tue May 30 14:39:28 2006 for Coin by Doxygen. 1.4.4