Main Page   Class Hierarchy   Compound List   File List   Compound Members  

Input.h

00001 /**************************************************************************\
00002  * 
00003  *  FILE: Input.h
00004  *
00005  *  This source file is part of DIME.
00006  *  Copyright (C) 1998-1999 by Systems In Motion.  All rights reserved.
00007  *
00008  *  This library is free software; you can redistribute it and/or modify it
00009  *  under the terms of the GNU General Public License, version 2, as
00010  *  published by the Free Software Foundation.
00011  *
00012  *  This library is distributed in the hope that it will be useful, but
00013  *  WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  *  General Public License (the accompanying file named COPYING) for more
00016  *  details.
00017  *
00018  **************************************************************************
00019  *
00020  *  If you need DIME for a non-GPL project, contact Systems In Motion
00021  *  to acquire a Professional Edition License:
00022  *
00023  *  Systems In Motion                                   http://www.sim.no/
00024  *  Prof. Brochs gate 6                                       sales@sim.no
00025  *  N-7030 Trondheim                                   Voice: +47 22114160
00026  *  NORWAY                                               Fax: +47 67172912
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;              // set by the dimeModel class.
00072   int filePosition;
00073   bool binary;
00074   bool binary16bit;
00075   int version;
00076 
00077   int fd;
00078 #ifdef USE_GZFILE
00079   void *gzfp; // gzip file pointer
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 }; // class dimeInput
00123 
00124 #endif // ! DIME_INPUT_H
00125 

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