1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- #ifndef BOOST_MYSQL_DETAIL_ROW_IMPL_HPP
- #define BOOST_MYSQL_DETAIL_ROW_IMPL_HPP
- #include <boost/mysql/field_view.hpp>
- #include <boost/mysql/detail/config.hpp>
- #include <boost/core/span.hpp>
- #include <cstddef>
- #include <vector>
- namespace boost {
- namespace mysql {
- namespace detail {
- inline span<field_view> add_fields(std::vector<field_view>& storage, std::size_t num_fields)
- {
- std::size_t old_size = storage.size();
- storage.resize(old_size + num_fields);
- return span<field_view>(storage.data() + old_size, num_fields);
- }
- class row_impl
- {
- public:
- row_impl() = default;
- BOOST_MYSQL_DECL
- row_impl(const row_impl&);
- row_impl(row_impl&&) = default;
- BOOST_MYSQL_DECL
- row_impl& operator=(const row_impl&);
- row_impl& operator=(row_impl&&) = default;
- ~row_impl() = default;
-
- BOOST_MYSQL_DECL
- row_impl(const field_view* fields, std::size_t size);
-
- BOOST_MYSQL_DECL
- void assign(const field_view* fields, std::size_t size);
-
- span<field_view> add_fields(std::size_t num_fields)
- {
- return ::boost::mysql::detail::add_fields(fields_, num_fields);
- }
-
- BOOST_MYSQL_DECL
- void copy_strings_as_offsets(std::size_t first, std::size_t num_fields);
-
- BOOST_MYSQL_DECL
- void offsets_to_string_views();
- const std::vector<field_view>& fields() const noexcept { return fields_; }
- void clear() noexcept
- {
- fields_.clear();
- string_buffer_.clear();
- }
- private:
- std::vector<field_view> fields_;
- std::vector<unsigned char> string_buffer_;
- };
- }
- }
- }
- #ifdef BOOST_MYSQL_HEADER_ONLY
- #include <boost/mysql/impl/row_impl.ipp>
- #endif
- #endif
|