本文整理汇总了C++中PHPInputTransport::readI8方法的典型用法代码示例。如果您正苦于以下问题:C++ PHPInputTransport::readI8方法的具体用法?C++ PHPInputTransport::readI8怎么用?C++ PHPInputTransport::readI8使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPInputTransport
的用法示例。
在下文中一共展示了PHPInputTransport::readI8方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: skip_element
void skip_element(long thrift_typeID, PHPInputTransport& transport) {
switch (thrift_typeID) {
case T_STOP:
case T_VOID:
return;
case T_STRUCT:
while (true) {
int8_t ttype = transport.readI8(); // get field type
if (ttype == T_STOP) break;
transport.skip(2); // skip field number, I16
skip_element(ttype, transport); // skip field payload
}
return;
case T_BOOL:
case T_BYTE:
transport.skip(1);
return;
case T_I16:
transport.skip(2);
return;
case T_I32:
case T_FLOAT:
transport.skip(4);
return;
case T_U64:
case T_I64:
case T_DOUBLE:
transport.skip(8);
return;
//case T_UTF7: // aliases T_STRING
case T_UTF8:
case T_UTF16:
case T_STRING: {
uint32_t len = transport.readU32();
transport.skip(len);
} return;
case T_MAP: {
int8_t keytype = transport.readI8();
int8_t valtype = transport.readI8();
uint32_t size = transport.readU32();
for (uint32_t i = 0; i < size; ++i) {
skip_element(keytype, transport);
skip_element(valtype, transport);
}
} return;
case T_LIST:
case T_SET: {
int8_t valtype = transport.readI8();
uint32_t size = transport.readU32();
for (uint32_t i = 0; i < size; ++i) {
skip_element(valtype, transport);
}
} return;
};
char errbuf[128];
sprintf(errbuf, "Unknown thrift typeID %ld", thrift_typeID);
throw_tprotocolexception(String(errbuf, CopyString), INVALID_DATA);
}
示例2: binary_deserialize_spec
void binary_deserialize_spec(const Object& zthis, PHPInputTransport& transport,
const Array& spec) {
// SET and LIST have 'elem' => array('type', [optional] 'class')
// MAP has 'val' => array('type', [optiona] 'class')
while (true) {
Variant val;
int8_t ttype = transport.readI8();
if (ttype == T_STOP) return;
int16_t fieldno = transport.readI16();
if (!(val = spec.rvalAt(fieldno)).isNull()) {
Array fieldspec = val.toArray();
// pull the field name
// zend hash tables use the null at the end in the length... so strlen(hash key) + 1.
String varname = fieldspec.rvalAt(PHPTransport::s_var).toString();
// and the type
int8_t expected_ttype = fieldspec.rvalAt(PHPTransport::s_type).toInt64();
if (ttypes_are_compatible(ttype, expected_ttype)) {
Variant rv = binary_deserialize(ttype, transport, fieldspec);
zthis->o_set(varname, rv, zthis->getClassName());
} else {
skip_element(ttype, transport);
}
} else {
skip_element(ttype, transport);
}
}
}
示例3: binary_deserialize_spec
static
void binary_deserialize_spec(zval* zthis, PHPInputTransport& transport, HashTable* spec) {
// SET and LIST have 'elem' => array('type', [optional] 'class')
// MAP has 'val' => array('type', [optiona] 'class')
zend_class_entry* ce = Z_OBJCE_P(zthis);
while (true) {
int8_t ttype = transport.readI8();
if (ttype == T_STOP) {
validate_thrift_object(zthis);
return;
}
int16_t fieldno = transport.readI16();
zval* val_ptr = zend_hash_index_find(spec, fieldno);
if (val_ptr != nullptr) {
HashTable* fieldspec = Z_ARRVAL_P(val_ptr);
// pull the field name
val_ptr = zend_hash_str_find(fieldspec, "var", sizeof("var")-1);
char* varname = Z_STRVAL_P(val_ptr);
// and the type
val_ptr = zend_hash_str_find(fieldspec, "type", sizeof("type")-1);
if (Z_TYPE_P(val_ptr) != IS_LONG) convert_to_long(val_ptr);
int8_t expected_ttype = Z_LVAL_P(val_ptr);
if (ttypes_are_compatible(ttype, expected_ttype)) {
zval rv;
ZVAL_UNDEF(&rv);
binary_deserialize(ttype, transport, &rv, fieldspec);
zend_update_property(ce, zthis, varname, strlen(varname), &rv);
zval_ptr_dtor(&rv);
} else {
skip_element(ttype, transport);
}
} else {
skip_element(ttype, transport);
}
}
}
示例4: binary_deserialize_spec
void binary_deserialize_spec(zval* zthis, PHPInputTransport& transport, HashTable* spec) {
// SET and LIST have 'elem' => array('type', [optional] 'class')
// MAP has 'val' => array('type', [optiona] 'class')
TSRMLS_FETCH();
zend_class_entry* ce = zend_get_class_entry(zthis TSRMLS_CC);
while (true) {
zval** val_ptr = NULL;
int8_t ttype = transport.readI8();
if (ttype == T_STOP) return;
int16_t fieldno = transport.readI16();
if (zend_hash_index_find(spec, fieldno, (void**)&val_ptr) == SUCCESS) {
HashTable* fieldspec = Z_ARRVAL_PP(val_ptr);
// pull the field name
// zend hash tables use the null at the end in the length... so strlen(hash key) + 1.
zend_hash_find(fieldspec, "var", 4, (void**)&val_ptr);
char* varname = Z_STRVAL_PP(val_ptr);
// and the type
zend_hash_find(fieldspec, "type", 5, (void**)&val_ptr);
if (Z_TYPE_PP(val_ptr) != IS_LONG) convert_to_long(*val_ptr);
int8_t expected_ttype = Z_LVAL_PP(val_ptr);
if (ttypes_are_compatible(ttype, expected_ttype)) {
zval* rv = NULL;
MAKE_STD_ZVAL(rv);
binary_deserialize(ttype, transport, rv, fieldspec);
zend_update_property(ce, zthis, varname, strlen(varname), rv TSRMLS_CC);
zval_ptr_dtor(&rv);
} else {
skip_element(ttype, transport);
}
} else {
skip_element(ttype, transport);
}
}
}
示例5: binary_deserialize
//.........这里部分代码省略.........
} else {
return empty_string_variant();
}
}
case T_MAP: { // array of key -> value
uint8_t types[2];
transport.readBytes(types, 2);
uint32_t size = transport.readU32();
Array keyspec = fieldspec.rvalAt(PHPTransport::s_key,
AccessFlags::Error_Key).toArray();
Array valspec = fieldspec.rvalAt(PHPTransport::s_val,
AccessFlags::Error_Key).toArray();
String format = fieldspec.rvalAt(PHPTransport::s_format,
AccessFlags::None).toString();
if (format.equal(PHPTransport::s_collection)) {
ret = newobj<c_Map>();
for (uint32_t s = 0; s < size; ++s) {
Variant key = binary_deserialize(types[0], transport, keyspec);
Variant value = binary_deserialize(types[1], transport, valspec);
collectionSet(ret.getObjectData(), key.asCell(), value.asCell());
}
} else {
ret = Array::Create();
for (uint32_t s = 0; s < size; ++s) {
Variant key = binary_deserialize(types[0], transport, keyspec);
Variant value = binary_deserialize(types[1], transport, valspec);
ret.toArrRef().set(key, value);
}
}
return ret; // return_value already populated
}
case T_LIST: { // array with autogenerated numeric keys
int8_t type = transport.readI8();
uint32_t size = transport.readU32();
Variant elemvar = fieldspec.rvalAt(PHPTransport::s_elem,
AccessFlags::Error_Key);
Array elemspec = elemvar.toArray();
String format = fieldspec.rvalAt(PHPTransport::s_format,
AccessFlags::None).toString();
if (format.equal(PHPTransport::s_collection)) {
auto const pvec = newobj<c_Vector>();
ret = pvec;
for (uint32_t s = 0; s < size; ++s) {
Variant value = binary_deserialize(type, transport, elemspec);
pvec->t_add(value);
}
} else {
PackedArrayInit pai(size);
for (auto s = uint32_t{0}; s < size; ++s) {
pai.append(binary_deserialize(type, transport, elemspec));
}
ret = pai.toArray();
}
return ret;
}
case T_SET: { // array of key -> TRUE
uint8_t type;
uint32_t size;
transport.readBytes(&type, 1);
transport.readBytes(&size, 4);
size = ntohl(size);
Variant elemvar = fieldspec.rvalAt(PHPTransport::s_elem,
AccessFlags::Error_Key);
示例6: binary_deserialize
//.........这里部分代码省略.........
RETURN_DOUBLE(a.d);
}
//case T_UTF7: // aliases T_STRING
case T_UTF8:
case T_UTF16:
case T_STRING: {
uint32_t size = transport.readU32();
if (size) {
char* strbuf = (char*) emalloc(size + 1);
transport.readBytes(strbuf, size);
strbuf[size] = '\0';
ZVAL_STRINGL(return_value, strbuf, size, 0);
} else {
ZVAL_EMPTY_STRING(return_value);
}
return;
}
case T_MAP: { // array of key -> value
uint8_t types[2];
transport.readBytes(types, 2);
uint32_t size = transport.readU32();
array_init(return_value);
zend_hash_find(fieldspec, "key", 4, (void**)&val_ptr);
HashTable* keyspec = Z_ARRVAL_PP(val_ptr);
zend_hash_find(fieldspec, "val", 4, (void**)&val_ptr);
HashTable* valspec = Z_ARRVAL_PP(val_ptr);
for (uint32_t s = 0; s < size; ++s) {
zval *value;
MAKE_STD_ZVAL(value);
zval* key;
MAKE_STD_ZVAL(key);
binary_deserialize(types[0], transport, key, keyspec);
binary_deserialize(types[1], transport, value, valspec);
if (Z_TYPE_P(key) == IS_LONG) {
zend_hash_index_update(return_value->value.ht, Z_LVAL_P(key), &value, sizeof(zval *), NULL);
}
else {
if (Z_TYPE_P(key) != IS_STRING) convert_to_string(key);
zend_hash_update(return_value->value.ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &value, sizeof(zval *), NULL);
}
zval_ptr_dtor(&key);
}
return; // return_value already populated
}
case T_LIST: { // array with autogenerated numeric keys
int8_t type = transport.readI8();
uint32_t size = transport.readU32();
zend_hash_find(fieldspec, "elem", 5, (void**)&val_ptr);
HashTable* elemspec = Z_ARRVAL_PP(val_ptr);
array_init(return_value);
for (uint32_t s = 0; s < size; ++s) {
zval *value;
MAKE_STD_ZVAL(value);
binary_deserialize(type, transport, value, elemspec);
zend_hash_next_index_insert(return_value->value.ht, &value, sizeof(zval *), NULL);
}
return;
}
case T_SET: { // array of key -> TRUE
uint8_t type;
uint32_t size;
transport.readBytes(&type, 1);
transport.readBytes(&size, 4);
size = ntohl(size);
zend_hash_find(fieldspec, "elem", 5, (void**)&val_ptr);
HashTable* elemspec = Z_ARRVAL_PP(val_ptr);
array_init(return_value);
for (uint32_t s = 0; s < size; ++s) {
zval* key;
zval* value;
MAKE_STD_ZVAL(key);
MAKE_STD_ZVAL(value);
ZVAL_TRUE(value);
binary_deserialize(type, transport, key, elemspec);
if (Z_TYPE_P(key) == IS_LONG) {
zend_hash_index_update(return_value->value.ht, Z_LVAL_P(key), &value, sizeof(zval *), NULL);
}
else {
if (Z_TYPE_P(key) != IS_STRING) convert_to_string(key);
zend_hash_update(return_value->value.ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &value, sizeof(zval *), NULL);
}
zval_ptr_dtor(&key);
}
return;
}
};
char errbuf[128];
sprintf(errbuf, "Unknown thrift typeID %d", thrift_typeID);
throw_tprotocolexception(errbuf, INVALID_DATA);
}
示例7: binary_deserialize
//.........这里部分代码省略.........
RETURN_LONG((int64_t)ntohll(c));
}
case T_DOUBLE: {
union {
uint64_t c;
double d;
} a;
transport.readBytes(&(a.c), 8);
a.c = ntohll(a.c);
RETURN_DOUBLE(a.d);
}
//case T_UTF7: // aliases T_STRING
case T_UTF8:
case T_UTF16:
case T_STRING: {
uint32_t size = transport.readU32();
if (size) {
char strbuf[size+1];
transport.readBytes(strbuf, size);
strbuf[size] = '\0';
ZVAL_STRINGL(return_value, strbuf, size);
} else {
ZVAL_EMPTY_STRING(return_value);
}
return;
}
case T_MAP: { // array of key -> value
uint8_t types[2];
transport.readBytes(types, 2);
uint32_t size = transport.readU32();
array_init(return_value);
zval *val_ptr;
val_ptr = zend_hash_str_find(fieldspec, "key", sizeof("key")-1);
HashTable* keyspec = Z_ARRVAL_P(val_ptr);
val_ptr = zend_hash_str_find(fieldspec, "val", sizeof("val")-1);
HashTable* valspec = Z_ARRVAL_P(val_ptr);
for (uint32_t s = 0; s < size; ++s) {
zval key, value;
binary_deserialize(types[0], transport, &key, keyspec);
binary_deserialize(types[1], transport, &value, valspec);
if (Z_TYPE(key) == IS_LONG) {
zend_hash_index_update(Z_ARR_P(return_value), Z_LVAL(key), &value);
} else {
if (Z_TYPE(key) != IS_STRING) convert_to_string(&key);
zend_symtable_update(Z_ARR_P(return_value), Z_STR(key), &value);
}
zval_dtor(&key);
}
return; // return_value already populated
}
case T_LIST: { // array with autogenerated numeric keys
int8_t type = transport.readI8();
uint32_t size = transport.readU32();
zval *val_ptr = zend_hash_str_find(fieldspec, "elem", sizeof("elem")-1);
HashTable* elemspec = Z_ARRVAL_P(val_ptr);
array_init(return_value);
for (uint32_t s = 0; s < size; ++s) {
zval value;
binary_deserialize(type, transport, &value, elemspec);
zend_hash_next_index_insert(Z_ARR_P(return_value), &value);
}
return;
}
case T_SET: { // array of key -> TRUE
uint8_t type;
uint32_t size;
transport.readBytes(&type, 1);
transport.readBytes(&size, 4);
size = ntohl(size);
zval *val_ptr = zend_hash_str_find(fieldspec, "elem", sizeof("elem")-1);
HashTable* elemspec = Z_ARRVAL_P(val_ptr);
array_init(return_value);
for (uint32_t s = 0; s < size; ++s) {
zval key, value;
ZVAL_TRUE(&value);
binary_deserialize(type, transport, &key, elemspec);
if (Z_TYPE(key) == IS_LONG) {
zend_hash_index_update(Z_ARR_P(return_value), Z_LVAL(key), &value);
} else {
if (Z_TYPE(key) != IS_STRING) convert_to_string(&key);
zend_symtable_update(Z_ARR_P(return_value), Z_STR(key), &value);
}
zval_dtor(&key);
}
return;
}
};
char errbuf[128];
sprintf(errbuf, "Unknown thrift typeID %d", thrift_typeID);
throw_tprotocolexception(errbuf, INVALID_DATA);
}
示例8: binary_deserialize
//.........这里部分代码省略.........
}
case T_U64:
case T_I64: {
uint64_t c;
transport.readBytes(&c, 8);
return Variant((int64_t)ntohll(c));
}
case T_DOUBLE: {
union {
uint64_t c;
double d;
} a;
transport.readBytes(&(a.c), 8);
a.c = ntohll(a.c);
return a.d;
}
case T_FLOAT: {
union {
uint32_t c;
float d;
} a;
transport.readBytes(&(a.c), 4);
a.c = ntohl(a.c);
return a.d;
}
//case T_UTF7: // aliases T_STRING
case T_UTF8:
case T_UTF16:
case T_STRING: {
uint32_t size = transport.readU32();
if (size && (size + 1)) {
String s = String(size, ReserveString);
char* strbuf = s.bufferSlice().ptr;
transport.readBytes(strbuf, size);
return s.setSize(size);
} else {
return "";
}
}
case T_MAP: { // array of key -> value
uint8_t types[2];
transport.readBytes(types, 2);
uint32_t size = transport.readU32();
Array keyspec = fieldspec.rvalAt(PHPTransport::s_key,
AccessFlags::Error_Key).toArray();
Array valspec = fieldspec.rvalAt(PHPTransport::s_val,
AccessFlags::Error_Key).toArray();
ret = Array::Create();
for (uint32_t s = 0; s < size; ++s) {
Variant key = binary_deserialize(types[0], transport, keyspec);
Variant value = binary_deserialize(types[1], transport, valspec);
ret.set(key, value);
}
return ret; // return_value already populated
}
case T_LIST: { // array with autogenerated numeric keys
int8_t type = transport.readI8();
uint32_t size = transport.readU32();
Variant elemvar = fieldspec.rvalAt(PHPTransport::s_elem,
AccessFlags::Error_Key);
Array elemspec = elemvar.toArray();
ret = Array::Create();
for (uint32_t s = 0; s < size; ++s) {
Variant value = binary_deserialize(type, transport, elemspec);
ret.append(value);
}
return ret;
}
case T_SET: { // array of key -> TRUE
uint8_t type;
uint32_t size;
transport.readBytes(&type, 1);
transport.readBytes(&size, 4);
size = ntohl(size);
Variant elemvar = fieldspec.rvalAt(PHPTransport::s_elem,
AccessFlags::Error_Key);
Array elemspec = elemvar.toArray();
ret = Array::Create();
for (uint32_t s = 0; s < size; ++s) {
Variant key = binary_deserialize(type, transport, elemspec);
if (key.isInteger()) {
ret.set(key, true);
} else {
ret.set(key.toString(), true);
}
}
return ret;
}
};
char errbuf[128];
sprintf(errbuf, "Unknown thrift typeID %d", thrift_typeID);
throw_tprotocolexception(String(errbuf, CopyString), INVALID_DATA);
return uninit_null();
}