bool pbf::get_bool() {
    pbf_assert(tag() != 0 && "call next() before accessing field value");
    pbf_assert(has_wire_type(pbf_wire_type::varint) && "not a varint");
    pbf_assert((*m_data & 0x80) == 0 && "not a 1 byte varint");
    skip_bytes(1);
    return m_data[-1] != 0; // -1 okay because we incremented m_data the line before
}
std::pair<const char*, pbf_length_type> pbf::get_data() {
    pbf_assert(tag() != 0 && "call next() before accessing field value");
    pbf_assert(has_wire_type(pbf_wire_type::length_delimited) && "not of type string, bytes or message");
    auto len = get_len_and_skip();
    return std::make_pair(m_data-len, len);
}
double pbf::get_double() {
    pbf_assert(tag() != 0 && "call next() before accessing field value");
    pbf_assert(has_wire_type(pbf_wire_type::fixed64) && "not a 64-bit fixed");
    return get_fixed<double>();
}
float pbf::get_float() {
    pbf_assert(tag() != 0 && "call next() before accessing field value");
    pbf_assert(has_wire_type(pbf_wire_type::fixed32) && "not a 32-bit fixed");
    return get_fixed<float>();
}
T pbf::get_svarint() {
    pbf_assert((has_wire_type(pbf_wire_type::varint) || has_wire_type(pbf_wire_type::length_delimited)) && "not a varint");
    return static_cast<T>(decode_zigzag64(decode_varint(&m_data, m_end)));
}
Exemple #6
0
int64_t pbf_reader::get_sfixed64() {
    protozero_assert(tag() != 0 && "call next() before accessing field value");
    protozero_assert(has_wire_type(pbf_wire_type::fixed64) && "not a 64-bit fixed");
    return get_fixed<int64_t>();
}
Exemple #7
0
uint32_t pbf_reader::get_fixed32() {
    protozero_assert(tag() != 0 && "call next() before accessing field value");
    protozero_assert(has_wire_type(pbf_wire_type::fixed32) && "not a 32-bit fixed");
    return get_fixed<uint32_t>();
}