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,8 +68,11 @@ 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" );
if ( m_file != stdout )
{
fclose( m_file ); fclose( m_file );
} }
}
SHAPE* SHAPE_FILE_IO::Read() SHAPE* SHAPE_FILE_IO::Read()

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();