#include <Pt/Mcp/ContentType.h>
Writes the wrapper bytes of an MCP content block around a Formatter.
More...
|
|
Pt::Formatter & | beginContent (std::ostream &os) |
| | Writes the opening bytes of the content block to os and returns the Formatter the result is to be decomposed into.
|
| |
|
void | finishContent (std::ostream &os) |
| | Flushes buffered output and writes the closing bytes of the content array to os.
|
| |
ContentFormatter adds the begin/finish protocol for the enclosing content block (e.g. {"type":"text","text":"...")) around an existing Pt::Formatter: beginFormat() writes the opening bytes and returns the Pt::Formatter the decomposed result is drained into via Decomposer::beginFormat() and Decomposer::advanceFormat(); finishFormat() flushes any buffered output and writes the closing bytes once the result is fully drained. A ContentFormatter does not need to be a Formatter itself - it may wrap an existing one. Instances are created by ContentType::getFormatter() and must be released via ContentType::releaseFormatter().
◆ onBeginContent()
| virtual void onBeginContent |
( |
| ) |
|
|
protectedpure virtual |
Implementations write the type-specific opening JSON, e.g. {"type":"text","text":".
◆ onBeginFormat()