global.set has been implemented, but not diff xmit for globals
This commit is contained in:
@@ -328,10 +328,35 @@ struct XYZ {
|
||||
eng::string debug_string() const;
|
||||
};
|
||||
|
||||
class NullStreamBuffer : public std::streambuf
|
||||
{
|
||||
// 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.view().
|
||||
//
|
||||
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:
|
||||
int overflow(int c) { return c; }
|
||||
ostringstream() {
|
||||
std::basic_ostream<char>::rdbuf(&rstringbuf_);
|
||||
}
|
||||
char *data() const {
|
||||
return rstringbuf_.eback();
|
||||
}
|
||||
size_t size() const {
|
||||
return rstringbuf_.pptr() - rstringbuf_.eback();
|
||||
}
|
||||
std::string_view view() const {
|
||||
return std::string_view(data(), size());
|
||||
}
|
||||
eng::string str() const {
|
||||
return rstringbuf_.str();
|
||||
}
|
||||
};
|
||||
|
||||
// send_to_stream: send all arguments to the specified stream.
|
||||
@@ -350,34 +375,7 @@ 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.view().
|
||||
//
|
||||
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
|
||||
// dprintf / dprint
|
||||
//
|
||||
// Send a debugging message to somewhere that it can be seen. This routine
|
||||
// initially just sends output to stderr. But it can be hooked to send output
|
||||
@@ -388,8 +386,16 @@ public:
|
||||
// characters only. There will be no control characters. The newline is
|
||||
// implied.
|
||||
//
|
||||
void dprintview(std::string_view view);
|
||||
void dprintf(const char *format, ...);
|
||||
void hook_dprintf(void (*func)(const char *oneline));
|
||||
void hook_dprint(void (*func)(const char *oneline, size_t size));
|
||||
|
||||
template <class... ARGS>
|
||||
inline void dprint(const ARGS & ... args) {
|
||||
util::ostringstream oss;
|
||||
send_to_stream(oss, args...);
|
||||
dprintview(oss.view());
|
||||
}
|
||||
|
||||
// A better API than std::setfill, std::hex, std::setw, std::setprecision
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user