1
/******************************************************************************
2
** libDXFrw - Library to read/write DXF files (ascii & binary) **
4
** Copyright (C) 2011 Rallaz, rallazz@gmail.com **
6
** This library is free software, licensed under the terms of the GNU **
7
** General Public License as published by the Free Software Foundation, **
8
** either version 2 of the License, or (at your option) any later version. **
9
** You should have received a copy of the GNU General Public License **
10
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
11
******************************************************************************/
16
#include "drw_textcodec.h"
20
dxfReader(std::ifstream *stream){
26
virtual ~dxfReader(){}
27
virtual bool readCode(int *code) = 0; //return true if sucesful (not EOF)
28
virtual bool readString(std::string *text) = 0;
29
virtual bool readString() = 0;
30
bool readRec(int *code, bool skip);
31
virtual bool readInt() = 0;
32
virtual bool readInt32() = 0;
33
virtual bool readInt64() = 0;
34
virtual bool readDouble() = 0;
35
virtual bool readBool() = 0;
36
std::string getString() {return strData;}
37
int getHandleString();//Convert hex string to int
38
std::string toUtf8String(std::string t) {return decoder.toUtf8(t);}
39
std::string getUtf8String() {return decoder.toUtf8(strData);}
40
double getDouble() {return doubleData;}
41
int getInt32() {return intData;}
42
unsigned long long int getInt64() {return int64;}
43
bool getBool() { return (intData==0) ? false : true;}
44
int getVersion(){return decoder.getVersion();}
45
void setVersion(std::string *v){decoder.setVersion(v);}
46
void setCodePage(std::string *c){decoder.setCodePage(c);}
47
std::string getCodePage(){ return decoder.getCodePage();}
52
std::ifstream *filestr;
55
signed int intData; //32 bits integer
56
unsigned long long int int64; //64 bits integer
58
DRW_TextCodec decoder;
61
class dxfReaderBinary : public dxfReader {
63
dxfReaderBinary(std::ifstream *stream):dxfReader(stream){ }
64
virtual ~dxfReaderBinary() {}
65
virtual bool readCode(int *code);
66
virtual bool readString(std::string *text);
67
virtual bool readString();
68
virtual bool readInt();
69
virtual bool readInt32();
70
virtual bool readInt64();
71
virtual bool readDouble();
72
virtual bool readBool();
75
class dxfReaderAscii : public dxfReader {
77
dxfReaderAscii(std::ifstream *stream):dxfReader(stream){ }
78
virtual ~dxfReaderAscii(){}
79
virtual bool readCode(int *code);
80
virtual bool readString(std::string *text);
81
virtual bool readString();
82
virtual bool readInt();
83
virtual bool readDouble();
84
virtual bool readInt32();
85
virtual bool readInt64();
86
virtual bool readBool();