diff --git a/src/common/Format.h b/src/common/Format.h index c2db70752..3e76d2fab 100644 --- a/src/common/Format.h +++ b/src/common/Format.h @@ -80,6 +80,54 @@ namespace Format inline PrecisionOverride Precision(size_t precision) { return PrecisionOverride(precision); } }; +template inline ByteStringBuilder &operator<<(ByteStringBuilder &b, Format::FlagsOverride data) +{ + std::ios_base::fmtflags oldflags = b.flags; + b.flags = (b.flags & ~reset) | set; + b << data.value; + b.flags = oldflags; + return b; +} +template inline ByteStringBuilder &operator<<(ByteStringBuilder &b, Format::FlagsOverride data) +{ + b.flags = (b.flags & ~reset) | set; + return b; +} + +template inline ByteStringBuilder &operator<<(ByteStringBuilder &b, Format::WidthOverride data) +{ + size_t oldwidth = b.width; + b.width = data.width; + b << data.value; + b.width = oldwidth; + return b; +} +inline ByteStringBuilder &operator<<(ByteStringBuilder &b, Format::WidthOverride data) +{ + b.width = data.width; + return b; +} + +template inline ByteStringBuilder &operator<<(ByteStringBuilder &b, Format::PrecisionOverride data) +{ + std::ios_base::fmtflags oldflags = b.flags; + if(!(oldflags & std::ios_base::floatfield)) + b.flags |= std::ios_base::fixed; + size_t oldprecision = b.precision; + b.precision = data.precision; + b << data.value; + b.precision = oldprecision; + b.flags = oldflags; + return b; +} +inline ByteStringBuilder &operator<<(ByteStringBuilder &b, Format::PrecisionOverride data) +{ + if(!(b.flags & std::ios_base::floatfield)) + b.flags |= std::ios_base::fixed; + b.precision = data.precision; + return b; +} + template inline StringBuilder &operator<<(StringBuilder &b, Format::FlagsOverride data) { std::ios_base::fmtflags oldflags = b.flags;