diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 10:29:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 10:29:59 +0000 |
commit | fead91cfb1835d16049c615e1f1c87caa606ff06 (patch) | |
tree | 0d7fbbff7ff88b0873a99ead502d6ebb12beb6d6 /views.hh | |
parent | Adding debian version 1.9.5-1. (diff) | |
download | dnsdist-fead91cfb1835d16049c615e1f1c87caa606ff06.tar.xz dnsdist-fead91cfb1835d16049c615e1f1c87caa606ff06.zip |
Merging upstream version 1.9.6.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'views.hh')
-rw-r--r-- | views.hh | 24 |
1 files changed, 21 insertions, 3 deletions
@@ -33,21 +33,39 @@ public: view(data_, size_) { } - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast): No unsigned char view in C++17 + // NOLINTBEGIN(cppcoreguidelines-pro-type-reinterpret-cast): No unsigned char view in C++17 UnsignedCharView(const unsigned char* data_, size_t size_) : view(reinterpret_cast<const char*>(data_), size_) { } - const unsigned char& at(std::string_view::size_type pos) const + using size_type = std::string_view::size_type; + + [[nodiscard]] const unsigned char& at(size_type pos) const { return reinterpret_cast<const unsigned char&>(view.at(pos)); } - size_t size() const + [[nodiscard]] const unsigned char& operator[](size_type pos) const + { + return reinterpret_cast<const unsigned char&>(view[pos]); + } + + [[nodiscard]] const unsigned char* data() const + { + return reinterpret_cast<const unsigned char*>(view.data()); + } + // NOLINTEND(cppcoreguidelines-pro-type-reinterpret-cast): No unsigned char view in C++17 + + [[nodiscard]] size_t size() const { return view.size(); } + [[nodiscard]] size_t length() const + { + return view.length(); + } + private: std::string_view view; }; |