8#include <init.capnp.proxy.h>
20 void print(
const std::string& message)
override { std::cout <<
"mpprinter: " << message << std::endl; }
26 std::unique_ptr<Printer>
makePrinter()
override {
return std::make_unique<PrinterImpl>(); }
29static void LogPrint(
bool raise,
const std::string& message)
31 if (raise)
throw std::runtime_error(message);
32 std::ofstream(
"debug.log", std::ios_base::app) << message << std::endl;
35int main(
int argc,
char** argv)
38 std::cout <<
"Usage: mpprinter <fd>\n";
42 if (std::from_chars(argv[1], argv[1] + strlen(argv[1]), fd).ec != std::errc{}) {
43 std::cerr << argv[1] <<
" is not a number or is larger than an int\n";
47 std::unique_ptr<Init>
init = std::make_unique<InitImpl>();
48 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)