32class OperationNodeNameStreambuf :
public std::streambuf {
34 using char_type =
typename std::streambuf::char_type;
35 using int_type =
typename std::streambuf::int_type;
36 using pos_type =
typename std::streambuf::pos_type;
38 thread_local static OperationNodeNameStreambuf<Base>* BUF;
40 OperationNode <Base>* node_;
42 OperationNodeNameStreambuf() :
45 throw CGException(
"Only one OperationNodeNameStreambuf can exist at a time in each thread");
47 if (CGOStreamFunc<Base>::FUNC !=
nullptr) {
48 throw CGException(
"CGOStreamFunc<Base>::FUNC already defined in this thread");
51 CGOStreamFunc<Base>::FUNC = registerNode;
54 virtual ~OperationNodeNameStreambuf() {
56 CGOStreamFunc<Base>::FUNC =
nullptr;
59 std::streamsize xsputn(
const char_type* s,
60 std::streamsize n)
override {
61 if (node_ !=
nullptr && n > 0) {
62 node_->setName(std::string(s, n));
73 static std::ostream& registerNode(std::ostream& os,
76 BUF->node_ = c.getOperationNode();