当前位置: 首页>>代码示例>>C++>>正文


C++ ISerializer::type方法代码示例

本文整理汇总了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");
    }
  }
}
开发者ID:dinastyoffreedom,项目名称:dinastycoin,代码行数:35,代码来源:CryptoNoteSerialization.cpp

示例2: serialize

bool WalletUnconfirmedTransactions::serialize(ISerializer& s) {
  s(m_unconfirmedTxs, "transactions");
  if (s.type() == ISerializer::INPUT) {
    collectUsedOutputs();
  }
  return true;
}
开发者ID:bitumencoin,项目名称:valentinecoinwallet,代码行数:7,代码来源:WalletUnconfirmedTransactions.cpp

示例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);
   }
 }
开发者ID:niekjex,项目名称:BankCoin,代码行数:7,代码来源:BlockIndex.cpp

示例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;
}
开发者ID:HBNCoins,项目名称:cryptonote,代码行数:9,代码来源:PeerListManager.cpp

示例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);
  }
}
开发者ID:conordb,项目名称:bytecoin,代码行数:16,代码来源:SerializationOverloads.cpp


注:本文中的ISerializer::type方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。