|
Macaulay2 Engine
|
Append-only GC-backed byte buffer used throughout the engine for text output. More...
Go to the source code of this file.
Classes | |
| struct | indent |
| class | buffer |
Variables | |
| const int | BUFFER_INITIAL_CAPACITY = 100 |
Append-only GC-backed byte buffer used throughout the engine for text output.
buffer is the lightweight text-output primitive shared by every engine text_out, error message, debug trace, and serialised value. Storage is a char* allocated via newarray_atomic (an atomic GC region: the collector treats it as containing no pointers); when a write would exceed _capacity the buffer doubles via expand, memcpys the old contents into the larger block, and freemems the previous one. The destructor freemems the active block. The starting capacity is BUFFER_INITIAL_CAPACITY = 100.
The class is preferred over std::ostringstream mostly for GC integration — the buffer can be threaded through engine code that already runs under bdwgc without crossing into the STL allocator. The header overloads operator<< for every primitive integer / character / floating-point type, plus MPFR, MPFI, and the cc_struct / cci_struct complex variants, and a marker indent { int n } struct whose operator<< emits n right-aligned to three columns (padded with one or two leading spaces) rather than n raw spaces. Contents come back out via str() (the live buffer with a nul terminator) or to_string() (an M2_string copy).
Definition in file buffer.hpp.