From: Alexander Schmidt Date: Tue, 9 Dec 2014 12:35:13 +0000 (+0100) Subject: Made c++11 standard dependency obsolete. X-Git-Url: http://git.treefish.org/~alex/phys/latlib.git/commitdiff_plain/8d11db1cf57b103fcec701d71c9d620b1c381b73?ds=sidebyside Made c++11 standard dependency obsolete. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 9558c25..668888b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ project(latlib) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") #PROFILING #set(CMAKE_CXX_FLAGS -pg) diff --git a/datread.cpp b/datread.cpp index 4a0e31d..f4bf393 100644 --- a/datread.cpp +++ b/datread.cpp @@ -16,17 +16,20 @@ int datread::openFile (const string& filename) if ( ! infile.is_open() ) return -1; if( filename.substr(filename.size()-4) == ".dat" ) { - format = Format::DAT; + format = DAT; } else if( filename.substr(filename.size()-4) == "edat" ) { - format = Format::EDAT; + format = EDAT; } else if( filename.substr(filename.size()-4) == "sdat" ) { - format = Format::SDAT; + format = SDAT; getline(infile, parastring); } - inbuffer = unique_ptr(new boost::iostreams::filtering_istreambuf); + if ( inbuffer != NULL ) + delete inbuffer; + + inbuffer = new boost::iostreams::filtering_istreambuf; inbuffer->push( boost::iostreams::bzip2_decompressor() ); inbuffer->push(infile); @@ -121,7 +124,7 @@ int datread::readFullBlock (char *tmpData) return -4; /* try to read header */ - if ( format == Format::EDAT || format == Format::SDAT ) + if ( format == EDAT || format == SDAT ) if ( ! readAllHeaders() ) { infile.close(); return -1; @@ -173,3 +176,9 @@ void datread::closeFile () if ( infile.is_open() ) infile.close(); } + +datread::~datread () +{ + if ( inbuffer != NULL ) + delete inbuffer; +} diff --git a/datread.h b/datread.h index 64fd850..802ec17 100644 --- a/datread.h +++ b/datread.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -12,9 +13,10 @@ using namespace std; class datread { public: + ~datread (); datread (const unsigned int& _blocksize, ostream *_log=NULL); int openFile (const string& filename); - enum class Format {DAT, EDAT, SDAT}; + enum Format {DAT, EDAT, SDAT}; void * getHeader (const string& headerid); int readFullBlock (char *tmpData); bool fisopen (); @@ -25,7 +27,7 @@ class datread { ifstream infile; Format format; string parastring; - unique_ptr inbuffer; + boost::iostreams::filtering_istreambuf *inbuffer; ostream * const log; int readDataToMem (char *tmpData, long unsigned int dataSize); string filename;