pbf_message.hpp
Go to the documentation of this file.
#ifndef PROTOZERO_PBF_MESSAGE_HPP
#define PROTOZERO_PBF_MESSAGE_HPP
/*****************************************************************************
protozero - Minimalistic protocol buffer decoder and encoder in C++.
This file is from https://github.com/mapbox/protozero where you can find more
documentation.
*****************************************************************************/
#include <protozero/pbf_reader.hpp>
#include <protozero/types.hpp>
#include <type_traits>
namespace protozero {
template <typename T>
class pbf_message : public pbf_reader {
static_assert(std::is_same<pbf_tag_type, typename std::underlying_type<T>::type>::value,
"T must be enum with underlying type protozero::pbf_tag_type");
public:
using enum_type = T;
template <typename... Args>
pbf_message(Args&&... args) noexcept : // NOLINT(google-explicit-constructor, hicpp-explicit-conversions)
pbf_reader{std::forward<Args>(args)...} {
}
bool next() {
return pbf_reader::next();
}
bool next(T next_tag) {
return pbf_reader::next(pbf_tag_type(next_tag));
}
bool next(T next_tag, pbf_wire_type type) {
return pbf_reader::next(pbf_tag_type(next_tag), type);
}
T tag() const noexcept {
return T(pbf_reader::tag());
}
}; // class pbf_message
} // end namespace protozero
#endif // PROTOZERO_PBF_MESSAGE_HPP
protozero::pbf_message::next
bool next(T next_tag)
Definition: pbf_message.hpp:131
types.hpp
Contains the declaration of low-level types used in the pbf format.
protozero::pbf_message::next
bool next()
Definition: pbf_message.hpp:99
protozero::pbf_message::pbf_message
pbf_message(Args &&... args) noexcept
Definition: pbf_message.hpp:80
protozero::pbf_wire_type
pbf_wire_type
Definition: types.hpp:40
protozero::pbf_message::enum_type
T enum_type
The type of messages this class will read.
Definition: pbf_message.hpp:73
protozero::pbf_message::next
bool next(T next_tag, pbf_wire_type type)
Definition: pbf_message.hpp:163
protozero::pbf_message
Definition: pbf_message.hpp:65
pbf_reader.hpp
Contains the pbf_reader class.
protozero::pbf_tag_type
uint32_t pbf_tag_type
Definition: types.hpp:33
protozero::pbf_reader::tag
pbf_tag_type tag() const noexcept
Definition: pbf_reader.hpp:397
protozero::pbf_message::tag
T tag() const noexcept
Definition: pbf_message.hpp:176
protozero::pbf_reader
Definition: pbf_reader.hpp:62
protozero::pbf_reader::next
bool next()
Definition: pbf_reader.hpp:284
protozero
All parts of the protozero header-only library are in this namespace.
Definition: byteswap.hpp:23