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


C++ VRefParam类代码示例

本文整理汇总了C++中VRefParam的典型用法代码示例。如果您正苦于以下问题:C++ VRefParam类的具体用法?C++ VRefParam怎么用?C++ VRefParam使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了VRefParam类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: HHVM_METHOD

static Variant HHVM_METHOD(IntlDateFormatter, localtime,
                           const String& value, VRefParam position) {
  DATFMT_GET(data, this_, uninit_null());
  int32_t parse_pos = -1;
  if (!position.isNull()) {
    parse_pos = position.toInt64();
    if (parse_pos > value.size()) {
      return false;
    }
  }

  UErrorCode error = U_ZERO_ERROR;
  String uValue(u16(value, error));
  if (U_FAILURE(error)) {
    data->setError(error, "Error converting timezone to UTF-16");
    return false;
  }

  error = U_ZERO_ERROR;
  UCalendar *cal = const_cast<UCalendar*>(udat_getCalendar(data->datefmt()));
  udat_parseCalendar(data->datefmt(), cal,
                     (UChar*)uValue.c_str(), uValue.size() / sizeof(UChar),
                     &parse_pos, &error);

  Array ret = Array::Create();
  error = U_ZERO_ERROR;
  add_to_localtime_arr(ret, cal, UCAL_SECOND, s_tm_sec, error);
  add_to_localtime_arr(ret, cal, UCAL_MINUTE, s_tm_min, error);
  add_to_localtime_arr(ret, cal, UCAL_HOUR_OF_DAY, s_tm_hour, error);
  add_to_localtime_arr(ret, cal, UCAL_YEAR, s_tm_year, error, -1900);
  add_to_localtime_arr(ret, cal, UCAL_DAY_OF_MONTH, s_tm_mday, error);
  add_to_localtime_arr(ret, cal, UCAL_DAY_OF_WEEK, s_tm_wday, error, -1);
  add_to_localtime_arr(ret, cal, UCAL_DAY_OF_YEAR, s_tm_yday, error);
  add_to_localtime_arr(ret, cal, UCAL_MONTH, s_tm_mon, error);
  if (U_FAILURE(error)) {
    data->setError(error, "Date parsing - localtime failed : "
                          "could not get a field from calendar");
    return false;
  }

  error = U_ZERO_ERROR;
  auto isDST = ucal_inDaylightTime(cal, &error);
  if (U_FAILURE(error)) {
    data->setError(error, "Date parsing - localtime failed : "
                          "while checking if currently in DST.");
    return false;
  }
  ret.set(s_tm_isdst, isDST ? 1 : 0);

  position = (int64_t)parse_pos;
  return ret;
}
开发者ID:BiggDaddy,项目名称:hhvm,代码行数:52,代码来源:ext_icu_date_fmt.cpp

示例2: HHVM_FUNCTION

String HHVM_FUNCTION(pagelet_server_task_result,
                     const Resource& task,
                     VRefParam headers,
                     VRefParam code,
                     int64_t timeout_ms /* = 0 */) {
  Array rheaders;
  int rcode;
  String response = PageletServer::TaskResult(task, rheaders, rcode,
                                              timeout_ms);
  headers.assignIfRef(rheaders);
  code.assignIfRef(rcode);
  return response;
}
开发者ID:Thomascarette,项目名称:hhvm,代码行数:13,代码来源:ext_server.cpp

示例3: walk_func

static void walk_func(VRefParam value, CVarRef key, CVarRef userdata,
                      const void *data) {
  CallCtx* ctx = (CallCtx*)data;
  Variant sink;
  TypedValue args[3] = { *value->asRef(), *key.asCell(), *userdata.asCell() };
  g_vmContext->invokeFuncFew(sink.asTypedValue(), *ctx, 3, args);
}
开发者ID:barkinet,项目名称:hhvm,代码行数:7,代码来源:ext_array.cpp

示例4: f_msg_send

bool f_msg_send(CResRef queue, int64_t msgtype, CVarRef message,
                bool serialize /* = true */, bool blocking /* = true */,
                VRefParam errorcode /* = null */) {
  MessageQueue *q = queue.getTyped<MessageQueue>();
  if (!q) {
    raise_warning("Invalid message queue was specified");
    return false;
  }

  struct msgbuf *buffer = NULL;
  String data;
  if (serialize) {
    data = f_serialize(message);
  } else {
    data = message.toString();
  }
  int len = data.length();
  buffer = (struct msgbuf *)calloc(len + sizeof(struct msgbuf), 1);
  ScopedMem deleter(buffer);
  MSGBUF_MTYPE(buffer) = msgtype;
  memcpy(MSGBUF_MTEXT(buffer), data.c_str(), len + 1);

  int result = msgsnd(q->id, buffer, len, blocking ? 0 : IPC_NOWAIT);
  if (result < 0) {
    int err = errno;
    raise_warning("Unable to send message: %s",
                    folly::errnoStr(err).c_str());
    if (!errorcode.isNull()) {
      errorcode = err;
    }
    return false;
  }
  return true;
}
开发者ID:RdeWilde,项目名称:hhvm,代码行数:34,代码来源:ext_ipc.cpp

示例5: HHVM_FUNCTION

String HHVM_FUNCTION(system,
                     const String& command,
                     VRefParam return_var /* = null */) {
  ShellExecContext ctx;
  FILE *fp = ctx.exec(command);
  if (!fp) return empty_string();
  StringBuffer sbuf;
  if (fp) {
    sbuf.read(fp);
  }

  Array lines = StringUtil::Explode(sbuf.detach(), "\n").toArray();
  int ret = ctx.exit();
  if (WIFEXITED(ret)) ret = WEXITSTATUS(ret);
  return_var.assignIfRef(ret);
  int count = lines.size();
  if (count > 0 && lines[count - 1].toString().empty()) {
    count--; // remove explode()'s last empty line
  }

  auto& ectx = *g_context;
  for (int i = 0; i < count; i++) {
    ectx.write(lines[i].toString());
    ectx.write("\n");
  }
  if (!count || lines.empty()) {
    return String();
  }

  return HHVM_FN(rtrim)(lines[count - 1].toString());
}
开发者ID:anthonyattard,项目名称:hhvm,代码行数:31,代码来源:ext_std_process.cpp

示例6: 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

示例7: Walk

void ArrayUtil::Walk(VRefParam input, PFUNC_WALK walk_function,
                     const void *data, bool recursive /* = false */,
                     PointerSet *seen /* = NULL */,
                     CVarRef userdata /* = null_variant */) {
  assert(walk_function);

  Variant k;
  Variant v;
  for (MutableArrayIter iter = input->begin(&k, v); iter.advance(); ) {
    if (recursive && v.is(KindOfArray)) {
      assert(seen);
      ArrayData *arr = v.getArrayData();

      if (v.isReferenced()) {
        if (seen->find((void*)arr) != seen->end()) {
          raise_warning("array_walk_recursive(): recursion detected");
          return;
        }
        seen->insert((void*)arr);
      }

      Walk(directRef(v), walk_function, data, recursive, seen, userdata);
      if (v.isReferenced()) {
        seen->erase((void*)arr);
      }
    } else {
      walk_function(directRef(v), k, userdata, data);
    }
  }
}
开发者ID:RdeWilde,项目名称:hhvm,代码行数:30,代码来源:array-util.cpp

示例8: HHVM_FUNCTION

String HHVM_FUNCTION(exec,
                     const String& command,
                     VRefParam output /* = null */,
                     VRefParam return_var /* = null */) {
  ShellExecContext ctx;
  FILE *fp = ctx.exec(command);
  if (!fp) return empty_string();
  StringBuffer sbuf;
  sbuf.read(fp);

  Array lines = StringUtil::Explode(sbuf.detach(), "\n").toArray();
  int ret = ctx.exit();
  if (WIFEXITED(ret)) ret = WEXITSTATUS(ret);
  return_var = ret;
  int count = lines.size();
  if (count > 0 && lines[count - 1].toString().empty()) {
    count--; // remove explode()'s last empty line
  }

  PackedArrayInit pai(count);
  for (int i = 0; i < count; i++) {
    pai.append(lines[i]);
  }
  output.wrapped() = pai.toArray();

  if (!count || lines.empty()) {
    return String();
  }

  return HHVM_FN(rtrim)(lines[count - 1].toString());
}
开发者ID:milesj,项目名称:hhvm,代码行数:31,代码来源:ext_process.cpp

示例9: HHVM_FUNCTION

Variant HHVM_FUNCTION(preg_match,
                      const String& pattern, const String& subject,
                      VRefParam matches /* = null */,
                      int flags /* = 0 */, int offset /* = 0 */) {
  return preg_match(pattern, subject,
                    matches.getVariantOrNull(),
                    flags, offset);
}
开发者ID:bd808,项目名称:hhvm,代码行数:8,代码来源:ext_pcre.cpp

示例10: f_preg_match_all

Variant f_preg_match_all(CStrRef pattern, CStrRef subject, VRefParam matches,
                         int flags /* = 0 */, int offset /* = 0 */) {
  if (matches.isReferenced()) {
    return preg_match_all(pattern, subject, matches, flags, offset);
  } else {
    return preg_match_all(pattern, subject, flags, offset);
  }
}
开发者ID:7755373049,项目名称:hiphop-php,代码行数:8,代码来源:ext_preg.cpp

示例11: f_shuffle

bool f_shuffle(VRefParam array) {
  if (!array.isArray()) {
    throw_bad_array_exception();
    return false;
  }
  array = ArrayUtil::Shuffle(array);
  return true;
}
开发者ID:SagaieNet,项目名称:hiphop-php,代码行数:8,代码来源:ext_array.cpp

示例12: HHVM_FUNCTION

Variant HHVM_FUNCTION(preg_match, const String& pattern, const String& subject,
                                  VRefParam matches /* = null */,
                                  int flags /* = 0 */, int offset /* = 0 */) {
  if (matches.isReferenced()) {
    return preg_match(pattern, subject, matches, flags, offset);
  } else {
    return preg_match(pattern, subject, flags, offset);
  }
}
开发者ID:IshanRastogi,项目名称:hhvm,代码行数:9,代码来源:ext_pcre.cpp

示例13: f_msg_receive

bool f_msg_receive(CResRef queue, int64_t desiredmsgtype, VRefParam msgtype,
                   int64_t maxsize, VRefParam message,
                   bool unserialize /* = true */,
                   int64_t flags /* = 0 */, VRefParam errorcode /* = null */) {
  MessageQueue *q = queue.getTyped<MessageQueue>();
  if (!q) {
    raise_warning("Invalid message queue was specified");
    return false;
  }

  if (maxsize <= 0) {
    raise_warning("Maximum size of the message has to be greater than zero");
    return false;
  }

  int64_t realflags = 0;
  if (flags != 0) {
#if !defined(__APPLE__) && !defined(__FreeBSD__)
    if (flags & k_MSG_EXCEPT) realflags |= MSG_EXCEPT;
#endif
    if (flags & k_MSG_NOERROR) realflags |= MSG_NOERROR;
    if (flags & k_MSG_IPC_NOWAIT) realflags |= IPC_NOWAIT;
  }

  struct msgbuf *buffer =
    (struct msgbuf *)calloc(maxsize + sizeof(struct msgbuf), 1);
  ScopedMem deleter(buffer);

  int result = msgrcv(q->id, buffer, maxsize, desiredmsgtype, realflags);
  if (result < 0) {
    int err = errno;
    raise_warning("Unable to receive message: %s",
                    folly::errnoStr(err).c_str());
    if (!errorcode.isNull()) {
      errorcode = err;
    }
    return false;
  }

  msgtype = (int)MSGBUF_MTYPE(buffer);
  if (unserialize) {
    const char *bufText = (const char *)MSGBUF_MTEXT(buffer);
    uint bufLen = strlen(bufText);
    VariableUnserializer vu(bufText, bufLen,
                            VariableUnserializer::Type::Serialize);
    try {
      message = vu.unserialize();
    } catch (Exception &e) {
      raise_warning("Message corrupted");
      return false;
    }
  } else {
    message = String((const char *)MSGBUF_MTEXT(buffer));
  }

  return true;
}
开发者ID:RdeWilde,项目名称:hhvm,代码行数:57,代码来源:ext_ipc.cpp

示例14: parse_str_impl

static void parse_str_impl(const String& str, VRefParam arr) {
  Array result = Array::Create();
  HttpProtocol::DecodeParameters(result, str.data(), str.size());
  if (!arr.isReferenced()) {
    HHVM_FN(SystemLib_extract)(result);
    return;
  }
  arr = result;
}
开发者ID:vlajos,项目名称:hhvm,代码行数:9,代码来源:ext_std_variable.cpp

示例15: poll

int ZMQPollData::poll(int64_t timeout, VRefParam readable, VRefParam writable) {
  errors.clear();

  auto rVar = readable.getVariantOrNull();
  Array rArr;
  if (rVar && rVar->isArray()) {
    rArr = rVar->asArrRef();
    rArr.clear();
  }

  auto wVar = writable.getVariantOrNull();
  Array wArr;
  if (wVar && wVar->isArray()) {
    wArr = wVar->asArrRef();
    wArr.clear();
  }

  assert(items.size() == php_items.size());

  int rc = zmq_poll(items.data(), items.size(), timeout);
  if (rc == -1) {
    return -1;
  }

  if (rc > 0) {
    for (size_t i = 0; i < items.size(); i++) {
      if (rVar && (items[i].revents & ZMQ_POLLIN)) {
        rArr.append(php_items[i].entry);
      }
      if (wVar && (items[i].revents & ZMQ_POLLOUT)) {
        wArr.append(php_items[i].entry);
      }

      if (items[i].revents & ZMQ_POLLERR) {
        errors.append(php_items[i].key);
      }
    }
  }

  readable.assignIfRef(rArr);
  writable.assignIfRef(wArr);
  return rc;
}
开发者ID:Orvid,项目名称:php-zmq,代码行数:43,代码来源:ext_zmq.cpp


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