24#ifndef MYSQL_RANGES_VIEW_SOURCES_H
25#define MYSQL_RANGES_VIEW_SOURCES_H
65template <
class Source_t,
bool owns_source_t = std::ranges::view<Source_t>>
67 std::conditional_t<owns_source_t, Source_t, const Source_t &>;
100template <
class Source_tp,
bool owns_source_tp = std::ranges::view<Source_tp>>
113 std::conditional_t<owns_source, Source_t, const Source_t *>;
199template <
class Source_tp,
bool owns_source_tp = std::ranges::view<Source_tp>>
213 std::conditional_t<owns_source, std::optional<Source_t>,
273 [[nodiscard]]
auto end()
const {
280 return mysql::iterators::null_iterator<Source_t>();
300template <
class Source_t>
307template <
class Source_t>
314template <
class Source_t>
std::optional-like wrapper around an object that is the source for a view: this may hold an object or...
Definition: view_sources.h:200
Source_tp Source_t
Definition: view_sources.h:202
Optional_source_t m_source
The source.
Definition: view_sources.h:296
std::conditional_t< owns_source, std::optional< Source_t >, const Source_t * > Optional_source_t
Internal representation of the source.
Definition: view_sources.h:214
const Raw_source_t & get() const
Return a copy of the stored object if it is owned; otherwise a reference to it.
Definition: view_sources.h:233
auto begin() const
Return a valid begin iterator, even if !has_object().
Definition: view_sources.h:262
static constexpr bool owns_source
True if this object owns a copy of its source; false if it holds a reference to its source.
Definition: view_sources.h:206
Optional_view_source(const Source_t &source)
Construct from a const reference to the source.
Definition: view_sources.h:220
Raw_view_source< Source_t, owns_source > Raw_source_t
Source_t if owns_source, otherwise Source_t &.
Definition: view_sources.h:209
static decltype(auto) from_ptr(const Source_t *object)
Return an Optional_source_t from the given pointer, holding no object if the pointer is nullptr,...
Definition: view_sources.h:286
const Source_t * pointer() const
Return a pointer to the source if there is one, or nullptr otherwise.
Definition: view_sources.h:242
static auto null_iterator()
Definition: view_sources.h:279
auto end() const
Return a valid end iterator, even if !has_object().
Definition: view_sources.h:273
const Source_t * operator->() const
Arrow operator to access members of the source.
Definition: view_sources.h:253
const Raw_source_t & reference() const
Return a reference to the stored object.
Definition: view_sources.h:238
Optional_view_source(const Source_t *source)
Construct from a const pointer to the source.
Definition: view_sources.h:225
bool has_object() const
Return true if this object holds a source.
Definition: view_sources.h:229
Optional_view_source()=default
Construct an objec that does not hold a source.
Wrapper around an object that is the source for a view: the wrapped object is owned by this object if...
Definition: view_sources.h:101
Raw_view_source< Source_t, owns_source > Raw_source_t
Source_t if owns_source, otherwise Source_t &.
Definition: view_sources.h:109
Source_ref_t m_source
The source.
Definition: view_sources.h:172
auto begin() const
Return begin iterator to the source.
Definition: view_sources.h:151
auto end() const
Return end iterator to the source.
Definition: view_sources.h:158
const Source_t & reference() const
Return a reference to the stored object.
Definition: view_sources.h:130
static decltype(auto) from_ref(const Source_t &object)
Return an Source_ref_t from the given pointer, holding no object if the pointer is nullptr,...
Definition: view_sources.h:163
std::conditional_t< owns_source, Source_t, const Source_t * > Source_ref_t
Internal representation of the source.
Definition: view_sources.h:113
static constexpr bool owns_source
True if this object owns a copy of its source; false if it holds a reference to its source.
Definition: view_sources.h:106
View_source(const Source_t &source)
Construct from a const reference to the source.
Definition: view_sources.h:121
Source_tp Source_t
Definition: view_sources.h:103
View_source()=default
Default-construct an object.
const Raw_source_t & get() const
Return a copy of the stored object if it is owned; otherwise a reference to it.
Definition: view_sources.h:125
const Source_t * operator->() const
Arrow operator to access members of the source.
Definition: view_sources.h:144
Definition: buffer_interface.h:40
auto make_optional_view_source(const Source_t &source)
Factory function to create an Optional_view_source wrapping the given object.
Definition: view_sources.h:308
auto make_view_source(const Source_t &source)
Factory function to create a View_source wrapping the given object.
Definition: view_sources.h:301
std::conditional_t< owns_source_t, Source_t, const Source_t & > Raw_view_source
Type alias to represent the source of a view: resolves to Type if std::ranges::view<Type>,...
Definition: view_sources.h:67
Define std::hash<Gtid>.
Definition: gtid.h:355
repeated Source source
Definition: replication_asynchronous_connection_failover.proto:42