00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef DIME_INPUT_H
00031 #define DIME_INPUT_H
00032
00033 #include <dime/Basic.h>
00034 #include <dime/util/Array.h>
00035
00036 #define DXF_MAXLINELEN 4096
00037
00038 class dimeInput
00039 {
00040 public:
00041 dimeInput();
00042 ~dimeInput();
00043
00044 bool setFileHandle(FILE *fp);
00045 bool setFile(const char * const filename);
00046 bool setFilePointer(const int fd);
00047 bool eof() const;
00048 void setCallback(int (*cb)(float, void *), void *cbdata);
00049 float relativePosition();
00050
00051 void putBackGroupCode(const int32 code);
00052 bool readGroupCode(int32 &code);
00053 bool readInt8(int8 &val);
00054 bool readInt16(int16 &val);
00055 bool readInt32(int32 &val);
00056 bool readFloat(float &val);
00057 bool readDouble(dxfdouble &val);
00058 const char *readString();
00059
00060 class dimeModel *getModel();
00061 class dimeMemHandler *getMemHandler();
00062
00063 int getFilePosition() const;
00064
00065 bool isBinary() const;
00066 int getVersion() const;
00067 bool isAborted() const;
00068
00069 private:
00070 friend class dimeModel;
00071 dimeModel *model;
00072 int filePosition;
00073 bool binary;
00074 bool binary16bit;
00075 int version;
00076
00077 int fd;
00078 #ifdef USE_GZFILE
00079 void *gzfp;
00080 bool gzeof;
00081 #else // ! USE_GZFILE
00082 FILE *fp;
00083 bool fpeof;
00084 #endif // ! USE_GZFILE
00085 long filesize;
00086 char *readbuf;
00087 int readbufIndex;
00088 int readbufLen;
00089
00090 dimeArray <char> backBuf;
00091 int backBufIndex;
00092
00093 char lineBuf[DXF_MAXLINELEN];
00094 int32 putBackCode;
00095 bool hasPutBack;
00096 int (*callback)(float, void*);
00097 void *callbackdata;
00098 float prevposition;
00099 int cbcnt;
00100 bool aborted;
00101 bool prevwashandle;
00102 bool didOpenFile;
00103 bool endianSwap;
00104
00105 private:
00106 bool init();
00107 bool doBufferRead();
00108 void putBack(const char c);
00109 void putBack(const char * const string);
00110 bool get(char &c);
00111 bool read(char &c);
00112 bool skipWhiteSpace();
00113 bool nextLine();
00114 bool readInteger(long &l);
00115 bool readUnsignedInteger(unsigned long &l);
00116 bool readUnsignedIntegerString(char * const str);
00117 int readDigits(char * const string);
00118 int readHexDigits(char * const string);
00119 int readChar(char * const string, char charToRead);
00120 bool readReal(dxfdouble &d);
00121 bool checkBinary();
00122 };
00123
00124 #endif // ! DIME_INPUT_H
00125