1 #ifndef PROTOZERO_TYPES_HPP 2 #define PROTOZERO_TYPES_HPP 57 return (static_cast<uint32_t>(static_cast<pbf_tag_type>(tag)) << 3) |
static_cast<uint32_t
>(wire_type);
65 #ifdef PROTOZERO_USE_VIEW 96 constexpr
data_view(
const char* ptr, std::size_t length) noexcept
107 : m_data(str.data()),
118 m_size(std::strlen(ptr)) {
128 swap(m_data, other.m_data);
129 swap(m_size, other.m_size);
133 constexpr
const char*
data() const noexcept {
138 constexpr std::size_t
size() const noexcept {
143 constexpr
bool empty() const noexcept {
153 protozero_assert(m_data);
154 return std::string{m_data, m_size};
162 explicit operator std::string()
const {
163 protozero_assert(m_data);
164 return std::string{m_data, m_size};
187 return lhs.size() == rhs.size() && std::equal(lhs.data(), lhs.data() + lhs.size(), rhs.data());
198 return !(lhs == rhs);
206 #endif // PROTOZERO_TYPES_HPP constexpr bool empty() const noexcept
Returns true if size is 0.
Definition: types.hpp:143
data_view(const std::string &str) noexcept
Definition: types.hpp:106
constexpr uint32_t tag_and_type(T tag, pbf_wire_type wire_type) noexcept
Definition: types.hpp:56
std::string to_string() const
Definition: types.hpp:152
Contains macro checks for different configurations.
void swap(iterator_range< T > &lhs, iterator_range< T > &rhs) noexcept
Definition: iterators.hpp:137
constexpr std::size_t size() const noexcept
Return length of data in bytes.
Definition: types.hpp:138
pbf_wire_type
Definition: types.hpp:40
data_view(const char *ptr) noexcept
Definition: types.hpp:116
constexpr data_view() noexcept
Definition: types.hpp:85
void swap(data_view &other) noexcept
Definition: types.hpp:126
uint32_t pbf_length_type
Definition: types.hpp:63
uint32_t pbf_tag_type
Definition: types.hpp:33
bool operator==(const data_view &lhs, const data_view &rhs) noexcept
Definition: types.hpp:186
bool operator!=(const data_view &lhs, const data_view &rhs) noexcept
Definition: types.hpp:197
constexpr const char * data() const noexcept
Return pointer to data.
Definition: types.hpp:133
constexpr data_view(const char *ptr, std::size_t length) noexcept
Definition: types.hpp:96
All parts of the protozero header-only library are in this namespace.
Definition: byteswap.hpp:24
void swap(data_view &lhs, data_view &rhs) noexcept
Definition: types.hpp:175