MCPcopy Create free account
hub / github.com/CppMicroServices/CppMicroServices / CompareIntegralType

Method CompareIntegralType

framework/src/util/LDAPExpr.cpp:813–838  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

811
812 template <typename T>
813 bool
814 LDAPExpr::CompareIntegralType(Any const& obj, int const op, std::string const& s) const
815 {
816 errno = 0;
817 char* endptr = nullptr;
818 long longInt = strtol(s.c_str(), &endptr, 10);
819 if ((errno == ERANGE
820 && (longInt == std::numeric_limits<long>::max() || longInt == std::numeric_limits<long>::min()))
821 || (errno != 0 && longInt == 0) || endptr == s.c_str())
822 {
823 return false;
824 }
825
826 auto sInt = static_cast<T>(longInt);
827 auto intVal = any_cast<T>(obj);
828
829 switch (op)
830 {
831 case LE:
832 return intVal <= sInt;
833 case GE:
834 return intVal >= sInt;
835 default: /*APPROX and EQ*/
836 return intVal == sInt;
837 }
838 }
839
840 bool
841 LDAPExpr::CompareString(const std::string_view s1, int op, const std::string_view s2)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected