//--------------------------------------------------------- bool ofxXmlSettings::pushTag(const string& tag, int which){ int pos = tag.find(":"); // Either find the tag specified, or the first tag if colon-seperated. string tagToFind((pos > 0) ? tag.substr(0,pos) :tag); //we only allow to push one tag at a time. TiXmlHandle isRealHandle = storedHandle.ChildElement(tagToFind, which); if( isRealHandle.ToNode() ){ storedHandle = isRealHandle; level++; return true; }else{ ofLogError("ofxXmlSettings") << "pushTag(): tag \"" << tag << "\" not found"; } return false; }
//--------------------------------------------------------- bool ofxXmlSettings::pushTag(const string& tag, int which){ int pos = tag.find(":"); // Either find the tag specified, or the first tag if colon-seperated. string tagToFind((pos > 0) ? tag.substr(0,pos) :tag); //we only allow to push one tag at a time. TiXmlHandle isRealHandle = storedHandle.ChildElement(tagToFind, which); if( isRealHandle.ToNode() ){ storedHandle = isRealHandle; level++; return true; }else{ printf("pushTag - <"); printf("%s",tag.c_str()); printf("> tag not found\n"); } return false; }
//--------------------------------------------------------- int ofxXmlSettings::getNumTags(const string& tag){ //this only works for tags at the current root level int pos = tag.find(":"); // Either find the tag specified, or the first tag if colon-seperated. string tagToFind((pos > 0) ? tag.substr(0,pos) :tag); //grab the handle from the level we are at //normally this is the doc but could be a pushed node //TiXmlHandle tagHandle = storedHandle; int count = 0; //ripped from tinyXML as doing this ourselves once is a LOT! faster //than having this called n number of times in a while loop - we go from n*n iterations to n iterations TiXmlElement* child = ( storedHandle.FirstChildElement( tagToFind ) ).ToElement(); for (count = 0; child; child = child->NextSiblingElement( tagToFind ), ++count){ //nothing } return count; }