]> git.lyx.org Git - features.git/commitdiff
Add operator<< for Row::Elements
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 20 Sep 2021 15:32:18 +0000 (17:32 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 23 Nov 2021 15:31:30 +0000 (16:31 +0100)
This is useful for debugging.

src/Row.cpp
src/Row.h

index 8233a965a752c039d838be77460caf757d8020b6..b7e4c07c95c3903c608f78996d0e4a6fe6bff95f 100644 (file)
@@ -275,6 +275,17 @@ ostream & operator<<(ostream & os, Row::Element const & e)
 }
 
 
+ostream & operator<<(ostream & os, Row::Elements const & elts)
+{
+       double x = 0;
+       for (Row::Element const & e : elts) {
+               os << "x=" << x << " => " << e << endl;
+               x += e.full_width();
+       }
+       return os;
+}
+
+
 ostream & operator<<(ostream & os, Row const & row)
 {
        os << " pos: " << row.pos_ << " end: " << row.end_
@@ -286,11 +297,11 @@ ostream & operator<<(ostream & os, Row const & row)
           << " separator: " << row.separator
           << " label_hfill: " << row.label_hfill
           << " row_boundary: " << row.right_boundary() << "\n";
+       // We cannot use the operator above, unfortunately
        double x = row.left_margin;
-       Row::Elements::const_iterator it = row.elements_.begin();
-       for ( ; it != row.elements_.end() ; ++it) {
-               os << "x=" << x << " => " << *it << endl;
-               x += it->full_width();
+       for (Row::Element const & e : row.elements_) {
+               os << "x=" << x << " => " << e << endl;
+               x += e.full_width();
        }
        return os;
 }
index 74667976efba1e54741cac9cd773e09cd2171a99..1272a0f6eabd7cdf7987c2ed86335e06f64c33fb 100644 (file)
--- a/src/Row.h
+++ b/src/Row.h
@@ -378,6 +378,8 @@ private:
        bool changebar_ = false;
 };
 
+std::ostream & operator<<(std::ostream & os, Row::Elements const & elts);
+
 
 /**
  * Each paragraph is broken up into a number of rows on the screen.