readRitoRevisionLayout function

RitoRevisionLayout readRitoRevisionLayout(
  1. RitoBinaryReader reader
)

Reads the layout a RITONVR1 message carries after its result tag.

Implementation

RitoRevisionLayout readRitoRevisionLayout(RitoBinaryReader reader) {
  int? optional(String field) =>
      reader.option(field, () => reader.uint32(field));
  List<T> collection<T>(String field, T Function() read) => <T>[
    for (var count = reader.count(field); count > 0; count -= 1) read(),
  ];
  return RitoRevisionLayout(
    pageCount: reader.uint32('layout page count'),
    spreads: collection(
      'layout spreads',
      () => RitoSpreadPages(
        leftPageIndex: reader.uint32('spread left page'),
        rightPageIndex: optional('spread right page'),
      ),
    ),
    chapters: collection(
      'layout chapters',
      () => RitoChapterPages(
        spineIndex: reader.uint32('chapter spine index'),
        startPage: reader.uint32('chapter start page'),
        endPage: reader.uint32('chapter end page'),
      ),
    ),
    tocTargets: collection(
      'layout toc targets',
      () => RitoTocTargetPage(
        tocId: reader.uint32('toc target entry'),
        pageIndex: reader.uint32('toc target page'),
      ),
    ),
    activeTocEntryByPage: collection(
      'layout page toc entries',
      () => optional('page toc entry'),
    ),
    complete: reader.boolean('layout complete'),
  );
}