void print_events(const std::shared_ptr<cainteoir::document_reader> &reader) { while (reader->read()) { if (reader->type & cainteoir::events::anchor) { fprintf(stdout, "anchor [%s]%s\n", reader->anchor.ns.c_str(), reader->anchor.ref.c_str()); } if (reader->type & cainteoir::events::text_ref) { fprintf(stdout, "text-ref [%s]%s\n", reader->anchor.ns.c_str(), reader->anchor.ref.c_str()); } if (reader->type & cainteoir::events::media_ref) { fprintf(stdout, "media-ref [%s]%s [from=", reader->anchor.ns.c_str(), reader->anchor.ref.c_str()); print_time(reader->media_begin); fprintf(stdout, " ; to="); print_time(reader->media_end); fprintf(stdout, "]\n"); } if (reader->type & cainteoir::events::begin_context) { fprintf(stdout, "begin-context "); if (reader->styles) format_style(*reader->styles); fprintf(stdout, "\n"); } if (reader->type & cainteoir::events::text) { fprintf(stdout, "text(%zu): \"\"\"", reader->content->size()); fwrite(reader->content->begin(), 1, reader->content->size(), stdout); fwrite("\"\"\"\n", 1, 4, stdout); } if (reader->type & cainteoir::events::end_context) fprintf(stdout, "end-context\n"); } }
namespace bmc { namespace braille { struct format_style { unsigned columns = 40; }; struct output { struct fragment { std::u32string unicode; std::string description; bool needs_guide_dot; fragment(std::u32string const &unicode, std::string const &description, bool needs_guide_dot = false) : unicode{unicode}, description{description}, needs_guide_dot{needs_guide_dot} {} }; std::vector<fragment> fragments; }; output reformat(ast::score const &, format_style const &style = format_style()); std::ostream &operator<<(std::ostream &, output const &); }}