| 1 |
/* Copyright (C) 1992-1998 The Geometry Center |
| 2 |
* Copyright (C) 1998-2000 Stuart Levy, Tamara Munzner, Mark Phillips |
| 3 |
* |
| 4 |
* This file is part of Geomview. |
| 5 |
* |
| 6 |
* Geomview is free software; you can redistribute it and/or modify it |
| 7 |
* under the terms of the GNU Lesser General Public License as published |
| 8 |
* by the Free Software Foundation; either version 2, or (at your option) |
| 9 |
* any later version. |
| 10 |
* |
| 11 |
* Geomview is distributed in the hope that it will be useful, but |
| 12 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 |
* Lesser General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU Lesser General Public |
| 17 |
* License along with Geomview; see the file COPYING. If not, write |
| 18 |
* to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, |
| 19 |
* USA, or visit http://www.gnu.org. |
| 20 |
*/ |
| 21 |
#ifndef _QV_INPUT_ |
| 22 |
#define _QV_INPUT_ |
| 23 |
|
| 24 |
#include <QvDict.h> |
| 25 |
#include <QvString.h> |
| 26 |
|
| 27 |
class QvNode; |
| 28 |
class QvDB; |
| 29 |
|
| 30 |
class QvInput { |
| 31 |
public: |
| 32 |
|
| 33 |
QvInput(); |
| 34 |
~QvInput(); |
| 35 |
|
| 36 |
static float isASCIIHeader(const char *string); |
| 37 |
void setFilePointer(FILE *newFP); |
| 38 |
FILE * getCurFile() const { return fp; } |
| 39 |
float getVersion(); |
| 40 |
QvBool get(char &c); |
| 41 |
QvBool read(char &c); |
| 42 |
QvBool read(QvString &s); |
| 43 |
QvBool read(QvName &n, QvBool validIdent = FALSE); |
| 44 |
QvBool read(int &i); |
| 45 |
QvBool read(unsigned int &i); |
| 46 |
QvBool read(short &s); |
| 47 |
QvBool read(unsigned short &s); |
| 48 |
QvBool read(long &l); |
| 49 |
QvBool read(unsigned long &l); |
| 50 |
QvBool read(float &f); |
| 51 |
QvBool read(double &d); |
| 52 |
QvBool eof() const; |
| 53 |
void getLocationString(QvString &string) const; |
| 54 |
void putBack(char c); |
| 55 |
void putBack(const char *string); |
| 56 |
void addReference(const QvName &name, QvNode *node); |
| 57 |
QvNode * findReference(const QvName &name) const; |
| 58 |
|
| 59 |
private: |
| 60 |
FILE *fp; // File pointer |
| 61 |
int lineNum; // Number of line currently reading |
| 62 |
float version; // Version number of file |
| 63 |
QvBool readHeader; // TRUE if header was checked for A/B |
| 64 |
QvBool headerOk; // TRUE if header was read ok |
| 65 |
QvDict refDict; // Node reference dictionary |
| 66 |
QvString backBuf; |
| 67 |
int backBufIndex; |
| 68 |
|
| 69 |
QvBool checkHeader(); |
| 70 |
|
| 71 |
QvBool skipWhiteSpace(); |
| 72 |
|
| 73 |
QvBool readInteger(long &l); |
| 74 |
QvBool readUnsignedInteger(unsigned long &l); |
| 75 |
QvBool readReal(double &d); |
| 76 |
QvBool readUnsignedIntegerString(char *str); |
| 77 |
int readDigits(char *string); |
| 78 |
int readHexDigits(char *string); |
| 79 |
int readChar(char *string, char charToRead); |
| 80 |
|
| 81 |
friend class QvNode; |
| 82 |
friend class QvDB; |
| 83 |
}; |
| 84 |
|
| 85 |
#endif /* _QV_INPUT_ */ |