Changeset 2052


Ignore:
Timestamp:
Sep 6, 2009, 6:59:15 PM (11 years ago)
Author:
Peter
Message:

added constructor that creates and internal ifstream. refs #521.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/utility/StreamRedirect.h

    r2051 r2052  
    6464                        std::basic_istream<charT, traits>& is2,
    6565                        bool active=true);
     66   
     67    /**
     68       Constructor for istream
     69
     70       If \a active is false, the class does nothing.
     71    */
     72    BasicStreamRedirect(std::basic_istream<charT, traits>& os1,
     73                        const std::string& file, bool active=true);
    6674   
    6775    /**
     
    142150  template<class charT, class traits>
    143151  BasicStreamRedirect<charT, traits>::
     152  BasicStreamRedirect(std::basic_istream<charT, traits>& is,
     153                      const std::string& file, bool active)
     154    : buf_(NULL), ifs_(NULL), ios_(NULL), ofs_(NULL)
     155  {
     156    if (active) {
     157      ifs_ = new std::basic_ifstream<charT, traits>(file.c_str());
     158      init(is, *ofs_, active);
     159    }
     160  }
     161 
     162 
     163  template<class charT, class traits>
     164  BasicStreamRedirect<charT, traits>::
    144165  BasicStreamRedirect(std::basic_ostream<charT, traits>& os1,
    145166                      std::basic_ostream<charT, traits>& os2, bool active)
     
    152173  template<class charT, class traits>
    153174  BasicStreamRedirect<charT, traits>::
    154   BasicStreamRedirect(std::basic_ostream<charT, traits>& os1,
     175  BasicStreamRedirect(std::basic_ostream<charT, traits>& os,
    155176                      const std::string& file, bool active)
    156177    : buf_(NULL), ifs_(NULL), ios_(NULL), ofs_(NULL)
     
    158179    if (active) {
    159180      ofs_ = new std::basic_ofstream<charT, traits>(file.c_str());
    160       init(os1, *ofs_, active);
     181      init(os, *ofs_, active);
    161182    }
    162183  }
Note: See TracChangeset for help on using the changeset viewer.