本文整理汇总了C++中CArrRef::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ CArrRef::begin方法的具体用法?C++ CArrRef::begin怎么用?C++ CArrRef::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CArrRef
的用法示例。
在下文中一共展示了CArrRef::begin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: binary_serialize_spec
void binary_serialize_spec(CObjRef zthis, PHPOutputTransport& transport,
CArrRef spec) {
for (ArrayIter key_ptr = spec.begin(); !key_ptr.end(); ++key_ptr) {
Variant key = key_ptr.first();
if (!key.isInteger()) {
throw_tprotocolexception("Bad keytype in TSPEC (expected 'long')", INVALID_DATA);
return;
}
unsigned long fieldno = key.toInt64();
Array fieldspec = key_ptr.second().toArray();
// field name
String varname = fieldspec.rvalAt(PHPTransport::s_var,
AccessFlags::Error_Key).toString();
// thrift type
int8_t ttype = fieldspec.rvalAt(PHPTransport::s_type,
AccessFlags::Error_Key).toByte();
Variant prop = zthis->o_get(varname, true, zthis->o_getClassName());
if (!prop.isNull()) {
transport.writeI8(ttype);
transport.writeI16(fieldno);
binary_serialize(ttype, transport, prop, fieldspec);
}
}
transport.writeI8(T_STOP); // struct end
}
示例2: Map
Variant ArrayUtil::Map(CArrRef inputs, PFUNC_MAP map_function,
const void *data) {
Array ret = Array::Create();
if (inputs.size() == 1) {
Array arr = inputs.begin().secondRef().toArray();
if (!arr.empty()) {
for (ssize_t k = arr->iter_begin(); k != ArrayData::invalid_index;
k = arr->iter_advance(k)) {
Array params;
params.append(arr->getValueRef(k));
Variant result;
if (map_function) {
result = map_function(params, data);
} else {
result = params;
}
ret.add(arr->getKey(k), result, true);
}
}
} else {
int maxlen = 0;
vector<vector<ssize_t> > positions;
positions.resize(inputs.size());
int i = 0;
for (ArrayIter iter(inputs); iter; ++iter, ++i) {
Array arr = iter.secondRef().toArray();
int count = arr.size();
if (count > maxlen) maxlen = count;
if (count > 0) {
positions[i].reserve(count);
for (ssize_t pos = arr->iter_begin(); pos != ArrayData::invalid_index;
pos = arr->iter_advance(pos)) {
positions[i].push_back(pos);
}
}
}
for (int k = 0; k < maxlen; k++) {
Array params;
int i = 0;
for (ArrayIter iter(inputs); iter; ++iter, ++i) {
Array arr = iter.secondRef().toArray();
if (k < arr.size()) {
params.append(arr->getValueRef(positions[i][k]));
} else {
params.append(uninit_null());
}
}
Variant result;
if (map_function) {
result = map_function(params, data);
} else {
result = params;
}
ret.append(result);
}
}
return ret;
}