diff options
author | Marco Bubke <marco.bubke@qt.io> | 2016-11-16 18:27:59 +0100 |
---|---|---|
committer | Marco Bubke <marco.bubke@qt.io> | 2016-11-17 15:06:58 +0000 |
commit | f11b746e60096d9b6a089fc34a6d1a6934774601 (patch) | |
tree | 5ac5136aff4263ecb72ec3c0824a0f65217c7bcb | |
parent | 19a00f418f39549119031b9c494a65dc4d5db4f7 (diff) |
Utils: Improve debug output of SmallString
Change-Id: I738ac9d139271b7d154dd39f30ae3c08b5e5b921
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
-rw-r--r-- | src/libs/utils/smallstringio.h | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/libs/utils/smallstringio.h b/src/libs/utils/smallstringio.h index c8cf70cb27..d3fa564263 100644 --- a/src/libs/utils/smallstringio.h +++ b/src/libs/utils/smallstringio.h @@ -78,18 +78,27 @@ QDebug &operator<<(QDebug &debug, const SmallString &string) return debug; } -inline -std::ostream &operator<<(std::ostream &stream, const SmallString &string) +template <uint Size> +std::ostream &operator<<(std::ostream &stream, const BasicSmallString<Size> &string) { using std::operator<<; return stream << std::string(string.data(), string.size()); } -inline -void PrintTo(const SmallString &string, ::std::ostream *os) +template <uint Size> +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) |