xc
StandardStreamWrapper.h
1 // -*-c++-*-
2 //----------------------------------------------------------------------------
3 // xc utils library; general purpose classes and functions.
4 //
5 // Copyright (C) Luis C. PĂ©rez Tato
6 //
7 // XC utils is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // This software is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program.
19 // If not, see <http://www.gnu.org/licenses/>.
20 //----------------------------------------------------------------------------
21 //log_file.h
22 //Standard stream redirection.
23 
24 #ifndef STANDARD_STREAM_WRAPPER_H
25 #define STANDARD_STREAM_WRAPPER_H
26 
27 #include <iostream>
28 #include <fstream>
29 #include <string>
30 
32 //
35  {
36  std::string fileName;
37  std::ostream &standardStream;
38  std::ofstream *customStream;
39  std::streambuf *standardStreamBuffer;
40  protected:
41  void free(void);
42  void alloc(const std::string &);
43  public:
44  StandardStreamWrapper(const std::string &, std::ostream &);
46  void reset(void);
47  std::ostream &getStream(void);
48  inline const std::string &getFileName(void) const
49  { return fileName; }
50  void setFileName(const std::string &);
51  };
52 
53 #endif
~StandardStreamWrapper(void)
Destructor.
Definition: StandardStreamWrapper.cc:67
void alloc(const std::string &)
Allocates memory.
Definition: StandardStreamWrapper.cc:37
Standard stream redirection.
Definition: StandardStreamWrapper.h:34
void free(void)
Frees memory.
Definition: StandardStreamWrapper.cc:26
StandardStreamWrapper(const std::string &, std::ostream &)
Constructor.
Definition: StandardStreamWrapper.cc:61
void reset(void)
Fall back to the standard buffer.
Definition: StandardStreamWrapper.cc:53