VLink  2.0.0
A high-performance communication middleware
fast_stream.h 文件参考

Allocation-light std::ostream backed by a growable string buffer. 更多...

#include <ostream>
#include <string>
#include <string_view>
#include "./macros.h"
fast_stream.h 的引用(Include)关系图:
此图展示该文件直接或间接的被哪些文件引用了:

浏览源代码.

class  vlink::FastStream
 Logger-friendly std::ostream with a custom growable string buffer. 更多...
 

命名空间

 

详细描述

Allocation-light std::ostream backed by a growable string buffer.

FastStream is the zero-copy log assembly buffer used inside the VLink logger. Inheriting from std::ostream means every operator<< overload and manipulator works unchanged; the difference lies in the StringBuf backing storage and in take_view, which yields a std::string_view directly into the buffer for hand-off to the active sink without an intermediate copy.

Supported operators
Operation Source Notes
operator<< std::ostream interface All integral, floating, pointer types
Standard manipulators std::ios_base::fmtflags etc. std::hex, std::setw, std::setfill, ...
write_raw direct buffer write Bypasses locale and format flags
append_to append current contents Does not reset the buffer
take_view hand-off as string_view View invalidated by the next write
Growth policy
Stage Capacity
Initial kDefaultCapacity (256)
Doubling until kMaxExpandSize (8192)
Linear increments kMaxExpandSize step thereafter
Example
stream << "sensor_id=" << 42 << " value=" << 3.14;
std::string_view view = stream.take_view(); // valid until next write
write_to_sink(view);
stream.reset();
stream.write_raw("LITERAL", 7); // bypass formatting
注解
Not thread-safe; the logger keeps one FastStream per thread via thread_local. Views returned by take_view become invalid on the next stream operation or reset.