mlpack  3.4.2
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:
61  const char* prefix,
62  bool ignoreInput = false,
63  bool fatal = false,
64  bool backtrace = true) :
68  prefix(prefix),
69  // We want the first call to operator<< to prefix the prefix so we set
70  // carriageReturned to true.
71  carriageReturned(true),
72  fatal(fatal)
73  { /* nothing to do */ }
74 
80  PrefixedOutStream& operator<<(unsigned short val);
84  PrefixedOutStream& operator<<(unsigned int val);
88  PrefixedOutStream& operator<<(unsigned long val);
94  PrefixedOutStream& operator<<(long double val);
98  PrefixedOutStream& operator<<(const char* str);
100  PrefixedOutStream& operator<<(std::string& str);
102  PrefixedOutStream& operator<<(std::streambuf* sb);
104  PrefixedOutStream& operator<<(std::ostream& (*pf)(std::ostream&));
106  PrefixedOutStream& operator<<(std::ios& (*pf)(std::ios&));
108  PrefixedOutStream& operator<<(std::ios_base& (*pf)(std::ios_base&));
109 
111  template<typename T>
113 
116  std::ostream& destination;
117 
120 
123  bool backtrace;
124 
125  private:
136  template<typename T>
137  typename std::enable_if<!arma::is_arma_type<T>::value>::type
138  BaseLogic(const T& val);
139 
150  template<typename T>
151  typename std::enable_if<arma::is_arma_type<T>::value>::type
152  BaseLogic(const T& val);
153 
157  inline void PrefixIfNeeded();
158 
160  std::string prefix;
161 
164  bool carriageReturned;
165 
168  bool fatal;
169 };
170 
171 } // namespace util
172 } // namespace mlpack
173 
174 // Template definitions.
175 #include "prefixedoutstream_impl.hpp"
176 
177 #endif
mlpack::util::PrefixedOutStream::operator<<
PrefixedOutStream & operator<<(std::ios &(*pf)(std::ios &))
Write an ios manipulator function to the stream.
mlpack::util::PrefixedOutStream::PrefixedOutStream
PrefixedOutStream(std::ostream &destination, const char *prefix, bool ignoreInput=false, bool fatal=false, bool backtrace=true)
Set up the PrefixedOutStream.
Definition: prefixedoutstream.hpp:60
prereqs.hpp
The core includes that mlpack expects; standard C++ includes and Armadillo.
mlpack::util::PrefixedOutStream::operator<<
PrefixedOutStream & operator<<(int val)
Write an int to the stream.
mlpack::util::PrefixedOutStream::operator<<
PrefixedOutStream & operator<<(long val)
Write a long to the stream.
mlpack::util::PrefixedOutStream::operator<<
PrefixedOutStream & operator<<(void *val)
Write a void pointer to the stream.
mlpack::util::PrefixedOutStream::operator<<
PrefixedOutStream & operator<<(unsigned long val)
Write an unsigned long to the stream.
mlpack::util::PrefixedOutStream::destination
std::ostream & destination
The output stream that all data is to be sent to; example: MLPACK_COUT_STREAM.
Definition: prefixedoutstream.hpp:116
mlpack::util::PrefixedOutStream::operator<<
PrefixedOutStream & operator<<(const T &s)
Write anything else to the stream.
mlpack::util::PrefixedOutStream::operator<<
PrefixedOutStream & operator<<(bool val)
Write a bool to the stream.
mlpack::util::PrefixedOutStream::ignoreInput
bool ignoreInput
Discards input, prints nothing if true.
Definition: prefixedoutstream.hpp:119
mlpack
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: add_to_cli11.hpp:21
mlpack::util::PrefixedOutStream::operator<<
PrefixedOutStream & operator<<(const char *str)
Write a character array to the stream.
mlpack::util::PrefixedOutStream::backtrace
bool backtrace
If true, on a fatal error, a backtrace will be printed if HAS_BFD_DL is defined.
Definition: prefixedoutstream.hpp:123
mlpack::util::PrefixedOutStream::operator<<
PrefixedOutStream & operator<<(std::ios_base &(*pf)(std::ios_base &))
Write an ios_base manipulator function to the stream.
mlpack::util::PrefixedOutStream::operator<<
PrefixedOutStream & operator<<(long double val)
Write a long double to the stream.
mlpack::util::PrefixedOutStream::operator<<
PrefixedOutStream & operator<<(std::streambuf *sb)
Write a streambuf to the stream.
mlpack::util::PrefixedOutStream::operator<<
PrefixedOutStream & operator<<(unsigned short val)
Write an unsigned short to the stream.
mlpack::util::PrefixedOutStream::operator<<
PrefixedOutStream & operator<<(double val)
Write a double to the stream.
mlpack::util::PrefixedOutStream::operator<<
PrefixedOutStream & operator<<(std::string &str)
Write a string to the stream.
mlpack::util::PrefixedOutStream::operator<<
PrefixedOutStream & operator<<(std::ostream &(*pf)(std::ostream &))
Write an ostream manipulator function to the stream.
mlpack::util::PrefixedOutStream::operator<<
PrefixedOutStream & operator<<(float val)
Write a float to the stream.
mlpack::util::PrefixedOutStream::operator<<
PrefixedOutStream & operator<<(unsigned int val)
Write an unsigned int to the stream.
mlpack::util::PrefixedOutStream
Allows us to output to an ostream with a prefix at the beginning of each line, in the same way we wou...
Definition: prefixedoutstream.hpp:47
mlpack::util::PrefixedOutStream::operator<<
PrefixedOutStream & operator<<(short val)
Write a short to the stream.