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

@@ -68,23 +68,27 @@ double get_monotonic_clock();
// without copying, use oss.size() and oss.c_str()
//
class ostringstream : public std::ostringstream {
class rstringbuf : public std::stringbuf {
class rstringbuf : public std::basic_stringbuf<char_type, traits_type, allocator_type> {
public:
char *eback() { return std::streambuf::eback(); }
char *eback() const { return std::streambuf::eback(); }
char *pptr() const { return std::streambuf::pptr(); }
};
rstringbuf rsbuf_;
rstringbuf rstringbuf_;
public:
ostringstream() {
std::basic_ostream<char>::rdbuf(&rsbuf_);
std::basic_ostream<char>::rdbuf(&rstringbuf_);
}
size_t size() {
return tellp();
std::string_view view() const {
char *p = rstringbuf_.eback();
size_t size = rstringbuf_.pptr() - p;
return std::string_view(p, size);
}
const char *c_str() {
return rsbuf_.eback();
std::string str() const {
return rstringbuf_.str();
}
};
// Remove items from a vector that are marked for deletion.
//
template<class T>