diff options
author | Sebastian Geerken <devnull@localhost> | 2014-09-26 14:24:17 +0200 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2014-09-26 14:24:17 +0200 |
commit | 482c58422d36425b3c60ea1a7655b342a5be1228 (patch) | |
tree | 11aebabf42875780f8bc09b7c3e44c2f65f9d4b6 /dw/oofawarewidget_iterator.cc | |
parent | a170867c7b7db49e0d52a51f7321b86348fa9ae7 (diff) |
RTFL.
Diffstat (limited to 'dw/oofawarewidget_iterator.cc')
-rw-r--r-- | dw/oofawarewidget_iterator.cc | 135 |
1 files changed, 96 insertions, 39 deletions
diff --git a/dw/oofawarewidget_iterator.cc b/dw/oofawarewidget_iterator.cc index 74b3ea53..119222c9 100644 --- a/dw/oofawarewidget_iterator.cc +++ b/dw/oofawarewidget_iterator.cc @@ -95,6 +95,15 @@ void OOFAwareWidget::OOFAwareWidgetIterator::getPart (int sectionIndex, } } +void OOFAwareWidget::OOFAwareWidgetIterator::intoStringBuffer (StringBuffer *sb) +{ + Iterator::intoStringBuffer (sb); + sb->append (", sectionIndex = "); + sb->appendInt (sectionIndex); + sb->append (", index = "); + sb->appendInt (index); +} + int OOFAwareWidget::OOFAwareWidgetIterator::compareTo (Comparable *other) { OOFAwareWidgetIterator *otherTI = (OOFAwareWidgetIterator*)other; @@ -107,54 +116,108 @@ int OOFAwareWidget::OOFAwareWidgetIterator::compareTo (Comparable *other) bool OOFAwareWidget::OOFAwareWidgetIterator::next () { - if (content.type == Content::END) - return false; + DBG_OBJ_ENTER0_O ("iterator", 0, getWidget (), + "OOFAwareWidgetIterator/next"); + + DBG_IF_RTFL { + StringBuffer sb; + intoStringBuffer (&sb); + DBG_OBJ_MSGF_O ("iterator", 1, getWidget (), "initial value: %s", + sb.getChars ()); + } + + bool r; - do { - index++; + if (content.type == Content::END) + r = false; + else { + r = true; + bool cancel = false; - if (index >= numParts(sectionIndex)) { - sectionIndex++; - while (sectionIndex < NUM_SECTIONS && numParts (sectionIndex) == 0) + do { + index++; + + if (index >= numParts(sectionIndex)) { sectionIndex++; + while (sectionIndex < NUM_SECTIONS && numParts (sectionIndex) == 0) + sectionIndex++; - if (sectionIndex == NUM_SECTIONS) { - content.type = Content::END; - return false; - } else - index = 0; - } + if (sectionIndex == NUM_SECTIONS) { + content.type = Content::END; + r = false; + cancel = true; + } else + index = 0; + } + + getPart (sectionIndex, index, &content); + } while (!cancel && (content.type & getMask()) == 0); + } - getPart (sectionIndex, index, &content); - } while ((content.type & getMask()) == 0); + DBG_IF_RTFL { + StringBuffer sb; + intoStringBuffer (&sb); + DBG_OBJ_MSGF_O ("iterator", 1, getWidget (), "final value: %s", + sb.getChars ()); + DBG_OBJ_MSGF_O ("iterator", 1, getWidget (), "return value: %s", + r ? "true" : "false"); + } - return true; + DBG_OBJ_LEAVE_O (getWidget ()); + return r; } bool OOFAwareWidget::OOFAwareWidgetIterator::prev () { - if (content.type == Content::START) - return false; + DBG_OBJ_ENTER0_O ("iterator", 0, getWidget (), + "OOFAwareWidgetIterator/prev"); + + DBG_IF_RTFL { + StringBuffer sb; + intoStringBuffer (&sb); + DBG_OBJ_MSGF_O ("iterator", 1, getWidget (), "initial value: %s", + sb.getChars ()); + } - do { - index--; + bool r; - if (index < 0) { - sectionIndex--; - while (sectionIndex >= 0 && numParts (sectionIndex) == 0) + if (content.type == Content::START) + r = false; + else { + r = true; + bool cancel = false; + + do { + index--; + + if (index < 0) { sectionIndex--; + while (sectionIndex >= 0 && numParts (sectionIndex) == 0) + sectionIndex--; - if (sectionIndex < 0) { - content.type = Content::START; - return false; - } else - index = numParts (sectionIndex) - 1; - } - - getPart (sectionIndex, index, &content); - } while ((content.type & getMask()) == 0); + if (sectionIndex < 0) { + content.type = Content::START; + r = false; + cancel = true; + } else + index = numParts (sectionIndex) - 1; + } + + getPart (sectionIndex, index, &content); + } while (!cancel && (content.type & getMask()) == 0); + } + + DBG_IF_RTFL { + StringBuffer sb; + intoStringBuffer (&sb); + DBG_OBJ_MSGF_O ("iterator", 1, getWidget (), "final value: %s", + sb.getChars ()); + DBG_OBJ_MSGF_O ("iterator", 1, getWidget (), "return value: %s", + r ? "true" : "false"); + } - return true; + DBG_OBJ_LEAVE_O (getWidget ()); + return r; } void OOFAwareWidget::OOFAwareWidgetIterator::highlightOOF (int start, int end, @@ -181,12 +244,6 @@ void OOFAwareWidget::OOFAwareWidgetIterator::getAllocationOOF (int start, ->getWidget(index)->getAllocation()); } -void OOFAwareWidget::OOFAwareWidgetIterator::print () -{ - Iterator::print (); - printf (", sectionIndex = %d, index = %d", sectionIndex, index); -} - } // namespace oof } // namespace dw |