root/include/io_errorStream.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /*! \file io_errorStream.h
   2     \brief Providing a costume stream 
   3 
   4     Revision history:
   5     --------------------------------------------------
   6 
   7          Revised by Christian Power April 2016
   8          Revised by Christian Power February 2016
   9          Originally written by Christian Power
  10               (power22c@gmail.com) Januar 2016
  11 
  12     Idea
  13     --------------------------------------------------
  14     Provides a wrapper class for fstream, that is compatible with the 
  15     Esfem::Io::Parameter class.  
  16 
  17     \author Christian Power
  18     \date 25. April 2016
  19     \copyright Copyright (c) 2016 Christian Power.  All rights reserved.
  20  */
  21 
  22 #ifndef IO_ERRORSTREAM_H
  23 #define IO_ERRORSTREAM_H 
  24 
  25 #include <fstream>
  26 #include "esfem_fwd.h"
  27 
  28 namespace Esfem{
  29   namespace Io{
  30     //! Wrapper class for a std::stream
  31     class Error_stream{
  32     public:
  33       //! `filename` will be `Io::Parameter::error_log` 
  34       explicit Error_stream(const Parameter&);
  35       //! `filename` will be `Io::Parameter::error_log + suffix` 
  36       explicit Error_stream(const std::string& suffix, const Parameter&);
  37 
  38       // ----------------------------------------------------------------------
  39       // Providing 'endl', 'scientific' and 'defaultfloat'
  40       //! Auxiliary typedef
  41       using Basic_ostream = std::basic_ostream<char, std::char_traits<char> >;
  42       //! The type of std::endl, std::float, etc.
  43       using StdManip = Basic_ostream& (*)(Basic_ostream&);
  44       //! Now you can use std::endl, etc.
  45       Error_stream& operator<<(StdManip);
  46 
  47       //! Stream type `T` out
  48       template<typename T>
  49       Error_stream& operator<<(const T&);
  50       //! Close the stream
  51       Error_stream& close();
  52     private:
  53       //! The actual stream implementation
  54       std::ofstream ofs;
  55 
  56       //! Constructor helper function
  57       explicit Error_stream(const std::string& fname);
  58       // filename is fname
  59     };
  60 
  61     // ----------------------------------------------------------------------
  62     // Template implementation
  63     template<typename T>
  64     Error_stream& Error_stream::operator<<(const T& t){
  65       ofs << t;
  66       return *this;
  67     }
  68   } 
  69 }
  70 
  71 #endif // IO_ERRORSTREAM_H
  72 
  73 /*! Log:
  74  */

/* [<][>][^][v][top][bottom][index][help] */