string_view_offset.hpp 933 B

1234567891011121314151617181920212223242526272829303132333435
  1. //
  2. // Copyright (c) 2019-2024 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. #ifndef BOOST_MYSQL_DETAIL_STRING_VIEW_OFFSET_HPP
  8. #define BOOST_MYSQL_DETAIL_STRING_VIEW_OFFSET_HPP
  9. #include <cstddef>
  10. namespace boost {
  11. namespace mysql {
  12. namespace detail {
  13. // Represents a string_view using offsets into a buffer.
  14. // Useful during deserialization, for buffers that may reallocate.
  15. struct string_view_offset
  16. {
  17. std::size_t offset;
  18. std::size_t size;
  19. constexpr bool operator==(string_view_offset rhs) const noexcept
  20. {
  21. return offset == rhs.offset && size == rhs.size;
  22. }
  23. constexpr bool operator!=(string_view_offset rhs) const noexcept { return !(*this == rhs); }
  24. };
  25. } // namespace detail
  26. } // namespace mysql
  27. } // namespace boost
  28. #endif