Fix util::ostringstream, fix pretty-printing, stub out new globals

This commit is contained in:
2023-03-05 01:51:25 -05:00
parent db234c2934
commit 86a27ef2d4
13 changed files with 455 additions and 282 deletions

View File

@@ -350,7 +350,32 @@ inline eng::string ss(const ARGS & ... args) {
return oss.str();
}
// util::ostringstream
//
// This is a variant of ostringstream in which it is possible
// to get the contents without copying. To get the contents
// without copying, use oss.size() and oss.c_str()
//
class ostringstream : public eng::ostringstream {
class rstringbuf : public std::basic_stringbuf<char_type, traits_type, allocator_type> {
public:
char *eback() const { return std::streambuf::eback(); }
char *pptr() const { return std::streambuf::pptr(); }
};
rstringbuf rstringbuf_;
public:
ostringstream() {
std::basic_ostream<char>::rdbuf(&rstringbuf_);
}
std::string_view view() const {
char *p = rstringbuf_.eback();
size_t size = rstringbuf_.pptr() - p;
return std::string_view(p, size);
}
eng::string str() const {
return rstringbuf_.str();
}
};
// dprintf
//