Input.h
1 /**************************************************************************\
2  *
3  * FILE: Input.h
4  *
5  * This source file is part of DIME.
6  * Copyright (C) 1998-1999 by Systems In Motion. All rights reserved.
7  *
8  * This library is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License, version 2, as
10  * published by the Free Software Foundation.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License (the accompanying file named COPYING) for more
16  * details.
17  *
18  **************************************************************************
19  *
20  * If you need DIME for a non-GPL project, contact Systems In Motion
21  * to acquire a Professional Edition License:
22  *
23  * Systems In Motion http://www.sim.no/
24  * Prof. Brochs gate 6 sales@sim.no
25  * N-7030 Trondheim Voice: +47 22114160
26  * NORWAY Fax: +47 67172912
27  *
28 \**************************************************************************/
29 
30 #ifndef DIME_INPUT_H
31 #define DIME_INPUT_H
32 
33 #include <dime/Basic.h>
34 #include <dime/util/Array.h>
35 
36 #define DXF_MAXLINELEN 4096
37 
38 class DIME_DLL_API dimeInput
39 {
40 public:
41  dimeInput();
42  ~dimeInput();
43 
44  bool setFileHandle(FILE *fp);
45  bool setFile(const char * const filename);
46  bool setFilePointer(const int fd);
47  bool eof() const;
48  void setCallback(int (*cb)(float, void *), void *cbdata);
49  float relativePosition();
50 
51  void putBackGroupCode(const int32 code);
52  bool readGroupCode(int32 &code);
53  bool readInt8(int8 &val);
54  bool readInt16(int16 &val);
55  bool readInt32(int32 &val);
56  bool readFloat(float &val);
57  bool readDouble(dxfdouble &val);
58  const char *readString();
59 
60  class dimeModel *getModel();
61  class dimeMemHandler *getMemHandler();
62 
63  int getFilePosition() const;
64 
65  bool isBinary() const;
66  int getVersion() const;
67  bool isAborted() const;
68 
69 private:
70  friend class dimeModel;
71  dimeModel *model; // set by the dimeModel class.
72  int filePosition;
73  bool binary;
74  bool binary16bit;
75  int version;
76 
77  int fd;
78 #ifdef USE_GZFILE
79  void *gzfp; // gzip file pointer
80  bool gzeof;
81 #else // ! USE_GZFILE
82  FILE *fp;
83  bool fpeof;
84 #endif // ! USE_GZFILE
85  long filesize;
86  char *readbuf;
87  int readbufIndex;
88  int readbufLen;
89 
90  dimeArray <char> backBuf;
91  int backBufIndex;
92 
93  char lineBuf[DXF_MAXLINELEN];
94  int32 putBackCode;
95  bool hasPutBack;
96  int (*callback)(float, void*);
97  void *callbackdata;
98  float prevposition;
99  int cbcnt;
100  bool aborted;
101  bool prevwashandle;
102  bool didOpenFile;
103  bool endianSwap;
104 
105 private:
106  bool init();
107  bool doBufferRead();
108  void putBack(const char c);
109  void putBack(const char * const string);
110  bool get(char &c);
111  bool read(char &c);
112  bool skipWhiteSpace();
113  bool nextLine();
114  bool readInteger(long &l);
115  bool readUnsignedInteger(unsigned long &l);
116  bool readUnsignedIntegerString(char * const str);
117  int readDigits(char * const string);
118  int readHexDigits(char * const string);
119  int readChar(char * const string, char charToRead);
120  bool readReal(dxfdouble &d);
121  bool checkBinary();
122 }; // class dimeInput
123 
124 #endif // ! DIME_INPUT_H
125 

Copyright © 1998-1999, Systems In Motion <sales@sim.no>. All rights reserved.
System documentation was generated using doxygen.