Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

SoInput.h

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

Generated at Tue Mar 5 03:31:14 2002 for Coin by doxygen1.2.9 written by Dimitri van Heesch, © 1997-2001