本文整理汇总了C++中StringData::isStrictlyInteger方法的典型用法代码示例。如果您正苦于以下问题:C++ StringData::isStrictlyInteger方法的具体用法?C++ StringData::isStrictlyInteger怎么用?C++ StringData::isStrictlyInteger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringData
的用法示例。
在下文中一共展示了StringData::isStrictlyInteger方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: f_array_key_exists
HOT_FUNC
bool f_array_key_exists(CVarRef key, CVarRef search) {
const ArrayData *ad;
auto const searchCell = search.asCell();
if (LIKELY(searchCell->m_type == KindOfArray)) {
ad = searchCell->m_data.parr;
} else if (searchCell->m_type == KindOfObject) {
ObjectData* obj = searchCell->m_data.pobj;
if (obj->isCollection()) {
return collectionOffsetContains(obj, key);
}
return f_array_key_exists(key, toArray(search));
} else {
throw_bad_type_exception("array_key_exists expects an array or an object; "
"false returned.");
return false;
}
auto const cell = key.asCell();
switch (cell->m_type) {
case KindOfString:
case KindOfStaticString: {
int64_t n = 0;
StringData *sd = cell->m_data.pstr;
if (sd->isStrictlyInteger(n)) {
return ad->exists(n);
}
return ad->exists(StrNR(sd));
}
case KindOfInt64:
return ad->exists(cell->m_data.num);
case KindOfUninit:
case KindOfNull:
return ad->exists(empty_string);
default:
break;
}
raise_warning("Array key should be either a string or an integer");
return false;
}
示例2: f_array_key_exists
HOT_FUNC
bool f_array_key_exists(CVarRef key, CVarRef search) {
const ArrayData *ad;
Variant::TypedValueAccessor sacc = search.getTypedAccessor();
DataType saccType = Variant::GetAccessorType(sacc);
if (LIKELY(saccType == KindOfArray)) {
ad = Variant::GetArrayData(sacc);
} else if (saccType == KindOfObject) {
return f_array_key_exists(key, toArray(search));
} else {
throw_bad_type_exception("array_key_exists expects an array or an object; "
"false returned.");
return false;
}
Variant::TypedValueAccessor kacc = key.getTypedAccessor();
switch (Variant::GetAccessorType(kacc)) {
case KindOfString:
case KindOfStaticString: {
int64_t n = 0;
StringData *sd = Variant::GetStringData(kacc);
if (sd->isStrictlyInteger(n)) {
return ad->exists(n);
}
return ad->exists(StrNR(sd));
}
case KindOfInt64:
return ad->exists(Variant::GetInt64(kacc));
case KindOfUninit:
case KindOfNull:
return ad->exists(empty_string);
default:
break;
}
raise_warning("Array key should be either a string or an integer");
return false;
}