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


C++ data_slice::begin方法代码示例

本文整理汇总了C++中data_slice::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ data_slice::begin方法的具体用法?C++ data_slice::begin怎么用?C++ data_slice::begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在data_slice的用法示例。


在下文中一共展示了data_slice::begin方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

inline data_chunk operator +(data_slice a, data_slice b)
{
    data_chunk out;
    out.reserve(a.size() + b.size());
    out.insert(out.end(), a.begin(), a.end());
    out.insert(out.end(), b.begin(), b.end());
    return out;
}
开发者ID:Airbitz,项目名称:libbitcoin,代码行数:8,代码来源:ec_keys.cpp

示例2: verify_checksum

bool verify_checksum(data_slice data)
{
    if (data.size() < checksum_size)
        return false;

    data_slice body(data.begin(), data.end() - checksum_size);
    auto checksum = from_little_endian_unsafe<uint32_t>(data.end() - checksum_size);
    return bitcoin_checksum(body) == checksum;
}
开发者ID:bankonca,项目名称:libbitcoin,代码行数:9,代码来源:checksum.cpp

示例3: while

binary_type::binary_type(size_type size, data_slice blocks)
{
    // Copy blocks
    blocks_.resize(blocks.size());
    std::copy(blocks.begin(), blocks.end(), blocks_.begin());
    // Pad with 00 for safety.
    while (blocks_.size() * bits_per_block < size)
        blocks_.push_back(0x00);
    resize(size);
}
开发者ID:veox,项目名称:libbitcoin,代码行数:10,代码来源:binary.cpp

示例4: unwrap

bool unwrap(uint8_t& version, data_chunk& payload, uint32_t& checksum,
    data_slice wrapped)
{
    constexpr size_t version_length = sizeof(version);
    constexpr size_t checksum_length = sizeof(checksum);
    // guard against insufficient buffer length
    if (wrapped.size() < version_length + checksum_length)
        return false;
    if (!verify_checksum(wrapped))
        return false;
    // set return values
    version = wrapped.data()[0];
    payload = data_chunk(wrapped.begin() + version_length,
        wrapped.end() - checksum_length);
    const auto checksum_start = wrapped.end() - checksum_length;
    auto deserial = make_deserializer(checksum_start, wrapped.end());
    checksum = deserial.read_4_bytes();
    return true;
}
开发者ID:Groestlcoin,项目名称:libgroestlcoin,代码行数:19,代码来源:address.cpp

示例5: indexes

std::string encode_base58(data_slice unencoded)
{
    size_t leading_zeros = count_leading_zeros(unencoded);

    // size = log(256) / log(58), rounded up.
    const size_t number_nonzero = unencoded.size() - leading_zeros;
    const size_t indexes_size = number_nonzero * 138 / 100 + 1;

    // Allocate enough space in big-endian base58 representation.
    data_chunk indexes(indexes_size);

    // Process the bytes.
    for (auto it = unencoded.begin() + leading_zeros;
        it != unencoded.end(); ++it)
    {
        pack_value(indexes, *it);
    }

    // Skip leading zeroes in base58 result.
    auto first_nonzero = search_first_nonzero(indexes);

    // Translate the result into a string.
    std::string encoded;
    const size_t estimated_size = leading_zeros + 
        (indexes.end() - first_nonzero);
    encoded.reserve(estimated_size);
    encoded.assign(leading_zeros, '1');

    // Set actual main bytes.
    for (auto it = first_nonzero; it != indexes.end(); ++it)
    {
        const size_t index = *it;
        encoded += base58_chars[index];
    }

    return encoded;
}
开发者ID:GeopaymeEE,项目名称:libbitcoin,代码行数:37,代码来源:base58.cpp

示例6: to_string

/**
 * Shoves data into a std::string object.
 */
std::string to_string(data_slice data)
{
    return std::string(data.begin(), data.end());
}
开发者ID:libmetrocoin,项目名称:libmetrocoin-client,代码行数:7,代码来源:obelisk_codec.cpp


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