mlpack
master
|
Allows us to output to an ostream with a prefix at the beginning of each line, in the same way we would output to cout or cerr. More...
Public Member Functions | |
PrefixedOutStream (std::ostream &destination, const char *prefix, bool ignoreInput=false, bool fatal=false) | |
Set up the PrefixedOutStream. More... | |
PrefixedOutStream & | operator<< (bool val) |
Write a bool to the stream. More... | |
PrefixedOutStream & | operator<< (short val) |
Write a short to the stream. More... | |
PrefixedOutStream & | operator<< (unsigned short val) |
Write an unsigned short to the stream. More... | |
PrefixedOutStream & | operator<< (int val) |
Write an int to the stream. More... | |
PrefixedOutStream & | operator<< (unsigned int val) |
Write an unsigned int to the stream. More... | |
PrefixedOutStream & | operator<< (long val) |
Write a long to the stream. More... | |
PrefixedOutStream & | operator<< (unsigned long val) |
Write an unsigned long to the stream. More... | |
PrefixedOutStream & | operator<< (float val) |
Write a float to the stream. More... | |
PrefixedOutStream & | operator<< (double val) |
Write a double to the stream. More... | |
PrefixedOutStream & | operator<< (long double val) |
Write a long double to the stream. More... | |
PrefixedOutStream & | operator<< (void *val) |
Write a void pointer to the stream. More... | |
PrefixedOutStream & | operator<< (const char *str) |
Write a character array to the stream. More... | |
PrefixedOutStream & | operator<< (std::string &str) |
Write a string to the stream. More... | |
PrefixedOutStream & | operator<< (std::streambuf *sb) |
Write a streambuf to the stream. More... | |
PrefixedOutStream & | operator<< (std::ostream &(*pf)(std::ostream &)) |
Write an ostream manipulator function to the stream. More... | |
PrefixedOutStream & | operator<< (std::ios &(*pf)(std::ios &)) |
Write an ios manipulator function to the stream. More... | |
PrefixedOutStream & | operator<< (std::ios_base &(*pf)(std::ios_base &)) |
Write an ios_base manipulator function to the stream. More... | |
template<typename T > | |
PrefixedOutStream & | operator<< (const T &s) |
Write anything else to the stream. More... | |
Public Attributes | |
std::ostream & | destination |
The output stream that all data is to be sent to; example: std::cout. More... | |
bool | ignoreInput |
Discards input, prints nothing if true. More... | |
Private Member Functions | |
template<typename T > | |
void | BaseLogic (const T &val) |
Conducts the base logic required in all the operator << overloads. More... | |
void | PrefixIfNeeded () |
Output the prefix, but only if we need to and if we are allowed to. More... | |
Private Attributes | |
bool | carriageReturned |
If true, the previous call to operator<< encountered a CR, and a prefix will be necessary. More... | |
bool | fatal |
If true, a std::runtime_error exception will be thrown when a CR is encountered. More... | |
std::string | prefix |
Contains the prefix we must prepend to each line. More... | |
Allows us to output to an ostream with a prefix at the beginning of each line, in the same way we would output to cout or cerr.
The prefix is specified in the constructor (as well as the destination ostream). A newline must be passed to the stream, and then the prefix will be prepended to the next line. For example,
would give, on std::cout,
These objects are used for the mlpack::Log levels (DEBUG, INFO, WARN, and FATAL).
Definition at line 52 of file prefixedoutstream.hpp.
|
inline |
Set up the PrefixedOutStream.
destination | ostream which receives output from this object. |
prefix | The prefix to prepend to each line. |
ignoreInput | If true, the stream will not be printed. |
fatal | If true, a std::runtime_error exception is thrown after printing a newline. |
Definition at line 64 of file prefixedoutstream.hpp.
References operator<<(), and string().
|
private |
Conducts the base logic required in all the operator << overloads.
Mostly just a good idea to reduce copy-pasta.
T | The type of the data to output. |
val | The The data to be output. |
PrefixedOutStream& mlpack::util::PrefixedOutStream::operator<< | ( | bool | val | ) |
Write a bool to the stream.
Referenced by PrefixedOutStream().
PrefixedOutStream& mlpack::util::PrefixedOutStream::operator<< | ( | short | val | ) |
Write a short to the stream.
PrefixedOutStream& mlpack::util::PrefixedOutStream::operator<< | ( | unsigned short | val | ) |
Write an unsigned short to the stream.
PrefixedOutStream& mlpack::util::PrefixedOutStream::operator<< | ( | int | val | ) |
Write an int to the stream.
PrefixedOutStream& mlpack::util::PrefixedOutStream::operator<< | ( | unsigned int | val | ) |
Write an unsigned int to the stream.
PrefixedOutStream& mlpack::util::PrefixedOutStream::operator<< | ( | long | val | ) |
Write a long to the stream.
PrefixedOutStream& mlpack::util::PrefixedOutStream::operator<< | ( | unsigned long | val | ) |
Write an unsigned long to the stream.
PrefixedOutStream& mlpack::util::PrefixedOutStream::operator<< | ( | float | val | ) |
Write a float to the stream.
PrefixedOutStream& mlpack::util::PrefixedOutStream::operator<< | ( | double | val | ) |
Write a double to the stream.
PrefixedOutStream& mlpack::util::PrefixedOutStream::operator<< | ( | long double | val | ) |
Write a long double to the stream.
PrefixedOutStream& mlpack::util::PrefixedOutStream::operator<< | ( | void * | val | ) |
Write a void pointer to the stream.
PrefixedOutStream& mlpack::util::PrefixedOutStream::operator<< | ( | const char * | str | ) |
Write a character array to the stream.
PrefixedOutStream& mlpack::util::PrefixedOutStream::operator<< | ( | std::string & | str | ) |
Write a string to the stream.
PrefixedOutStream& mlpack::util::PrefixedOutStream::operator<< | ( | std::streambuf * | sb | ) |
Write a streambuf to the stream.
PrefixedOutStream& mlpack::util::PrefixedOutStream::operator<< | ( | std::ostream &(*)(std::ostream &) | pf | ) |
Write an ostream manipulator function to the stream.
PrefixedOutStream& mlpack::util::PrefixedOutStream::operator<< | ( | std::ios &(*)(std::ios &) | pf | ) |
Write an ios manipulator function to the stream.
PrefixedOutStream& mlpack::util::PrefixedOutStream::operator<< | ( | std::ios_base &(*)(std::ios_base &) | pf | ) |
Write an ios_base manipulator function to the stream.
PrefixedOutStream& mlpack::util::PrefixedOutStream::operator<< | ( | const T & | s | ) |
Write anything else to the stream.
|
inlineprivate |
Output the prefix, but only if we need to and if we are allowed to.
|
private |
If true, the previous call to operator<< encountered a CR, and a prefix will be necessary.
Definition at line 143 of file prefixedoutstream.hpp.
std::ostream& mlpack::util::PrefixedOutStream::destination |
The output stream that all data is to be sent to; example: std::cout.
Definition at line 117 of file prefixedoutstream.hpp.
|
private |
If true, a std::runtime_error exception will be thrown when a CR is encountered.
Definition at line 147 of file prefixedoutstream.hpp.
bool mlpack::util::PrefixedOutStream::ignoreInput |
Discards input, prints nothing if true.
Definition at line 120 of file prefixedoutstream.hpp.
|
private |
Contains the prefix we must prepend to each line.
Definition at line 139 of file prefixedoutstream.hpp.