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

SoInput.h
1 #ifndef COIN_SOINPUT_H
2 #define COIN_SOINPUT_H
3 
4 /**************************************************************************\
5  *
6  * This file is part of the Coin 3D visualization library.
7  * Copyright (C) 1998-2007 by Systems in Motion. All rights reserved.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * ("GPL") version 2 as published by the Free Software Foundation.
12  * See the file LICENSE.GPL at the root directory of this source
13  * distribution for additional information about the GNU GPL.
14  *
15  * For using Coin with software that can not be combined with the GNU
16  * GPL, and for taking advantage of the additional benefits of our
17  * support services, please contact Systems in Motion about acquiring
18  * a Coin Professional Edition License.
19  *
20  * See http://www.coin3d.org/ for more information.
21  *
22  * Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY.
23  * http://www.sim.no/ sales@sim.no coin-support@coin3d.org
24  *
25 \**************************************************************************/
26 
27 #include <Inventor/system/inttypes.h>
28 #include <Inventor/SbBasic.h>
29 #include <Inventor/lists/SbList.h>
30 #include <stdio.h> // FILE
31 #ifndef COIN_INTERNAL
32  // For Open Inventor compatibility.
33  #include <Inventor/SoDB.h>
34  #include <Inventor/SbDict.h>
35 #else
36  #define COIN_ALLOW_SBDICT // Coin 2.x hack, for ABI compatibility
37  #include <Inventor/SbDict.h>
38  #undef COIN_ALLOW_SBDICT
39 #endif // COIN_INTERNAL
40 
41 // *************************************************************************
42 
43 class SoBase;
44 class SbString;
45 class SbTime;
46 class SbName;
47 class SbStringList;
48 class SoInput_FileInfo;
49 class SoProto;
50 class SoField;
51 class SoFieldContainer;
52 
53 // *************************************************************************
54 
55 class COIN_DLL_API SoInput {
56 public:
57  SoInput(void);
58  SoInput(SoInput * dictIn);
59 
60  SoProto * findProto(const SbName & name);
61  void addProto(SoProto * proto);
62  void pushProto(SoProto * proto);
63  SoProto * getCurrentProto(void) const;
64  void popProto(void);
65 
66  void addRoute(const SbName & fromnode, const SbName & fromfield,
67  const SbName & tonode, const SbName & tofield);
68  SbBool checkISReference(SoFieldContainer * container, const SbName & fieldname,
69  SbBool & readok);
70 
71  virtual ~SoInput(void);
72 
73  virtual void setFilePointer(FILE * newFP);
74  virtual SbBool openFile(const char * fileName, SbBool okIfNotFound = FALSE);
75  virtual SbBool pushFile(const char * fileName);
76  virtual void closeFile(void);
77  virtual SbBool isValidFile(void);
78  virtual SbBool isValidBuffer(void);
79  virtual FILE * getCurFile(void) const;
80  virtual const char * getCurFileName(void) const;
81  virtual void setBuffer(void * bufpointer, size_t bufsize);
82  void setStringArray(const char * strings[]);
83  virtual size_t getNumBytesRead(void) const;
84  virtual SbString getHeader(void);
85  virtual float getIVVersion(void);
86  virtual SbBool isBinary(void);
87 
88  virtual SbBool get(char & c);
89  virtual SbBool getASCIIBuffer(char & c);
90  virtual SbBool getASCIIFile(char & c);
91  virtual SbBool readHex(uint32_t & l);
92  virtual SbBool read(char & c);
93  virtual SbBool read(char & c, SbBool skip);
94  virtual SbBool read(SbString & s);
95  virtual SbBool read(SbName & n, SbBool validIdent = FALSE);
96  virtual SbBool read(int & i);
97  virtual SbBool read(unsigned int & i);
98  virtual SbBool read(short & s);
99  virtual SbBool read(unsigned short & s);
100  virtual SbBool read(float & f);
101  virtual SbBool read(double & d);
102  virtual SbBool readBinaryArray(unsigned char * c, int length);
103  virtual SbBool readBinaryArray(int32_t * l, int length);
104  virtual SbBool readBinaryArray(float * f, int length);
105  virtual SbBool readBinaryArray(double * d, int length);
106  SbBool readByte(int8_t & b);
107  SbBool readByte(uint8_t & b);
108  virtual SbBool eof(void) const;
109 
110  SbBool isFileVRML1(void);
111  SbBool isFileVRML2(void);
112  virtual void resetFilePointer(FILE * fptr);
113 
114  virtual void getLocationString(SbString & string) const;
115  virtual void putBack(const char c);
116  virtual void putBack(const char * str);
117  virtual void addReference(const SbName & name, SoBase * base,
118  SbBool addToGlobalDict = TRUE);
119  virtual void removeReference(const SbName & name);
120  virtual SoBase * findReference(const SbName & name) const;
121 
122  static void addDirectoryFirst(const char * dirName);
123  static void addDirectoryLast(const char * dirName);
124  static void addEnvDirectoriesFirst(const char * envVarName,
125  const char * separator = ":\t ");
126  static void addEnvDirectoriesLast(const char * envVarName,
127  const char * separator = ":\t ");
128  static void removeDirectory(const char * dirName);
129  static void clearDirectories(void);
130  static const SbStringList & getDirectories(void);
131 
132  static void init(void);
133 
134  static SbString getPathname(const char * const filename);
135  static SbString getPathname(const SbString & s);
136  static SbString getBasename(const char * const filename);
137  static SbString getBasename(const SbString & s);
138 
139  static SbString searchForFile(const SbString & basename,
140  const SbStringList & directories,
141  const SbStringList & subdirectories);
142 
143 
144 protected:
145  virtual SbBool popFile(void);
146  void setIVVersion(float version);
147  FILE * findFile(const char * fileName, SbString & fullName);
148  void initFile(FILE * newFP, const char * fileName, SbString * fullName,
149  SbBool openedHere, SbDict * refDict = (SbDict *) NULL);
150  SbBool checkHeader(SbBool bValidateBufferHeader = FALSE);
151  SbBool fromBuffer(void) const;
152  SbBool skipWhiteSpace(void);
153  size_t freeBytesInBuf(void) const;
154  SbBool readInteger(int32_t & l);
155  SbBool readUnsignedInteger(uint32_t & l);
156  SbBool readReal(double & d);
157  SbBool readUnsignedIntegerString(char * str);
158  int readDigits(char * str);
159  int readHexDigits(char * str);
160  int readChar(char * str, char charToRead);
161 
162  SbBool makeRoomInBuf(size_t nBytes);
163  void convertShort(char * from, short * s);
164  void convertInt32(char * from, int32_t * l);
165  void convertFloat(char * from, float * f);
166  void convertDouble(char * from, double * d);
167  void convertShortArray(char * from, short * to, int len);
168  void convertInt32Array(char * from, int32_t * to, int len);
169  void convertFloatArray(char * from, float * to, int len);
170  void convertDoubleArray(char * from, double * to, int len);
171  SbBool isFileURL(const char * url);
172  char * URLToFile(char * out_buf, const char * in_buf);
173  SbBool IsURL(const char * c_strng);
174 
175  static void setDirectories(SbStringList * dirs);
176 
177 private:
178  friend class SoDB;
179  friend class SoInputP;
180 
181  static void clean(void);
182  void constructorsCommon(void);
183 
184  static void addDirectoryIdx(const int idx, const char * dirName);
185  static void addEnvDirectoriesIdx(int startidx, const char * envVarName,
186  const char * separator);
187  static SbStringList * dirsearchlist;
188 
189  SbList<SoInput_FileInfo *> filestack;
190  SoInput_FileInfo * getTopOfStack(void) const {
191  return this->filestack[0];
192  }
193 
194  // OBSOLETE, only kept for Coin 2.x ABI compatibility.
195  SbDict refdict;
196 };
197 
198 #endif // !COIN_SOINPUT_H
The SoBase class is the top-level superclass for a number of class-hierarchies.SoBase provides the ba...
Definition: SoBase.h:41
The SoDB class keeps track of internal global data.This class collects various methods for initializi...
Definition: SoDB.h:46
The SoFieldContainer class is a base class for all classes that contain fields.The classes containing...
Definition: SoFieldContainer.h:35
The SoField class is the top-level abstract base class for fields.Fields is the mechanism used throug...
Definition: SoField.h:38
The SbDict class organizes a dictionary of keys and values.It uses hashing to quickly insert and find...
Definition: SbDict.h:47
The SbTime class instances represents time values.SbTime is a convenient way of doing system independ...
Definition: SbTime.h:41
The SoInput class is an abstraction of file import functionality.This class takes care of most of the...
Definition: SoInput.h:55
The SbString class is a string class with convenience functions for string operations.This is the class used for storing and working with character strings. It automatically takes care of supporting all the &quot;bookkeeping&quot; tasks usually associated with working with character strings, like memory allocation and deallocation etc.
Definition: SbString.h:42
The SbName class stores strings by reference.The class is used by Coin for storing keywords...
Definition: SbName.h:31
The SbStringList class is a container for arrays of SbString pointers.Note that upon using the equali...
Definition: SbStringList.h:31

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

Generated on Sun Dec 17 2017 for Coin by Doxygen. 1.8.5