Added Write() method to write buffer to an ostream, and added an ostream operator overload

This commit is contained in:
Bart Trzynadlowski 2016-08-18 04:13:50 +00:00
parent 1dc360a8b0
commit 5652aab91f
2 changed files with 13 additions and 0 deletions

View file

@ -4,6 +4,12 @@
namespace Util namespace Util
{ {
std::ostream &operator<<(std::ostream &os, const Format &format)
{
format.Write(os);
return os;
}
std::string ToLower(const std::string &str) std::string ToLower(const std::string &str)
{ {
std::string tmp(str); std::string tmp(str);

View file

@ -29,6 +29,11 @@ namespace Util
return m_stream.str(); return m_stream.str();
} }
void Write(std::ostream &os) const
{
os << m_stream.rdbuf();
}
template <typename T> template <typename T>
Format &Join(const T &collection) Format &Join(const T &collection)
{ {
@ -86,6 +91,7 @@ namespace Util
} }
}; };
std::ostream &operator<<(std::ostream &os, const Format &format);
std::string ToLower(const std::string &str); std::string ToLower(const std::string &str);
std::string TrimWhiteSpace(const std::string &str); std::string TrimWhiteSpace(const std::string &str);
std::string Hex(uint32_t n, size_t num_digits); std::string Hex(uint32_t n, size_t num_digits);
@ -94,4 +100,5 @@ namespace Util
std::string Hex(uint8_t n); std::string Hex(uint8_t n);
} // Util } // Util
#endif // INCLUDED_FORMAT_H #endif // INCLUDED_FORMAT_H