Utils: Improve debug output of SmallString

Change-Id: I738ac9d139271b7d154dd39f30ae3c08b5e5b921
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Marco Bubke
2016-11-16 18:27:59 +01:00
parent 19a00f418f
commit f11b746e60

View File

@@ -78,18 +78,27 @@ QDebug &operator<<(QDebug &debug, const SmallString &string)
return debug; return debug;
} }
inline template <uint Size>
std::ostream &operator<<(std::ostream &stream, const SmallString &string) std::ostream &operator<<(std::ostream &stream, const BasicSmallString<Size> &string)
{ {
using std::operator<<; using std::operator<<;
return stream << std::string(string.data(), string.size()); return stream << std::string(string.data(), string.size());
} }
inline template <uint Size>
void PrintTo(const SmallString &string, ::std::ostream *os) void PrintTo(const BasicSmallString<Size> &string, ::std::ostream *os)
{ {
*os << "'" << string.data() << "'"; Utils::SmallString formatedString = string.clone();
formatedString.replace("\n", "\\n");
formatedString.replace("\t", "\\t");
*os << "'";
os->write(formatedString.data(), formatedString.size());
*os<< "'";
} }
inline QDataStream &operator<<(QDataStream &out, const SmallStringVector &stringVector) inline QDataStream &operator<<(QDataStream &out, const SmallStringVector &stringVector)