当前位置: 首页>>代码示例>>C++>>正文


C++ VRefParam::toInt64方法代码示例

本文整理汇总了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;
  }
}
开发者ID:BiggDaddy,项目名称:hhvm,代码行数:31,代码来源:ext_icu_date_fmt.cpp

示例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;
}
开发者ID:6api,项目名称:hhvm,代码行数:31,代码来源:ext_icu_num_fmt.cpp

示例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;
}
开发者ID:devmario,项目名称:hiphop-php,代码行数:13,代码来源:ext_variable.cpp

示例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;
}
开发者ID:Halfnhav,项目名称:hiphop-php,代码行数:13,代码来源:ext_variable.cpp

示例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;
}
开发者ID:vlajos,项目名称:hhvm,代码行数:13,代码来源:ext_std_variable.cpp

示例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;
}
开发者ID:nadanomics,项目名称:hhvm,代码行数:42,代码来源:ext_pcre.cpp


注:本文中的VRefParam::toInt64方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。