本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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;
}
示例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());
}
示例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;
}
示例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);
}
}
}
示例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());
}
示例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);
}
示例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);
}
}
示例11: f_shuffle
bool f_shuffle(VRefParam array) {
if (!array.isArray()) {
throw_bad_array_exception();
return false;
}
array = ArrayUtil::Shuffle(array);
return true;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}