~librecad-dev/librecad/librecad

« back to all changes in this revision

Viewing changes to libraries/libdxfrw/src/intern/dxfreader.h

  • Committer: Scott Howard
  • Date: 2014-02-21 19:07:55 UTC
  • Revision ID: showard@debian.org-20140221190755-csjax9wb146hgdq4
first commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************************************
 
2
**  libDXFrw - Library to read/write DXF files (ascii & binary)              **
 
3
**                                                                           **
 
4
**  Copyright (C) 2011 Rallaz, rallazz@gmail.com                             **
 
5
**                                                                           **
 
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
******************************************************************************/
 
12
 
 
13
#ifndef DXFREADER_H
 
14
#define DXFREADER_H
 
15
 
 
16
#include "drw_textcodec.h"
 
17
 
 
18
class dxfReader {
 
19
public:
 
20
    dxfReader(std::ifstream *stream){
 
21
        filestr = stream;
 
22
#ifdef DRW_DBG
 
23
        count =0;
 
24
#endif
 
25
    }
 
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();}
 
48
#ifdef DRW_DBG
 
49
    int count;//DBG
 
50
#endif
 
51
protected:
 
52
    std::ifstream *filestr;
 
53
    std::string strData;
 
54
    double doubleData;
 
55
    signed int intData; //32 bits integer
 
56
    unsigned long long int int64; //64 bits integer
 
57
private:
 
58
    DRW_TextCodec decoder;
 
59
};
 
60
 
 
61
class dxfReaderBinary : public dxfReader {
 
62
public:
 
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();
 
73
};
 
74
 
 
75
class dxfReaderAscii : public dxfReader {
 
76
public:
 
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();
 
87
};
 
88
 
 
89
#endif // DXFREADER_H