Partial::Partial(
css::uno::Sequence< OUString > const & includedPaths,
css::uno::Sequence< OUString > const & excludedPaths)
{ // The Partial::Node tree built up here encodes the following information: // * Inner node, startInclude: an include starts here that contains excluded // sub-trees // * Inner node, !startInclude: contains in-/excluded sub-trees // * Leaf node, startInclude: an include starts here // * Leaf node, !startInclude: an exclude starts here for (autoconst& includedPath : includedPaths)
{
sal_Int32 n = 0; for (Node * p = &root_;;) {
OUString seg; bool end = parseSegment(includedPath, &n, &seg);
p = !seg.isEmpty() ? &p->children[seg] : p; if (p->startInclude) { break;
} if (end) {
p->children.clear();
p->startInclude = true; break;
}
}
} for (autoconst& excludedPath : excludedPaths)
{
sal_Int32 n = 0; for (Node * p = &root_;;) {
OUString seg; bool end = parseSegment(excludedPath, &n, &seg); if (end) {
p->children[seg].clear(); break;
}
Node::Children::iterator j(p->children.find(seg)); if (j == p->children.end()) { break;
}
p = &j->second;
}
}
}
Partial::~Partial() {}
Partial::Containment Partial::contains(std::vector<OUString> const & path) const { //TODO: For set elements, the segment names recorded in the node tree need // not match the corresponding path segments, so this function can fail.
// * If path ends at a leaf node or goes past a leaf node: // ** If that leaf node is startInclude: => CONTAINS_NODE // ** If that leaf node is !startInclude: => CONTAINS_NOT // * If path ends at inner node: // ** If there is some startInclude along its trace: => CONTAINS_NODE // ** If there is no startInclude along its trace: => CONTAINS_SUBNODES
Node const * p = &root_; bool bIncludes = false; for (autoconst& elemPath : path)
{
Node::Children::const_iterator j(p->children.find(elemPath)); if (j == p->children.end()) { return p->startInclude ? CONTAINS_NODE : CONTAINS_NOT;
}
p = &j->second;
bIncludes |= p->startInclude;
} return p->children.empty() && !p->startInclude
? CONTAINS_NOT
: bIncludes ? CONTAINS_NODE : CONTAINS_SUBNODES;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.