void CSIMSlmWithIteration::beginLevelIteration(int lvl, TLevelIterator& it) { it.m_history.clear(); for (int i=0, tmp_sz=lvl; i <= tmp_sz; ++i) it.m_history.push_back(0); adjustIterator(it); }
Rule& Proxy::moveRule(Rule* rule, int direction) { std::list<Rule>& ruleList = this->getRuleList(this->getParentRule(rule)); std::list<Rule>::iterator el = this->getListIterator(*rule, ruleList); std::list<Rule>::iterator next = el; adjustIterator(next, direction); Rule* newRule = rule; if (next == ruleList.end()) { try { std::list<Rule>& parentOfParent = this->getRuleList(this->getParentRule(this->getParentRule(rule))); std::list<Rule>::iterator parentListIter = this->getListIterator(*this->getParentRule(rule), parentOfParent); std::list<Rule>::iterator nextInParent = parentListIter; adjustIterator(nextInParent, direction == 1 ? 1 : 0); newRule = &*parentOfParent.insert(nextInParent, *rule); } catch (Proxy::Exception e) { if (e == RULE_NOT_FOUND) throw NO_MOVE_TARGET_FOUND; else throw e; } } else if (next->dataSource && next->type == Rule::NORMAL && next->dataSource->type == Entry::SUBMENU) { if (direction == 1) { next->subRules.push_front(*rule); newRule = &next->subRules.front(); } else { next->subRules.push_back(*rule); newRule = &next->subRules.back(); } } else { std::list<Rule>::iterator afterNext = el;adjustIterator(afterNext, direction == 1 ? 2 : -1); if (afterNext != ruleList.end()) { newRule = &*ruleList.insert(afterNext, *rule); } else { ruleList.push_back(*rule); newRule = &ruleList.back(); } } ruleList.erase(this->getListIterator(*rule, ruleList)); return *newRule; }
void CSIMSlmWithIteration::next(TLevelIterator& it) { ++(it.m_history.back()); adjustIterator(it); }