2013-10-24 16:44:38 +00:00
|
|
|
/******************************************************************************
|
|
|
|
** libDXFrw - Library to read/write DXF files (ascii & binary) **
|
|
|
|
** **
|
|
|
|
** Copyright (C) 2011 Rallaz, rallazz@gmail.com **
|
|
|
|
** **
|
|
|
|
** This library is free software, licensed under the terms of the GNU **
|
|
|
|
** General Public License as published by the Free Software Foundation, **
|
|
|
|
** either version 2 of the License, or (at your option) any later version. **
|
|
|
|
** You should have received a copy of the GNU General Public License **
|
|
|
|
** along with this program. If not, see <http://www.gnu.org/licenses/>. **
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#ifndef DXFWRITER_H
|
|
|
|
#define DXFWRITER_H
|
|
|
|
|
|
|
|
#include "drw_textcodec.h"
|
|
|
|
|
2013-10-28 08:06:38 +00:00
|
|
|
class dxfWriter
|
|
|
|
{
|
2013-10-24 16:44:38 +00:00
|
|
|
public:
|
2013-10-28 08:06:38 +00:00
|
|
|
dxfWriter( std::ofstream* stream ) { filestr = stream; /*count =0;*/ }
|
|
|
|
virtual ~dxfWriter() {}
|
|
|
|
virtual bool writeString( int code, std::string text ) = 0;
|
|
|
|
bool writeUtf8String( int code, std::string text );
|
|
|
|
bool writeUtf8Caps( int code, std::string text );
|
|
|
|
|
|
|
|
std::string fromUtf8String( std::string t ) { return encoder.fromUtf8( t ); }
|
|
|
|
virtual bool writeInt16( int code, int data ) = 0;
|
|
|
|
virtual bool writeInt32( int code, int data ) = 0;
|
|
|
|
virtual bool writeInt64( int code, unsigned long long int data ) = 0;
|
2015-02-24 09:07:40 +00:00
|
|
|
virtual bool writeDouble( int code, double data ) = 0;
|
|
|
|
virtual bool writeBool( int code, bool data ) = 0;
|
2013-10-28 08:06:38 +00:00
|
|
|
|
|
|
|
void setVersion( std::string* v ) { encoder.setVersion( v ); }
|
|
|
|
void setCodePage( std::string* c ) { encoder.setCodePage( c ); }
|
|
|
|
std::string getCodePage() { return encoder.getCodePage(); }
|
2015-02-24 09:07:40 +00:00
|
|
|
|
2013-10-24 16:44:38 +00:00
|
|
|
protected:
|
2015-02-24 09:07:40 +00:00
|
|
|
std::ofstream* filestr;
|
|
|
|
|
2013-10-24 16:44:38 +00:00
|
|
|
private:
|
2015-02-24 09:07:40 +00:00
|
|
|
DRW_TextCodec encoder;
|
2013-10-24 16:44:38 +00:00
|
|
|
};
|
|
|
|
|
2013-10-28 08:06:38 +00:00
|
|
|
class dxfWriterBinary : public dxfWriter
|
|
|
|
{
|
2013-10-24 16:44:38 +00:00
|
|
|
public:
|
2015-02-24 09:07:40 +00:00
|
|
|
dxfWriterBinary( std::ofstream* stream ) : dxfWriter( stream ) {}
|
2013-10-24 16:44:38 +00:00
|
|
|
virtual ~dxfWriterBinary() {}
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual bool writeString( int code, std::string text ) override;
|
|
|
|
virtual bool writeInt16( int code, int data ) override;
|
|
|
|
virtual bool writeInt32( int code, int data ) override;
|
|
|
|
virtual bool writeInt64( int code, unsigned long long int data ) override;
|
|
|
|
virtual bool writeDouble( int code, double data ) override;
|
|
|
|
virtual bool writeBool( int code, bool data ) override;
|
2013-10-24 16:44:38 +00:00
|
|
|
};
|
|
|
|
|
2013-10-28 08:06:38 +00:00
|
|
|
class dxfWriterAscii : public dxfWriter
|
|
|
|
{
|
2013-10-24 16:44:38 +00:00
|
|
|
public:
|
2015-02-24 09:07:40 +00:00
|
|
|
dxfWriterAscii( std::ofstream* stream ) : dxfWriter( stream ) {}
|
2013-10-28 08:06:38 +00:00
|
|
|
virtual ~dxfWriterAscii() {}
|
2016-09-24 18:53:15 +00:00
|
|
|
virtual bool writeString( int code, std::string text ) override;
|
|
|
|
virtual bool writeInt16( int code, int data ) override;
|
|
|
|
virtual bool writeInt32( int code, int data ) override;
|
|
|
|
virtual bool writeInt64( int code, unsigned long long int data ) override;
|
|
|
|
virtual bool writeDouble( int code, double data ) override;
|
|
|
|
virtual bool writeBool( int code, bool data ) override;
|
2013-10-24 16:44:38 +00:00
|
|
|
};
|
|
|
|
|
2013-10-28 08:06:38 +00:00
|
|
|
#endif // DXFWRITER_H
|