bool XmlSettingsEntry::remove( QStringList &xpath ) { QStringList::ConstIterator itXPath; AbstractNode *node = NULL; QString lastElem(xpath.last()); /* last element from xpath */ xpath.removeLast(); XmlSettingsEntry entry( find(xpath, itXPath, node) ); if( itXPath != xpath.end() ) { return false; } JQ_ASSERT(node); if( node->type() == AbstractNode::Map ) { MapNode *mapNode = dynamic_cast<MapNode*>(node); MapNode::iterator it = mapNode->find( lastElem ); if( it == mapNode->end() ) return false; mapNode->erase( it ); m_master->m_modified = true; return true; } if( node->type() == AbstractNode::Vector ) { JQ_ASSERT( lastElem.startsWith("[") ); JQ_ASSERT( lastElem.endsWith("]") && lastElem.size() > 2 ); bool ok; int index = lastElem.mid(1, lastElem.size()-2).toUInt(&ok); JQ_ASSERT(ok == true); VectorNode *vectorNode = dynamic_cast<VectorNode*>(node); vectorNode->erase( vectorNode->begin() + index ); m_master->m_modified = true; return true; } return false; }
T MyStack<T>::top()const { return lastElem(); }