| 161 | } |
| 162 | |
| 163 | bool LDAPExpr::GetMatchedObjectClasses(ObjectClassSet& objClasses) const |
| 164 | { |
| 165 | if (d->m_operator == EQ) |
| 166 | { |
| 167 | if (d->m_attrName.length() == ServiceConstants::OBJECTCLASS().length() && |
| 168 | std::equal(d->m_attrName.begin(), d->m_attrName.end(), ServiceConstants::OBJECTCLASS().begin(), stricomp) && |
| 169 | d->m_attrValue.find(LDAPExprConstants::WILDCARD()) == std::string::npos) |
| 170 | { |
| 171 | objClasses.insert( d->m_attrValue ); |
| 172 | return true; |
| 173 | } |
| 174 | return false; |
| 175 | } |
| 176 | else if (d->m_operator == AND) |
| 177 | { |
| 178 | bool result = false; |
| 179 | for (std::size_t i = 0; i < d->m_args.size( ); i++) |
| 180 | { |
| 181 | LDAPExpr::ObjectClassSet r; |
| 182 | if (d->m_args[i].GetMatchedObjectClasses(r)) |
| 183 | { |
| 184 | result = true; |
| 185 | if (objClasses.empty()) |
| 186 | { |
| 187 | objClasses = r; |
| 188 | } |
| 189 | else |
| 190 | { |
| 191 | // if AND op and classes in several operands, |
| 192 | // then only the intersection is possible. |
| 193 | for (LDAPExpr::ObjectClassSet::iterator it1 = objClasses.begin(); |
| 194 | it1 != objClasses.end(); ) |
| 195 | { |
| 196 | if (r.find(*it1) == r.end()) |
| 197 | { |
| 198 | objClasses.erase(it1++); |
| 199 | } |
| 200 | else |
| 201 | { |
| 202 | ++it1; |
| 203 | } |
| 204 | } |
| 205 | } |
| 206 | } |
| 207 | } |
| 208 | return result; |
| 209 | } |
| 210 | else if (d->m_operator == OR) |
| 211 | { |
| 212 | for (std::size_t i = 0; i < d->m_args.size( ); i++) |
| 213 | { |
| 214 | LDAPExpr::ObjectClassSet r; |
| 215 | if (d->m_args[i].GetMatchedObjectClasses(r)) |
| 216 | { |
| 217 | std::copy(r.begin(), r.end(), std::inserter(objClasses, objClasses.begin())); |
| 218 | } |
| 219 | else |
| 220 | { |