本文整理汇总了C++中Any::Empty方法的典型用法代码示例。如果您正苦于以下问题:C++ Any::Empty方法的具体用法?C++ Any::Empty怎么用?C++ Any::Empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Any
的用法示例。
在下文中一共展示了Any::Empty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetSurfaceFromAny
tbm_surface_h NativeImageSource::GetSurfaceFromAny( Any source ) const
{
if( source.Empty() )
{
return NULL;
}
if( source.GetType() == typeid( tbm_surface_h ) )
{
return AnyCast< tbm_surface_h >( source );
}
else
{
return NULL;
}
}
示例2: GetSurfaceId
unsigned int EcoreXRenderSurface::GetSurfaceId( Any surface ) const
{
unsigned int surfaceId = 0;
if ( surface.Empty() == false )
{
// check we have a valid type
DALI_ASSERT_ALWAYS( ( (surface.GetType() == typeid (XWindow) ) ||
(surface.GetType() == typeid (Ecore_X_Window) ) )
&& "Surface type is invalid" );
if ( surface.GetType() == typeid (Ecore_X_Window) )
{
surfaceId = AnyCast<Ecore_X_Window>( surface );
}
else
{
surfaceId = AnyCast<XWindow>( surface );
}
}
return surfaceId;
}
示例3: Compare
bool LDAPExpr::Compare( const Any& obj, int op, const std::string& s ) const
{
if (obj.Empty())
return false;
if (op == EQ && s == WILDCARD_STRING)
return true;
try
{
const std::type_info& objType = obj.Type();
if (objType == typeid(std::string))
{
return CompareString(ref_any_cast<std::string>(obj), op, s);
}
else if (objType == typeid(std::vector<std::string>))
{
const std::vector<std::string>& list = ref_any_cast<std::vector<std::string> >(obj);
for (std::size_t it = 0; it != list.size(); it++)
{
if (CompareString(list[it], op, s))
return true;
}
}
else if (objType == typeid(std::list<std::string>))
{
const std::list<std::string>& list = ref_any_cast<std::list<std::string> >(obj);
for (std::list<std::string>::const_iterator it = list.begin();
it != list.end(); ++it)
{
if (CompareString(*it, op, s))
return true;
}
}
else if (objType == typeid(char))
{
return CompareString(std::string(1, ref_any_cast<char>(obj)), op, s);
}
else if (objType == typeid(bool))
{
if (op==LE || op==GE)
return false;
std::string boolVal = any_cast<bool>(obj) ? "true" : "false";
return std::equal(s.begin(), s.end(), boolVal.begin(), stricomp);
}
else if (objType == typeid(short))
{
return CompareIntegralType<short>(obj, op, s);
}
else if (objType == typeid(int))
{
return CompareIntegralType<int>(obj, op, s);
}
else if (objType == typeid(long int))
{
return CompareIntegralType<long int>(obj, op, s);
}
else if (objType == typeid(long long int))
{
return CompareIntegralType<long long int>(obj, op, s);
}
else if (objType == typeid(unsigned char))
{
return CompareIntegralType<unsigned char>(obj, op, s);
}
else if (objType == typeid(unsigned short))
{
return CompareIntegralType<unsigned short>(obj, op, s);
}
else if (objType == typeid(unsigned int))
{
return CompareIntegralType<unsigned int>(obj, op, s);
}
else if (objType == typeid(unsigned long int))
{
return CompareIntegralType<unsigned long int>(obj, op, s);
}
else if (objType == typeid(unsigned long long int))
{
return CompareIntegralType<unsigned long long int>(obj, op, s);
}
else if (objType == typeid(float))
{
errno = 0;
char* endptr = 0;
double sFloat = strtod(s.c_str(), &endptr);
if ((errno == ERANGE && (sFloat == 0 || sFloat == HUGE_VAL || sFloat == -HUGE_VAL)) ||
(errno != 0 && sFloat == 0) || endptr == s.c_str())
{
return false;
}
double floatVal = static_cast<double>(any_cast<float>(obj));
switch(op)
{
case LE:
return floatVal <= sFloat;
case GE:
return floatVal >= sFloat;
//.........这里部分代码省略.........
示例4: Compare
bool LDAPExpr::Compare( const Any& obj, int op, const std::string& s ) const
{
if (obj.Empty())
return false;
if (op == EQ && s == WILDCARD_STRING)
return true;
try
{
const std::type_info& objType = obj.Type();
if (objType == typeid(std::string))
{
return CompareString(ref_any_cast<std::string>(obj), op, s);
}
else if (objType == typeid(std::vector<std::string>))
{
const std::vector<std::string>& list = ref_any_cast<std::vector<std::string> >(obj);
for (std::size_t it = 0; it != list.size(); it++)
{
if (CompareString(list[it], op, s))
return true;
}
}
else if (objType == typeid(std::list<std::string>))
{
const std::list<std::string>& list = ref_any_cast<std::list<std::string> >(obj);
for (std::list<std::string>::const_iterator it = list.begin();
it != list.end(); ++it)
{
if (CompareString(*it, op, s))
return true;
}
}
else if (objType == typeid(char))
{
return CompareString(std::string(1, ref_any_cast<char>(obj)), op, s);
}
else if (objType == typeid(bool))
{
if (op==LE || op==GE)
return false;
std::string boolVal = any_cast<bool>(obj) ? "true" : "false";
return std::equal(s.begin(), s.end(), boolVal.begin(), stricomp);
}
else if (objType == typeid(Byte) || objType == typeid(int))
{
int sInt;
std::stringstream ss(s);
ss >> sInt;
int intVal = any_cast<int>(obj);
switch(op)
{
case LE:
return intVal <= sInt;
case GE:
return intVal >= sInt;
default: /*APPROX and EQ*/
return intVal == sInt;
}
}
else if (objType == typeid(float))
{
float sFloat;
std::stringstream ss(s);
ss >> sFloat;
float floatVal = any_cast<float>(obj);
switch(op)
{
case LE:
return floatVal <= sFloat;
case GE:
return floatVal >= sFloat;
default: /*APPROX and EQ*/
float diff = floatVal - sFloat;
return (diff < std::numeric_limits<float>::epsilon()) && (diff > -std::numeric_limits<float>::epsilon());
}
}