From 8d11db1cf57b103fcec701d71c9d620b1c381b73 Mon Sep 17 00:00:00 2001
From: Alexander Schmidt <alex@treefish.org>
Date: Tue, 9 Dec 2014 13:35:13 +0100
Subject: [PATCH 1/1] Made c++11 standard dependency obsolete.

---
 CMakeLists.txt |  2 +-
 datread.cpp    | 19 ++++++++++++++-----
 datread.h      |  6 ++++--
 3 files changed, 19 insertions(+), 8 deletions(-)

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<boost::iostreams::filtering_istreambuf>(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 <ostream>
 #include <fstream>
 #include <memory>
+#include <vector>
 
 #include <boost/iostreams/filtering_streambuf.hpp>
 #include <boost/iostreams/filter/bzip2.hpp>
@@ -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<boost::iostreams::filtering_istreambuf> inbuffer;
+  boost::iostreams::filtering_istreambuf *inbuffer;
   ostream * const log;
   int readDataToMem (char *tmpData, long unsigned int dataSize);
   string filename;
-- 
2.39.5