| 383 | } |
| 384 | |
| 385 | bool |
| 386 | LDAPExpr::GetMatchedObjectClasses(ObjectClassSet& objClasses) const |
| 387 | { |
| 388 | if (d->m_operator == EQ) |
| 389 | { |
| 390 | if (d->m_attrName.length() == Constants::OBJECTCLASS.length() |
| 391 | && std::equal(d->m_attrName.begin(), d->m_attrName.end(), Constants::OBJECTCLASS.begin(), stricomp) |
| 392 | && d->m_attrValue.find(LDAPExprConstants::WILDCARD()) == std::string::npos) |
| 393 | { |
| 394 | objClasses.insert(d->m_attrValue); |
| 395 | return true; |
| 396 | } |
| 397 | return false; |
| 398 | } |
| 399 | else if (d->m_operator == AND) |
| 400 | { |
| 401 | bool result = false; |
| 402 | for (auto const& m_arg : d->m_args) |
| 403 | { |
| 404 | LDAPExpr::ObjectClassSet r; |
| 405 | if (m_arg.GetMatchedObjectClasses(r)) |
| 406 | { |
| 407 | result = true; |
| 408 | if (objClasses.empty()) |
| 409 | { |
| 410 | objClasses = r; |
| 411 | } |
| 412 | else |
| 413 | { |
| 414 | // if AND op and classes in several operands, |
| 415 | // then only the intersection is possible. |
| 416 | auto it1 = objClasses.begin(); |
| 417 | auto it2 = r.begin(); |
| 418 | while ((it1 != objClasses.end()) && (it2 != r.end())) |
| 419 | { |
| 420 | if (*it1 < *it2) |
| 421 | { |
| 422 | objClasses.erase(it1++); |
| 423 | } |
| 424 | else if (*it2 < *it1) |
| 425 | { |
| 426 | ++it2; |
| 427 | } |
| 428 | else |
| 429 | { // *it1 == *it2 |
| 430 | ++it1; |
| 431 | ++it2; |
| 432 | } |
| 433 | } |
| 434 | // Anything left in set_1 from here on did not appear in set_2, |
| 435 | // so we remove it. |
| 436 | objClasses.erase(it1, objClasses.end()); |
| 437 | } |
| 438 | } |
| 439 | } |
| 440 | return result; |
| 441 | } |
| 442 | else if (d->m_operator == OR) |