本文整理汇总了C++中VPackBuilder::steal方法的典型用法代码示例。如果您正苦于以下问题:C++ VPackBuilder::steal方法的具体用法?C++ VPackBuilder::steal怎么用?C++ VPackBuilder::steal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VPackBuilder
的用法示例。
在下文中一共展示了VPackBuilder::steal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operator
void operator()(VPackSlice const& v, std::vector<VPackSlice>& resEdges,
std::vector<VPackSlice>& neighbors) {
int res = TRI_ERROR_NO_ERROR;
for (auto const& edgeCollection : _block->_collectionInfos) {
VPackBuilder result;
TRI_ASSERT(edgeCollection != nullptr);
if (_isReverse) {
res = edgeCollection->getReverseEdgesCoordinator(v, result);
} else {
res = edgeCollection->getEdgesCoordinator(v, result);
}
if (res != TRI_ERROR_NO_ERROR) {
THROW_ARANGO_EXCEPTION(res);
}
VPackSlice edges = result.slice().get("edges");
for (auto const& edge : VPackArrayIterator(edges)) {
VPackSlice from = arangodb::Transaction::extractFromFromDocument(edge);
if (from == v) {
VPackSlice to = arangodb::Transaction::extractToFromDocument(edge);
if (to != v) {
resEdges.emplace_back(edge);
neighbors.emplace_back(to);
}
} else {
resEdges.emplace_back(edge);
neighbors.emplace_back(from);
}
}
// Make sure the data Slices are pointing to is not running out of scope.
// This is not thread-safe!
_block->_coordinatorCache.emplace_back(result.steal());
}
}
示例2: prepareForNetwork
VPackMessageNoOwnBuffer VppResponse::prepareForNetwork() {
// initalize builder with vpackbuffer. then we do not need to
// steal the header and can avoid the shared pointer
VPackBuilder builder;
builder.openArray();
builder.add(VPackValue(int(1)));
builder.add(VPackValue(int(2))); // 2 == response
builder.add(
VPackValue(static_cast<int>(meta::underlyingValue(_responseCode))));
builder.close();
_header = builder.steal();
if (_vpackPayloads.empty()) {
if (_generateBody) {
LOG_TOPIC(INFO, Logger::REQUESTS)
<< "Response should generate body but no Data available";
_generateBody = false; // no body availalbe
}
return VPackMessageNoOwnBuffer(VPackSlice(_header->data()),
VPackSlice::noneSlice(), _messageId,
_generateBody);
} else {
std::vector<VPackSlice> slices;
for (auto const& buffer : _vpackPayloads) {
slices.emplace_back(buffer.data());
}
return VPackMessageNoOwnBuffer(VPackSlice(_header->data()),
std::move(slices), _messageId,
_generateBody);
}
}