| 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) by Kongsberg Oil & Gas Technologies.
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 Kongsberg Oil & Gas Technologies
18 * about acquiring a Coin Professional Edition License.
19 *
20 * See http://www.coin3d.org/ for more information.
21 *
22 * Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, 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 #endif // COIN_INTERNAL
35
36 // *************************************************************************
37
38 class SbDict;
39 class SoBase;
40 class SbString;
41 class SbTime;
42 class SbName;
43 class SbStringList;
44 class SoInput_FileInfo;
45 class SoProto;
46 class SoField;
47 class SoFieldContainer;
48 class SoInputP;
49
50 // *************************************************************************
51
52 class COIN_DLL_API SoInput {
53 public:
54 SoInput(void);
55 SoInput(SoInput * dictIn);
56
57 SoProto * findProto(const SbName & name);
58 void addProto(SoProto * proto);
59 void pushProto(SoProto * proto);
60 SoProto * getCurrentProto(void) const;
61 void popProto(void);
62
63 void addRoute(const SbName & fromnode, const SbName & fromfield,
64 const SbName & tonode, const SbName & tofield);
65 SbBool checkISReference(SoFieldContainer * container, const SbName & fieldname,
66 SbBool & readok);
67
68 virtual ~SoInput(void);
69
70 virtual void setFilePointer(FILE * newFP);
71 virtual SbBool openFile(const char * fileName, SbBool okIfNotFound = FALSE);
72 virtual SbBool pushFile(const char * fileName);
73 virtual void closeFile(void);
74 virtual SbBool isValidFile(void);
75 virtual SbBool isValidBuffer(void);
76 virtual FILE * getCurFile(void) const;
77 virtual const char * getCurFileName(void) const;
78 virtual void setBuffer(void * bufpointer, size_t bufsize);
79 void setStringArray(const char * strings[]);
80 virtual size_t getNumBytesRead(void) const;
81 virtual SbString getHeader(void);
82 virtual float getIVVersion(void);
83 virtual SbBool isBinary(void);
84
85 virtual SbBool get(char & c);
86 virtual SbBool getASCIIBuffer(char & c);
87 virtual SbBool getASCIIFile(char & c);
88 virtual SbBool readHex(uint32_t & l);
89 virtual SbBool read(char & c);
90 virtual SbBool read(char & c, SbBool skip);
91 virtual SbBool read(SbString & s);
92 virtual SbBool read(SbName & n, SbBool validIdent = FALSE);
93 virtual SbBool read(int & i);
94 virtual SbBool read(unsigned int & i);
95 virtual SbBool read(short & s);
96 virtual SbBool read(unsigned short & s);
97 virtual SbBool read(float & f);
98 virtual SbBool read(double & d);
99 virtual SbBool readByte(int8_t & b);
100 virtual SbBool readByte(uint8_t & b);
101 virtual SbBool readBinaryArray(unsigned char * c, int length);
102 virtual SbBool readBinaryArray(int32_t * l, int length);
103 virtual SbBool readBinaryArray(float * f, int length);
104 virtual SbBool readBinaryArray(double * d, int length);
105 virtual SbBool eof(void) const;
106
107 SbBool isFileVRML1(void);
108 SbBool isFileVRML2(void);
109 virtual void resetFilePointer(FILE * fptr);
110
111 virtual void getLocationString(SbString & string) const;
112 virtual void putBack(const char c);
113 virtual void putBack(const char * str);
114 virtual void addReference(const SbName & name, SoBase * base,
115 SbBool addToGlobalDict = TRUE);
116 virtual void removeReference(const SbName & name);
117 virtual SoBase * findReference(const SbName & name) const;
118
119 static void addDirectoryFirst(const char * dirName);
120 static void addDirectoryLast(const char * dirName);
121 static void addEnvDirectoriesFirst(const char * envVarName,
122 const char * separator = ":\t ");
123 static void addEnvDirectoriesLast(const char * envVarName,
124 const char * separator = ":\t ");
125 static void removeDirectory(const char * dirName);
126 static void clearDirectories(void);
127 static const SbStringList & getDirectories(void);
128
129 static void init(void);
130
131 static SbString getPathname(const char * const filename);
132 static SbString getPathname(const SbString & s);
133 static SbString getBasename(const char * const filename);
134 static SbString getBasename(const SbString & s);
135
136 static SbString searchForFile(const SbString & basename,
137 const SbStringList & directories,
138 const SbStringList & subdirectories);
139
140
141 protected:
142 virtual SbBool popFile(void);
143 void setIVVersion(float version);
144 FILE * findFile(const char * fileName, SbString & fullName);
145 void initFile(FILE * newFP, const char * fileName, SbString * fullName,
146 SbBool openedHere, SbDict * refDict = NULL);
147 SbBool checkHeader(SbBool bValidateBufferHeader = FALSE);
148 SbBool fromBuffer(void) const;
149 SbBool skipWhiteSpace(void);
150 size_t freeBytesInBuf(void) const;
151 SbBool readInteger(int32_t & l);
152 SbBool readUnsignedInteger(uint32_t & l);
153 SbBool readReal(double & d);
154 SbBool readUnsignedIntegerString(char * str);
155 int readDigits(char * str);
156 int readHexDigits(char * str);
157 int readChar(char * str, char charToRead);
158
159 SbBool makeRoomInBuf(size_t nBytes);
160 void convertShort(char * from, short * s);
161 void convertInt32(char * from, int32_t * l);
162 void convertFloat(char * from, float * f);
163 void convertDouble(char * from, double * d);
164 void convertShortArray(char * from, short * to, int len);
165 void convertInt32Array(char * from, int32_t * to, int len);
166 void convertFloatArray(char * from, float * to, int len);
167 void convertDoubleArray(char * from, double * to, int len);
168 SbBool isFileURL(const char * url);
169 char * URLToFile(char * out_buf, const char * in_buf);
170 SbBool IsURL(const char * c_strng);
171
172 static void setDirectories(SbStringList * dirs);
173
174 private:
175 friend class SoDB;
176 friend class SoInputP;
177
178 static void clean(void);
179 void constructorsCommon(void);
180
181 static void addDirectoryIdx(const int idx, const char * dirName);
182 static void addEnvDirectoriesIdx(int startidx, const char * envVarName,
183 const char * separator);
184 static SbStringList * dirsearchlist;
185
186 SbList<SoInput_FileInfo *> filestack;
187 SoInput_FileInfo * getTopOfStack(void) const {
188 return this->filestack[0];
189 }
190
191 SoInputP * pimpl;
192 };
193
194 #endif // !COIN_SOINPUT_H
SoBase
The SoBase class is the top-level superclass for a number of class-hierarchies.SoBase provides the ba...
Definition: SoBase.h:36
SoDB
The SoDB class keeps track of internal global data.This class collects various methods for initializi...
Definition: SoDB.h:46
SoFieldContainer
The SoFieldContainer class is a base class for all classes that contain fields.The classes containing...
Definition: SoFieldContainer.h:34
SbList
The SbList class is a template container class for lists.SbList is an extension of the Coin library v...
Definition: SoType.h:46
SoField
The SoField class is the top-level abstract base class for fields.Fields is the mechanism used throug...
Definition: SoField.h:38
SbDict
The SbDict class organizes a dictionary of keys and values.It uses hashing to quickly insert and find...
Definition: SbDict.h:54
SoProto
The SoProto class handles PROTO definitions.
Definition: SoProto.h:41
SbTime
The SbTime class instances represents time values.SbTime is a convenient way of doing system independ...
Definition: SbTime.h:41
SoInput
The SoInput class is an abstraction of file import functionality.This class takes care of most of the...
Definition: SoInput.h:52
SbString
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 "bookkeeping" tasks usually associated with working with character strings, like memory allocation and deallocation etc.
Definition: SbString.h:42
SbName
The SbName class stores strings by reference.The class is used by Coin for storing keywords...
Definition: SbName.h:31
SbStringList
The SbStringList class is a container for arrays of SbString pointers.Note that upon using the equali...
Definition: SbStringList.h:31

Copyright © 1998-2010 by Kongsberg Oil & Gas Technologies. All rights reserved.