SHAPE_FILE_IO: default constructor outputs to stdout

This commit is contained in:
Tomasz Włostowski 2017-11-29 19:49:50 +01:00
parent 316ddadec1
commit dbdf085555
2 changed files with 13 additions and 2 deletions

View File

@ -28,6 +28,13 @@
#include <geometry/shape.h> #include <geometry/shape.h>
#include <geometry/shape_file_io.h> #include <geometry/shape_file_io.h>
SHAPE_FILE_IO::SHAPE_FILE_IO()
{
m_groupActive = false;
m_mode = IOM_WRITE;
m_file = stdout;
}
SHAPE_FILE_IO::SHAPE_FILE_IO( const std::string& aFilename, SHAPE_FILE_IO::IO_MODE aMode ) SHAPE_FILE_IO::SHAPE_FILE_IO( const std::string& aFilename, SHAPE_FILE_IO::IO_MODE aMode )
{ {
m_groupActive = false; m_groupActive = false;
@ -61,7 +68,10 @@ SHAPE_FILE_IO::~SHAPE_FILE_IO()
if( m_groupActive && m_mode != IOM_READ ) if( m_groupActive && m_mode != IOM_READ )
fprintf( m_file, "endgroup\n" ); fprintf( m_file, "endgroup\n" );
fclose( m_file ); if ( m_file != stdout )
{
fclose( m_file );
}
} }
@ -143,4 +153,4 @@ void SHAPE_FILE_IO::Write( const SHAPE* aShape, const std::string aName )
fprintf( m_file, "shape %d %s %s\n", aShape->Type(), aName.c_str(), sh.c_str() ); fprintf( m_file, "shape %d %s %s\n", aShape->Type(), aName.c_str(), sh.c_str() );
fflush( m_file ); fflush( m_file );
} }

View File

@ -45,6 +45,7 @@ class SHAPE_FILE_IO
IOM_WRITE IOM_WRITE
}; };
SHAPE_FILE_IO();
SHAPE_FILE_IO( const std::string& aFilename, IO_MODE aMode = IOM_READ ); SHAPE_FILE_IO( const std::string& aFilename, IO_MODE aMode = IOM_READ );
~SHAPE_FILE_IO(); ~SHAPE_FILE_IO();