libpqxx
7.9.0
|
A C++ equivalent to PostgreSQL's range types. More...
#include <range.hxx>
Public Member Functions | |
constexpr | range (range_bound< TYPE > lower, range_bound< TYPE > upper) |
Create a range. More... | |
constexpr | range () noexcept(noexcept(exclusive_bound< TYPE >{TYPE{}})) |
Create an empty range. More... | |
constexpr bool | operator== (range const &rhs) const noexcept(noexcept(this->lower_bound()==rhs.lower_bound()) and noexcept(this->upper_bound()==rhs.upper_bound()) and noexcept(this->empty())) |
constexpr bool | operator!= (range const &rhs) const noexcept(noexcept(*this==rhs)) |
range (range const &)=default | |
range (range &&)=default | |
range & | operator= (range const &)=default |
range & | operator= (range &&)=default |
constexpr bool | empty () const noexcept(noexcept(m_lower.is_exclusive()) and noexcept(m_lower.is_limited()) and noexcept(*m_lower.value()< *m_upper.value())) |
Is this range clearly empty? More... | |
constexpr bool | contains (TYPE value) const noexcept(noexcept(m_lower.extends_down_to(value)) and noexcept(m_upper.extends_up_to(value))) |
Does this range encompass value ? More... | |
constexpr bool | contains (range< TYPE > const &other) const noexcept(noexcept((*this &other)==other)) |
Does this range encompass all of other ? More... | |
constexpr range_bound< TYPE > const & | lower_bound () const &noexcept |
constexpr range_bound< TYPE > const & | upper_bound () const &noexcept |
constexpr range | operator& (range const &other) const |
Intersection of two ranges. More... | |
template<typename DEST > | |
operator range< DEST > () const | |
Convert to another base type. More... | |
A C++ equivalent to PostgreSQL's range types.
You can use this as a client-side representation of a "range" in SQL.
PostgreSQL defines several range types, differing in the data type over which they range. You can also define your own range types.
Usually you'll want the server to deal with ranges. But on occasions where you need to work with them client-side, you may want to use pqxx::range. (In cases where all you do is pass them along to the server though, it's not worth the complexity. In that case you might as well treat ranges as just strings.)
For documentation on PostgreSQL's range types, see: https://www.postgresql.org/docs/current/rangetypes.html
The value type must be copyable and default-constructible, and support the less-than (<
) and equals (==
) comparisons. Value initialisation must produce a consistent value.
|
constexpr |
Create a range.
For each of the two bounds, pass a no_bound, inclusive_bound, or exclusive_bound.
References pqxx::range_bound< TYPE >::is_limited(), and pqxx::range_bound< TYPE >::value().
|
constexprnoexcept |
Create an empty range.
SQL has a separate literal to denote an empty range, but any range which encompasses no values is an empty range.
|
default |
|
default |
|
constexprnoexcept |
Does this range encompass all of other
?
This function is not particularly smart. It does not know, for example, that integer ranges [0,9]
and [0,10)
contain the same values.
|
constexprnoexcept |
Does this range encompass value
?
|
constexprnoexcept |
Is this range clearly empty?
An empty range encompasses no values.
It is possible to "fool" this. For example, if your range is of an integer type and has exclusive bounds of 0 and 1, it encompasses no values but its empty()
will return false. The PostgreSQL implementation, by contrast, will notice that it is empty. Similar things can happen for floating-point types, but with more subtleties and edge cases.
Referenced by pqxx::string_traits< range< TYPE > >::into_buf().
|
constexprnoexcept |
Referenced by pqxx::string_traits< range< TYPE > >::into_buf(), and pqxx::range< TYPE >::operator&().
pqxx::range< TYPE >::operator range< DEST > | ( | ) | const |
Convert to another base type.
|
constexprnoexcept |
|
constexpr |
Intersection of two ranges.
Returns a range describing those values which are in both ranges.
References pqxx::range< TYPE >::lower_bound(), and pqxx::range< TYPE >::upper_bound().
|
default |
|
default |
|
constexprnoexcept |
|
constexprnoexcept |
Referenced by pqxx::string_traits< range< TYPE > >::into_buf(), and pqxx::range< TYPE >::operator&().