本文整理汇总了C++中VRefParam::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ VRefParam::toString方法的具体用法?C++ VRefParam::toString怎么用?C++ VRefParam::toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VRefParam
的用法示例。
在下文中一共展示了VRefParam::toString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: f_socket_recvfrom
Variant f_socket_recvfrom(CObjRef socket, VRefParam buf, int len, int flags,
VRefParam name, VRefParam port /* = 0 */) {
if (len <= 0) {
return false;
}
Socket *sock = socket.getTyped<Socket>();
char *recv_buf = (char *)malloc(len + 2);
socklen_t slen;
int retval;
switch (sock->getType()) {
case AF_UNIX:
{
struct sockaddr_un s_un;
slen = sizeof(s_un);
memset(&s_un, 0, slen);
s_un.sun_family = AF_UNIX;
retval = recvfrom(sock->fd(), recv_buf, len, flags,
(struct sockaddr *)&s_un, (socklen_t *)&slen);
if (retval < 0) {
free(recv_buf);
SOCKET_ERROR(sock, "unable to recvfrom", errno);
return false;
}
recv_buf[retval] = 0;
buf = String(recv_buf, retval, AttachString);
name = String(s_un.sun_path, CopyString);
}
break;
case AF_INET:
{
struct sockaddr_in sin;
slen = sizeof(sin);
memset(&sin, 0, slen);
sin.sin_family = AF_INET;
retval = recvfrom(sock->fd(), recv_buf, len, flags,
(struct sockaddr *)&sin, (socklen_t *)&slen);
if (retval < 0) {
free(recv_buf);
SOCKET_ERROR(sock, "unable to recvfrom", errno);
return false;
}
recv_buf[retval] = 0;
buf = String(recv_buf, retval, AttachString);
name = String(Util::safe_inet_ntoa(sin.sin_addr));
if (name.toString().empty()) {
name = s_0_0_0_0;
}
port = ntohs(sin.sin_port);
}
break;
case AF_INET6:
{
struct sockaddr_in6 sin6;
slen = sizeof(sin6);
memset(&sin6, 0, slen);
sin6.sin6_family = AF_INET6;
retval = recvfrom(sock->fd(), recv_buf, len, flags,
(struct sockaddr *)&sin6, (socklen_t *)&slen);
if (retval < 0) {
free(recv_buf);
SOCKET_ERROR(sock, "unable to recvfrom", errno);
return false;
}
char addr6[INET6_ADDRSTRLEN];
const char* succ =
inet_ntop(AF_INET6, &sin6.sin6_addr, addr6, INET6_ADDRSTRLEN);
recv_buf[retval] = 0;
buf = String(recv_buf, retval, AttachString);
if (succ) {
name = String(addr6, CopyString);
} else {
name = s_2colons;
}
port = ntohs(sin6.sin6_port);
}
break;
default:
raise_warning("Unsupported socket type %d", sock->getType());
return false;
}
return retval;
}