12struct hegel_printer_t;
113 template <
typename T>
void repr(
const T& value);
183 template <
typename F>
184 void group(std::size_t indent, std::string_view open,
185 std::string_view close, F&& body) {
187 std::invoke(std::forward<F>(body), *
this);
205 template <
typename Range,
typename F>
206 void seq(std::string_view open, std::string_view close,
207 const Range& items, F&& print_item) {
210 for (
const auto& item : items) {
215 std::invoke(print_item, *
this, item);
267 Printer(hegel_printer_t* handle,
bool owned)
268 : handle_(handle), owned_(owned) {}
269 hegel_printer_t* handle()
const {
return handle_; }
270 void begin_block(std::string_view open);
271 void end_block(std::string_view close);
275 hegel_printer_t* handle_ =
nullptr;
304 explicit Speculation(hegel_printer_t* handle) : handle_(handle) {}
308 void close(
bool keep);
310 hegel_printer_t* handle_ =
nullptr;
311 bool resolved_ =
false;
358namespace hegel::internal {
361 inline constexpr std::size_t unbounded_width =
362 std::numeric_limits<uint32_t>::max();
std::string finish() &&
Lay out the document and return it.
Document(std::size_t max_width=79)
Make an empty document.
Printer & printer()
The printer that writes to this document.
Definition printer.h:341
Writes to the document that a failure report shows.
Definition printer.h:55
void separator()
Write the separator between two items: , and breakable(" ").
void end_group(std::string_view close)
End the innermost group and write close.
void group(std::size_t indent, std::string_view open, std::string_view close, F &&body)
Write a group: open, what body writes, then close.
Definition printer.h:184
void breakable(std::string_view separator=" ")
Write a point where the line can break.
void repr(const T &value)
Write the C++ representation of a value.
Definition repr.h:713
void if_break(std::string_view text)
Write text only when the innermost group breaks.
Printer deferred()
Make a child region at the current position.
void text(std::string_view text)
Write text that does not break.
void comment(std::string_view text)
Write // <text> at the end of the current line.
void reflow(std::string_view text)
Write text that some other formatter made, with its bracket structure recovered.
static Printer noop()
A printer that discards everything.
Printer(Printer &&other) noexcept
Move-constructs, transferring the region.
Speculation speculate()
Start a speculative region on this printer.
void shift_indent(std::ptrdiff_t delta)
Change the indentation of the break points that follow.
void seq(std::string_view open, std::string_view close, const Range &items, F &&print_item)
Write a list of items, separated by commas.
Definition printer.h:206
void hard_break()
Write a new line, then the current indentation.
bool should_print() const
Whether printing to this printer gives output.
void begin_group(std::size_t indent, std::string_view open)
Write open and start a group.
Printer & operator=(Printer &&other) noexcept
Move-assigns, transferring the region.
An open speculative region; see Printer::speculate().
Definition printer.h:285
void commit()
End the region and keep what was written in it.
void abort()
End the region and discard what was written in it.
Speculation(Speculation &&other) noexcept
Move-constructs, transferring the open region.
Main namespace.
Definition config.h:29