|
User Guide
|
Go to the documentation of this file.
23 #include <string_view>
47 std::streambuf*
sbuf =
nullptr;
48 std::unique_ptr<std::ostream>
result;
56 :
result(std::make_unique<std::ostream>(std::cout.rdbuf()))
60 :
result(std::make_unique<std::ostream>(stream.rdbuf()))
63 CodePrinter(
const std::string& filename, std::unique_ptr<utils::Blame>
blame);
76 void push_block(
const std::string& expression);
81 template <
typename... Args>
87 template <
typename... Args>
90 add_text(std::forward<Args>(args)...);
95 template <
typename... Args>
97 add_line(fmt::format(std::forward<Args>(args)...));
101 template <
typename... Args>
103 push_block(fmt::format(std::forward<Args>(args)...));
107 template <
typename... Args>
109 add_text(fmt::format(std::forward<Args>(args)...));
132 void pop_block(
const std::string_view& suffix, std::size_t num_newlines = 1);
void add_indent()
print whitespaces for indentation
void add_multi_line(const std::string &)
void blame()
Blame when on the requested line.
void add_text(Args &&... args)
void pop_block_nl(std::size_t num_newlines=0)
same as pop_block but control the number of NL characters (0 or more) with num_newlines parameter
encapsulates code generation backend implementations
void fmt_text(Args &&... args)
fmt_text(args...) is just shorthand for add_text(fmt::format(args...))
std::unique_ptr< std::ostream > result
void add_line(Args &&... args)
void chain_block(std::string const &expression)
end a block and immediately start a new one (i.e. "[indent-1]} [expression] {\n")
std::unique_ptr< utils::Blame > blame_printer
CodePrinter(std::unique_ptr< utils::Blame > blame)
CodePrinter(std::ostream &stream, std::unique_ptr< utils::Blame > blame)
void pop_block()
end of current block scope (i.e. end with "}") and adds one NL character
std::ostream & operator<<(std::ostream &stream, const ModToken &mt)
void fmt_push_block(Args &&... args)
fmt_push_block(args...) is just shorthand for push_block(fmt::format(args...))
void fmt_line(Args &&... args)
fmt_line(x, y, z) is just shorthand for add_line(fmt::format(x, y, z))
void push_block()
start a block scope without indentation (i.e. "{\n")
void add_newline(std::size_t n=1)
Helper class for printing C/C++ code.