// This sets the various recording data to the values they should have // before reading in some text. inline void RestrictedXmlParser::ResetContent() { fileProlog.assign( "" ); rootName.assign( "" ); rootAttributes.clear(); currentName.assign( "" ); currentAttributes.clear(); currentBody.assign( "" ); currentElementIsEmpty = true; }
vector<AttributeMap> Ldap::search(string base, int scope, string filter, const StringList& attribs) { if(bound == false) { return vector<AttributeMap>(); } LDAPSearchResults* lr = lc->search(base, scope, filter,attribs, false); LDAPEntry* le; const LDAPAttribute* la; StringList s; vector<AttributeMap> result; AttributeMap temp; int i = 0; while( (le = lr->getNext()) ) { for(StringList::const_iterator it =attribs.begin(); it!=attribs.end(); it++) { //cout << endl << "Name: " << *it << " |"; la = le->getAttributeByName(*it); if(la == NULL) continue; s = la->getValues(); for(StringList::const_iterator st = s.begin(); st != s.end(); st ++) { // concatenates multivalues with | temp[*it] += (i>0?"|"+*st:*st); i++; } i=0; } //cout << endl; if(temp.size() > 0) { result.push_back(temp); temp.clear(); } } return result; }
// This moves forward in the current content to parse until the next // element start tag is found, then that element is read in until its end // tag is found, and the character just after that is where the next call // of this function will resume. The element just parsed is accessible // through CurrentName() for its name, CurrentAttributes() for its // attributes, and CurrentBody() for the text between the start and end // tags. The return value is true if an element was read in, or false if no // more valid elements could be found. (If no further elements are // found, the next call of this function will do nothing, as the next // character will just be the EOF character.) inline bool RestrictedXmlParser::ReadNextElement() { if( ReadToNextTagOpener( NULL ) ) { currentName.assign( "" ); currentAttributes.clear(); currentBody.assign( "" ); currentElementIsEmpty = true; ReadStartTag( currentName, ¤tAttributes, NULL ); if( !currentElementIsEmpty ) { RecordToEndOfElement( currentName ); } return true; } return false; }