Fix util::ostringstream, fix pretty-printing, stub out new globals
This commit is contained in:
@@ -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
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user