8#include <init.capnp.proxy.h>
21#include <system_error>
26 void print(
const std::string& message)
override { std::cout <<
"mpprinter: " << message << std::endl; }
32 std::unique_ptr<Printer>
makePrinter()
override {
return std::make_unique<PrinterImpl>(); }
35static void LogPrint(
bool raise,
const std::string& message)
37 if (raise)
throw std::runtime_error(message);
38 std::ofstream(
"debug.log", std::ios_base::app) << message << std::endl;
41int main(
int argc,
char** argv)
44 std::cout <<
"Usage: mpprinter <fd>\n";
48 if (std::from_chars(argv[1], argv[1] + strlen(argv[1]), fd).ec != std::errc{}) {
49 std::cerr << argv[1] <<
" is not a number or is larger than an int\n";
53 std::unique_ptr<Init>
init = std::make_unique<InitImpl>();
54 mp::ServeStream<InitInterface>(loop, fd, *
init);
std::unique_ptr< Printer > makePrinter() override
void print(const std::string &message) override
Event loop implementation.
void loop()
Run event loop.
int main(int argc, char **argv)
static void LogPrint(bool raise, const std::string &message)