void splitTags(const string &tagString, TagSet &tagSet) { stringstream ss(tagString); string tag; while(getline(ss, tag, ',')) { tagSet.insert(tag); } }
void BooksUtil::collectTagsFromLibrary(TagList &tags) { const TagList &lTags = Library::Instance().tags(); TagSet tagSet; for (TagList::const_iterator it = lTags.begin(); it != lTags.end(); ++it) { shared_ptr<Tag> tag = *it; if (tag.isNull()) { tagSet.insert(tag); tags.push_back(tag); } else { TagList tagStack; do { tagStack.push_back(tag); tag = tag->parent(); } while (!tag.isNull() && tagSet.find(tag) == tagSet.end()); tagSet.insert(tagStack.begin(), tagStack.end()); tags.insert(tags.end(), tagStack.rbegin(), tagStack.rend()); } } }
bool ClassHandler::init(Core::BaseObject *obj, void *n, TagSet &mandatory) { xmlNodePtr node = reinterpret_cast<xmlNodePtr>(n); // Fill in mandatory tags for ( MemberList::iterator it = attributes.begin(); it != attributes.end(); ++it ) { if ( !it->optional ) mandatory.insert(it->tag); } for ( MemberList::iterator it = elements.begin(); it != elements.end(); ++it ) { if ( !it->optional && !it->tag.empty() ) mandatory.insert(it->tag); } for ( MemberList::iterator it = childs.begin(); it != childs.end(); ++it ) { if ( !it->optional && !it->tag.empty() ) mandatory.insert(it->tag); } if ( cdataUsed ) cdata.get(obj, n, this); if ( attributes.empty() ) return true; for ( xmlAttrPtr attr = node->properties; attr != NULL; attr = attr->next ) { if ( attr->children ) { for ( MemberList::iterator it = attributes.begin(); it != attributes.end(); ++it ) { if ( equalsTag(attr, it->tag.c_str(), it->nameSpace.c_str()) ) { if ( it->get(obj, attr, this) && !it->optional ) { mandatory.erase(it->tag); break; } } } } } return true; }