+ /// an individual par id/pos <=> row mapping
+ struct TextEntry { int id; pos_type pos; };
+
+ /// an individual math id/cell <=> row mapping
+ struct MathEntry { uid_type id; idx_type cell; };
+
+ /// a container for passing entries around
+ struct RowEntry {
+ RowType type;
+ union {
+ struct TextEntry text;// iff the type is text_entry
+ struct MathEntry math;// iff the type is row_entry
+ struct {} begindocument;// iff the type is begin_document
+ };
+ };
+
+ /// Encapsulates the paragraph and position for later use
+ static RowEntry textEntry(int id, pos_type pos);
+ /// Encapsulates a cell and position for later use
+ static RowEntry mathEntry(uid_type id, idx_type cell);
+ /// Denotes the beginning of the document
+ static RowEntry beginDocument();
+
+ /// Converts a CursorSlice into a RowEntry
+ static RowEntry rowEntryFromCursorSlice(CursorSlice const & slice);
+
+ static const TextEntry text_none;
+ static const RowEntry row_none;
+ /// Returns true if RowEntry is devoid of information
+ static bool isNone(RowEntry entry);
+ /// Returns true if TextEntry is devoid of information
+ static bool isNone(TextEntry entry);
+
+private:
+ /// id/pos correspondence for a single row
+ class RowEntryList;
+
+ /// container of id/pos <=> row mapping
+ /// invariant: in any enabled_ TexRow, rowlist_ will contain at least one
+ /// Row (the current row)
+ typedef std::vector<RowEntryList> RowList;
+ ///
+ RowList rowlist_;
+ ///
+ RowEntryList & currentRow();
+
+ ///
+ class RowListIterator;
+ ///
+ RowListIterator begin() const;
+ ///
+ RowListIterator end() const;
+public:
+ ///
+ TexRow();
+
+ /// Copy can be expensive and is not usually useful for TexRow.
+ /// Force explicit copy, prefer move instead. This also prevents
+ /// move()s from being converted into copy silently.
+ explicit TexRow(TexRow const & other) = default;
+ TexRow(TexRow && other) = default;
+ TexRow & operator=(TexRow const & other) = default;
+ TexRow & operator=(TexRow && other) = default;
+
+ /// Clears structure.
+ void reset();
+
+ /// for debugging purposes
+ static docstring asString(RowEntry entry);
+
+ /// Defines the row information for the current line
+ /// returns true if this entry will appear on the current row
+ bool start(RowEntry entry);
+ /// Defines the paragraph and position for the current line
+ /// returns true if this entry will appear on the current row
+ bool start(int id, pos_type pos);
+ /// Defines a cell and position for the current line. Always appear in the
+ /// current row.
+ void startMath(uid_type id, idx_type cell);
+ /// Defines the paragraph for the current cell-like inset. Always appears
+ /// in the current row like a math cell, but is detached from the normal
+ /// text flow. Note: since the cell idx is not recorded it does not work as
+ /// well as for math grids; if we were to do that properly we would need to
+ /// access the id of the parent Tabular inset from the CursorSlice.
+ void forceStart(int id, pos_type pos);