本文整理汇总了C++中VRefParam::toInt64方法的典型用法代码示例。如果您正苦于以下问题:C++ VRefParam::toInt64方法的具体用法?C++ VRefParam::toInt64怎么用?C++ VRefParam::toInt64使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VRefParam
的用法示例。
在下文中一共展示了VRefParam::toInt64方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HHVM_METHOD
static Variant HHVM_METHOD(IntlDateFormatter, parse,
const String& value, VRefParam position) {
DATFMT_GET(data, this_, 0);
int32_t pos = position.toInt64();
if (pos > value.size()) {
return false;
}
UErrorCode error = U_ZERO_ERROR;
String str(u16(value, error));
if (U_FAILURE(error)) {
data->setError(error, "Error converting timezone to UTF-16");
return false;
}
error = U_ZERO_ERROR;
UDate timestamp = udat_parse(data->datefmt(),
(UChar*)str.c_str(), str.size() / sizeof(UChar),
&pos, &error);
position = (int64_t)pos;
if (U_FAILURE(error)) {
data->setError(error, "Date parsing failed");
return false;
}
double result = (double)timestamp / U_MILLIS_PER_SECOND;
if ((result > LONG_MAX) || (result < -LONG_MAX)) {
return (double)((result > 0) ? ceil(result) : floor(result));
} else {
return (int64_t)result;
}
}
示例2: HHVM_METHOD
static Variant HHVM_METHOD(NumberFormatter, parse,
const String& value, int64_t type,
VRefParam position) {
NUMFMT_GET(obj, this_, false);
UErrorCode error = U_ZERO_ERROR;
icu::UnicodeString val(u16(value, error));
NUMFMT_CHECK(obj, error, false);
Variant ret;
int32_t pos = position.toInt64();
error = U_ZERO_ERROR;
switch (type) {
case UNUM(TYPE_INT32):
ret = unum_parse(obj->formatter(), val.getBuffer(), val.length(),
&pos, &error);
break;
case UNUM(TYPE_INT64):
ret = unum_parseInt64(obj->formatter(), val.getBuffer(), val.length(),
&pos, &error);
break;
case UNUM(TYPE_DOUBLE):
ret = unum_parseDouble(obj->formatter(), val.getBuffer(), val.length(),
&pos, &error);
break;
default:
obj->setError(U_UNSUPPORTED_ERROR);
return false;
}
NUMFMT_CHECK(obj, error, false);
position = pos;
return ret;
}
示例3: f_settype
bool f_settype(VRefParam var, CStrRef type) {
if (type == "boolean") var = var.toBoolean();
else if (type == "bool" ) var = var.toBoolean();
else if (type == "integer") var = var.toInt64();
else if (type == "int" ) var = var.toInt64();
else if (type == "float" ) var = var.toDouble();
else if (type == "string" ) var = var.toString();
else if (type == "array" ) var = var.toArray();
else if (type == "object" ) var = var.toObject();
else if (type == "null" ) var = null;
else return false;
return true;
}
示例4: f_settype
bool f_settype(VRefParam var, CStrRef type) {
if (type == s_boolean) var = var.toBoolean();
else if (type == s_bool ) var = var.toBoolean();
else if (type == s_integer) var = var.toInt64();
else if (type == s_int ) var = var.toInt64();
else if (type == s_float ) var = var.toDouble();
else if (type == s_string ) var = var.toString();
else if (type == s_array ) var = var.toArray();
else if (type == s_object ) var = var.toObject();
else if (type == s_null ) var = uninit_null();
else return false;
return true;
}
示例5: HHVM_FUNCTION
bool HHVM_FUNCTION(settype, VRefParam var, const String& type) {
if (type == s_boolean) var = var.toBoolean();
else if (type == s_bool ) var = var.toBoolean();
else if (type == s_integer) var = var.toInt64();
else if (type == s_int ) var = var.toInt64();
else if (type == s_float ) var = var.toDouble();
else if (type == s_string ) var = var.toString();
else if (type == s_array ) var = var.toArray();
else if (type == s_object ) var = var.toObject();
else if (type == s_null ) var = uninit_null();
else return false;
return true;
}
示例6: preg_replace_callback_array_impl
static Variant preg_replace_callback_array_impl(
const Variant& patterns_and_callbacks,
const Array& subjects,
int limit,
VRefParam count) {
Array ret = Array::Create();
auto key = 0;
auto total_replacement_count = 0;
for (ArrayIter s_iter(subjects); s_iter; ++s_iter) {
assert(s_iter.second().isString());
auto subj = s_iter.second();
for (ArrayIter pc_iter(patterns_and_callbacks.toArray());
pc_iter; ++pc_iter) {
Variant pattern(pc_iter.first());
assert(pattern.isString());
Variant callback(pc_iter.second());
subj = HHVM_FN(preg_replace_callback)(pattern, callback, subj, limit,
count);
// If we got an error on the replacement, the subject will be null,
// and then we will return null.
if (subj.isNull()) {
return init_null();
}
if (count.isReferenced()) {
total_replacement_count += count.toInt64();
}
}
ret.add(key++, subj);
}
// If count was passed in as an explicit reference, we will assign it to our
// total replacement count; otherwise, count will just remained unassigned
count.assignIfRef(total_replacement_count);
// If there were no replacements (i.e., matches) return original subject(s)
if (ret.empty()) {
return subjects;
}
return ret;
}