mlpack  2.2.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
prefixedoutstream.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_CORE_UTIL_PREFIXEDOUTSTREAM_HPP
14 #define MLPACK_CORE_UTIL_PREFIXEDOUTSTREAM_HPP
15 
16 #include <mlpack/prereqs.hpp>
17 
18 namespace mlpack {
19 namespace util {
20 
47 {
48  public:
59  const char* prefix,
60  bool ignoreInput = false,
61  bool fatal = false) :
62  destination(destination),
64  prefix(prefix),
65  // We want the first call to operator<< to prefix the prefix so we set
66  // carriageReturned to true.
67  carriageReturned(true),
68  fatal(fatal)
69  { /* nothing to do */ }
70 
72  PrefixedOutStream& operator<<(bool val);
74  PrefixedOutStream& operator<<(short val);
76  PrefixedOutStream& operator<<(unsigned short val);
78  PrefixedOutStream& operator<<(int val);
80  PrefixedOutStream& operator<<(unsigned int val);
82  PrefixedOutStream& operator<<(long val);
84  PrefixedOutStream& operator<<(unsigned long val);
86  PrefixedOutStream& operator<<(float val);
88  PrefixedOutStream& operator<<(double val);
90  PrefixedOutStream& operator<<(long double val);
92  PrefixedOutStream& operator<<(void* val);
94  PrefixedOutStream& operator<<(const char* str);
96  PrefixedOutStream& operator<<(std::string& str);
98  PrefixedOutStream& operator<<(std::streambuf* sb);
100  PrefixedOutStream& operator<<(std::ostream& (*pf)(std::ostream&));
102  PrefixedOutStream& operator<<(std::ios& (*pf)(std::ios&));
104  PrefixedOutStream& operator<<(std::ios_base& (*pf)(std::ios_base&));
105 
107  template<typename T>
108  PrefixedOutStream& operator<<(const T& s);
109 
111  std::ostream& destination;
112 
115 
116  private:
127  template<typename T>
128  typename std::enable_if<!arma::is_arma_type<T>::value>::type
129  BaseLogic(const T& val);
130 
141  template<typename T>
142  typename std::enable_if<arma::is_arma_type<T>::value>::type
143  BaseLogic(const T& val);
144 
148  inline void PrefixIfNeeded();
149 
151  std::string prefix;
152 
155  bool carriageReturned;
156 
159  bool fatal;
160 };
161 
162 } // namespace util
163 } // namespace mlpack
164 
165 // Template definitions.
166 #include "prefixedoutstream_impl.hpp"
167 
168 #endif
The core includes that mlpack expects; standard C++ includes and Armadillo.
PrefixedOutStream & operator<<(bool val)
Write a bool to the stream.
bool ignoreInput
Discards input, prints nothing if true.
PrefixedOutStream(std::ostream &destination, const char *prefix, bool ignoreInput=false, bool fatal=false)
Set up the PrefixedOutStream.
std::ostream & destination
The output stream that all data is to be sent too; example: std::cout.
Allows us to output to an ostream with a prefix at the beginning of each line, in the same way we wou...