本文整理汇总了C++中VRefParam类的典型用法代码示例。如果您正苦于以下问题:C++ VRefParam类的具体用法?C++ VRefParam怎么用?C++ VRefParam使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VRefParam类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: t_getbykey
Variant c_Memcached::t_getbykey(CStrRef server_key, CStrRef key,
CVarRef cache_cb /*= null_variant*/,
VRefParam cas_token /*= null_variant*/) {
INSTANCE_METHOD_INJECTION_BUILTIN(Memcached, Memcached::getbykey);
m_impl->rescode = q_Memcached_RES_SUCCESS;
if (key.empty()) {
m_impl->rescode = q_Memcached_RES_BAD_KEY_PROVIDED;
return false;
}
memcached_behavior_set(&m_impl->memcached, MEMCACHED_BEHAVIOR_SUPPORT_CAS,
cas_token.isReferenced() ? 1 : 0);
const char *myServerKey = server_key.empty() ? NULL : server_key.c_str();
size_t myServerKeyLen = server_key.length();
const char *myKey = key.c_str();
size_t myKeyLen = key.length();
memcached_return status = memcached_mget_by_key(&m_impl->memcached,
myServerKey, myServerKeyLen, &myKey, &myKeyLen, 1);
if (!handleError(status)) return false;
Variant returnValue;
MemcachedResultWrapper result(&m_impl->memcached);
if (!memcached_fetch_result(&m_impl->memcached, &result.value, &status)) {
if (status == MEMCACHED_END) status = MEMCACHED_NOTFOUND;
if (status == MEMCACHED_NOTFOUND && !cache_cb.isNull()) {
status = doCacheCallback(cache_cb, key, returnValue);
if (!handleError(status)) return false;
if (cas_token.isReferenced()) cas_token = 0.0;
return returnValue;
}
handleError(status);
return false;
}
if (!toObject(returnValue, result.value)) {
m_impl->rescode = q_Memcached_RES_PAYLOAD_FAILURE;
return false;
}
if (cas_token.isReferenced()) {
cas_token = (double) memcached_result_cas(&result.value);
}
return returnValue;
}
开发者ID:HyeongKyu,项目名称:hiphop-php,代码行数:43,代码来源:ext_memcached.cpp
示例17: walk_func
static void walk_func(VRefParam value, CVarRef key, CVarRef userdata,
const void *data) {
CallCtx* ctx = (CallCtx*)data;
Variant sink;
TypedValue args[3];
tvDup(*value->asTypedValue(), args[0]);
tvDup(*key.asTypedValue(), args[1]);
tvDup(*userdata.asTypedValue(), args[2]);
g_vmContext->invokeFuncFew(sink.asTypedValue(), *ctx, 3, args);
}
开发者ID:vincentbdb,项目名称:hiphop-php,代码行数:10,代码来源:ext_array.cpp
示例18: f_hphp_get_iterator
static Variant f_hphp_get_iterator(VRefParam iterable, bool isMutable) {
if (iterable.isArray()) {
if (isMutable) {
return create_object(s_MutableArrayIterator,
CREATE_VECTOR1(ref(iterable)));
}
return create_object(s_ArrayIterator,
CREATE_VECTOR1(iterable));
}
if (iterable.isObject()) {
ObjectData *obj = iterable.getObjectData();
Variant iterator;
while (obj->instanceof(SystemLib::s_IteratorAggregateClass)) {
iterator = obj->o_invoke(s_getIterator, Array());
if (!iterator.isObject()) break;
obj = iterator.getObjectData();
}
VM::Class*ctx = g_vmContext->getContextClass();
CStrRef context = ctx ? ctx->nameRef() : empty_string;
if (isMutable) {
if (obj->instanceof(SystemLib::s_IteratorClass)) {
throw FatalErrorException("An iterator cannot be used for "
"iteration by reference");
}
Array properties = obj->o_toIterArray(context, true);
return create_object(s_MutableArrayIterator,
CREATE_VECTOR1(ref(properties)));
} else {
if (obj->instanceof(SystemLib::s_IteratorClass)) {
return obj;
}
return create_object(s_ArrayIterator,
CREATE_VECTOR1(obj->o_toIterArray(context)));
}
}
raise_warning("Invalid argument supplied for iteration");
if (isMutable) {
return create_object(s_MutableArrayIterator,
CREATE_VECTOR1(Array::Create()));
}
return create_object(s_ArrayIterator,
CREATE_VECTOR1(Array::Create()));
}
开发者ID:SagaieNet,项目名称:hiphop-php,代码行数:43,代码来源:ext_array.cpp
示例19: 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
示例20: HHVM_FUNCTION
int64_t HHVM_FUNCTION(pcntl_wait,
VRefParam status,
int options /* = 0 */) {
int nstatus = status;
auto const child_id = LightProcess::pcntl_waitpid(-1, &nstatus, options);
/* if (options) {
child_id = wait3(&nstatus, options, NULL);
} else {
child_id = wait(&nstatus);
}*/
status.assignIfRef(nstatus);
return child_id;
}
开发者ID:sunnygkp10,项目名称:hhvm,代码行数:13,代码来源:ext_process.cpp
注:本文中的VRefParam类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论