File indexing completed on 2024-05-12 15:58:29
0001 /* 0002 * SPDX-FileCopyrightText: 2005 C. Boemann <cbo@boemann.dk> 0003 * SPDX-FileCopyrightText: 2007, 2008 Boudewijn Rempt <boud@valdyas.org> 0004 * 0005 * SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #include "kis_node_visitor.h" 0009 #include "kis_node.h" 0010 0011 bool KisNodeVisitor::visitAll(KisNode * node, bool breakOnFail) 0012 { 0013 for (uint i = 0; i < node->childCount(); ++i) { 0014 if (!node->at(i)->accept(*this)) { 0015 if (breakOnFail) 0016 return false; 0017 } 0018 } 0019 return true; 0020 } 0021 0022 0023 0024 /** 0025 * Visit all child nodes of the given node starting with the last one until one node returns 0026 * false. Then visitAll returns false, otherwise true. 0027 * 0028 * @param node the parent node whose children will be visited 0029 * @param breakOnFail break if one of the children returns false on accept 0030 * @return true if none of the childnodes returns false on 0031 * accepting the visitor. 0032 */ 0033 bool KisNodeVisitor::visitAllInverse(KisNode * node, bool breakOnFail) 0034 { 0035 KisNodeSP child = node->lastChild(); 0036 while (child) { 0037 if (!child->accept(*this)) { 0038 if (breakOnFail) 0039 return false; 0040 } 0041 child = child->prevSibling(); 0042 } 0043 return true; 0044 }