protozero  1.6.3
Minimalistic protocol buffer decoder and encoder in C++.
pbf_message.hpp
Go to the documentation of this file.
1 #ifndef PROTOZERO_PBF_MESSAGE_HPP
2 #define PROTOZERO_PBF_MESSAGE_HPP
3 
4 /*****************************************************************************
5 
6 protozero - Minimalistic protocol buffer decoder and encoder in C++.
7 
8 This file is from https://github.com/mapbox/protozero where you can find more
9 documentation.
10 
11 *****************************************************************************/
12 
19 #include <protozero/pbf_reader.hpp>
20 #include <protozero/types.hpp>
21 
22 #include <type_traits>
23 
24 namespace protozero {
25 
64 template <typename T>
65 class pbf_message : public pbf_reader {
66 
67  static_assert(std::is_same<pbf_tag_type, typename std::underlying_type<T>::type>::value,
68  "T must be enum with underlying type protozero::pbf_tag_type");
69 
70 public:
71 
73  using enum_type = T;
74 
79  template <typename... Args>
80  pbf_message(Args&&... args) noexcept : // NOLINT(google-explicit-constructor, hicpp-explicit-conversions)
81  pbf_reader(std::forward<Args>(args)...) {
82  }
83 
99  bool next() {
100  return pbf_reader::next();
101  }
102 
131  bool next(T next_tag) {
132  return pbf_reader::next(pbf_tag_type(next_tag));
133  }
134 
163  bool next(T next_tag, pbf_wire_type type) {
164  return pbf_reader::next(pbf_tag_type(next_tag), type);
165  }
166 
176  T tag() const noexcept {
177  return T(pbf_reader::tag());
178  }
179 
180 }; // class pbf_message
181 
182 } // end namespace protozero
183 
184 #endif // PROTOZERO_PBF_MESSAGE_HPP
bool next(T next_tag)
Definition: pbf_message.hpp:131
Contains the declaration of low-level types used in the pbf format.
bool next()
Definition: pbf_message.hpp:99
pbf_reader() noexcept=default
pbf_message(Args &&... args) noexcept
Definition: pbf_message.hpp:80
pbf_wire_type
Definition: types.hpp:40
T enum_type
The type of messages this class will read.
Definition: pbf_message.hpp:73
bool next(T next_tag, pbf_wire_type type)
Definition: pbf_message.hpp:163
Definition: pbf_message.hpp:65
Contains the pbf_reader class.
uint32_t pbf_tag_type
Definition: types.hpp:33
pbf_tag_type tag() const noexcept
Definition: pbf_reader.hpp:391
T tag() const noexcept
Definition: pbf_message.hpp:176
Definition: pbf_reader.hpp:62
bool next()
Definition: pbf_reader.hpp:278
All parts of the protozero header-only library are in this namespace.
Definition: byteswap.hpp:23