本文整理汇总了C++中ISerializer::type方法的典型用法代码示例。如果您正苦于以下问题:C++ ISerializer::type方法的具体用法?C++ ISerializer::type怎么用?C++ ISerializer::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISerializer
的用法示例。
在下文中一共展示了ISerializer::type方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: serialize
// unpack to strings to maintain protocol compatibility with older versions
void serialize(RawBlock& rawBlock, ISerializer& serializer) {
if (serializer.type() == ISerializer::INPUT) {
uint64_t blockSize;
serializer(blockSize, "block_size");
rawBlock.block.resize(static_cast<size_t>(blockSize));
} else {
auto blockSize = rawBlock.block.size();
serializer(blockSize, "block_size");
}
serializer.binary(rawBlock.block.data(), rawBlock.block.size(), "block");
if (serializer.type() == ISerializer::INPUT) {
uint64_t txCount;
serializer(txCount, "tx_count");
rawBlock.transactions.resize(static_cast<size_t>(txCount));
for (auto& txBlob : rawBlock.transactions) {
uint64_t txSize;
serializer(txSize, "tx_size");
txBlob.resize(txSize);
serializer.binary(txBlob.data(), txBlob.size(), "transaction");
}
} else {
auto txCount = rawBlock.transactions.size();
serializer(txCount, "tx_count");
for (auto& txBlob : rawBlock.transactions) {
auto txSize = txBlob.size();
serializer(txSize, "tx_size");
serializer.binary(txBlob.data(), txBlob.size(), "transaction");
}
}
}
示例2: serialize
bool WalletUnconfirmedTransactions::serialize(ISerializer& s) {
s(m_unconfirmedTxs, "transactions");
if (s.type() == ISerializer::INPUT) {
collectUsedOutputs();
}
return true;
}
示例3: serialize
void BlockIndex::serialize(ISerializer& s) {
if (s.type() == ISerializer::INPUT) {
readSequence<Crypto::Hash>(std::back_inserter(m_container), "index", s);
} else {
writeSequence<Crypto::Hash>(m_container.begin(), m_container.end(), "index", s);
}
}
示例4: serialize
bool serialize(boost::multi_index_container<T, Indexes>& value, Common::StringView name, ISerializer& s) {
if (s.type() == ISerializer::INPUT) {
readSequence<T>(std::inserter(value, value.end()), name, s);
} else {
writeSequence<T>(value.begin(), value.end(), name, s);
}
return true;
}
示例5: serializeBlockHeight
void serializeBlockHeight(ISerializer& s, uint32_t& blockHeight, Common::StringView name) {
if (s.type() == ISerializer::INPUT) {
uint64_t height;
s(height, name);
if (height == std::numeric_limits<uint64_t>::max()) {
blockHeight = std::numeric_limits<uint32_t>::max();
} else if (height > std::numeric_limits<uint32_t>::max() && height < std::numeric_limits<uint64_t>::max()) {
throw std::runtime_error("Deserialization error: wrong value");
} else {
blockHeight = static_cast<uint32_t>(height);
}
} else {
s(blockHeight, name);
}
}