| 310 | } |
| 311 | |
| 312 | bool LDAPExpr::Compare( const Any& obj, int op, const std::string& s ) const |
| 313 | { |
| 314 | if (obj.Empty()) |
| 315 | return false; |
| 316 | if (op == EQ && s == LDAPExprConstants::WILDCARD_STRING()) |
| 317 | return true; |
| 318 | |
| 319 | try |
| 320 | { |
| 321 | const std::type_info& objType = obj.Type(); |
| 322 | if (objType == typeid(std::string)) |
| 323 | { |
| 324 | return CompareString(ref_any_cast<std::string>(obj), op, s); |
| 325 | } |
| 326 | else if (objType == typeid(std::vector<std::string>)) |
| 327 | { |
| 328 | const std::vector<std::string>& list = ref_any_cast<std::vector<std::string> >(obj); |
| 329 | for (std::size_t it = 0; it != list.size(); it++) |
| 330 | { |
| 331 | if (CompareString(list[it], op, s)) |
| 332 | return true; |
| 333 | } |
| 334 | } |
| 335 | else if (objType == typeid(std::list<std::string>)) |
| 336 | { |
| 337 | const std::list<std::string>& list = ref_any_cast<std::list<std::string> >(obj); |
| 338 | for (std::list<std::string>::const_iterator it = list.begin(); |
| 339 | it != list.end(); ++it) |
| 340 | { |
| 341 | if (CompareString(*it, op, s)) |
| 342 | return true; |
| 343 | } |
| 344 | } |
| 345 | else if (objType == typeid(char)) |
| 346 | { |
| 347 | return CompareString(std::string(1, ref_any_cast<char>(obj)), op, s); |
| 348 | } |
| 349 | else if (objType == typeid(bool)) |
| 350 | { |
| 351 | if (op==LE || op==GE) |
| 352 | return false; |
| 353 | |
| 354 | std::string boolVal = any_cast<bool>(obj) ? "true" : "false"; |
| 355 | return s.size() == boolVal.size() && std::equal(s.begin(), s.end(), boolVal.begin(), stricomp); |
| 356 | } |
| 357 | else if (objType == typeid(short)) |
| 358 | { |
| 359 | return CompareIntegralType<short>(obj, op, s); |
| 360 | } |
| 361 | else if (objType == typeid(int)) |
| 362 | { |
| 363 | return CompareIntegralType<int>(obj, op, s); |
| 364 | } |
| 365 | else if (objType == typeid(long int)) |
| 366 | { |
| 367 | return CompareIntegralType<long int>(obj, op, s); |
| 368 | } |
| 369 | else if (objType == typeid(long long int)) |