1
/****************************************************************************
2
** $Id: dl_writer_ascii.cpp 242 2004-04-12 22:39:43Z andrew $
4
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
5
** Copyright (C) 2001 Robert J. Campbell Jr.
7
** This file is part of the dxflib project.
9
** This file may be distributed and/or modified under the terms of the
10
** GNU General Public License version 2 as published by the Free Software
11
** Foundation and appearing in the file LICENSE.GPL included in the
12
** packaging of this file.
14
** Licensees holding valid dxflib Professional Edition licenses may use
15
** this file in accordance with the dxflib Commercial License
16
** Agreement provided with the Software.
18
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
19
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21
** See http://www.ribbonsoft.com for further details.
23
** Contact info@ribbonsoft.com if any conditions of this licensing are
26
**********************************************************************/
31
#include "dl_writer_ascii.h"
32
#include "dl_exception.h"
36
* Closes the output file.
38
void DL_WriterA::close() const
45
* @retval true Opening file has failed.
46
* @retval false Otherwise.
48
bool DL_WriterA::openFailed() const
50
return m_ofile.fail();
56
* Writes a real (double) variable to the DXF file.
58
* @param gc Group code.
59
* @param value Double value
61
void DL_WriterA::dxfReal( int gc, double value ) const
64
sprintf( str, "%.16f", value );
66
// fix for german locale:
67
strReplace( str, ',', '.' );
69
// Cut away those zeros at the end:
72
for ( unsigned int i = 0; i < strlen( str ); ++i )
80
else if ( dot && str[i] != '0' )
85
if ( end > 0 && end < ( int )strlen( str ) )
97
* Writes an int variable to the DXF file.
99
* @param gc Group code.
100
* @param value Int value
102
void DL_WriterA::dxfInt( int gc, int value ) const
104
m_ofile << ( gc < 10 ? " " : ( gc < 100 ? " " : "" ) ) << gc << "\n"
111
* Writes a hex int variable to the DXF file.
113
* @param gc Group code.
114
* @param value Int value
116
void DL_WriterA::dxfHex( int gc, int value ) const
119
sprintf( str, "%0X", value );
120
dxfString( gc, str );
126
* Writes a string variable to the DXF file.
128
* @param gc Group code.
129
* @param value String
131
void DL_WriterA::dxfString( int gc, const char* value ) const
136
throw DL_NullStrExc();
139
m_ofile << ( gc < 10 ? " " : ( gc < 100 ? " " : "" ) ) << gc << "\n"
145
void DL_WriterA::dxfString( int gc, const string& value ) const
147
m_ofile << ( gc < 10 ? " " : ( gc < 100 ? " " : "" ) ) << gc << "\n"
153
* Replaces every occurence of src with dest in the null terminated str.
155
void DL_WriterA::strReplace( char* str, char src, char dest )
158
for ( i = 0; i < strlen( str ); i++ )