boat
C++23 geospatial library
Loading...
Searching...
No Matches
boat::db Namespace Reference

Classes

struct  kind< T >
struct  catalog
 Uniform access to vector and raster data. More...
struct  command
struct  source
struct  layer
struct  column
struct  index_key
struct  table
struct  bbox
 Spatial filter for row selection. More...
struct  order_key
struct  page
 Pagination filter for row selection. More...
struct  band
struct  raster
struct  rect
struct  id
class  query
struct  rowset
struct  variant
struct  kind
 Maps a C++ type to the database-neutral type name used by boat. More...
struct  kind< std::string >
struct  kind< blob >

Typedefs

using null = std::monostate
using variant_base = std::variant<null, int64_t, double, std::string, blob>

Functions

void read (variant const &in, geometry::ogc99 auto &out)
 Reads WKB from a blob; NULL produces a default-constructed geometry.
void write (variant &out, geometry::ogc99 auto const &in)
 Serializes an OGC geometry as WKB in a blob.
template<class T>
requires requires { read(in, out.emplace()); }
void read (variant const &in, std::optional< T > &out)
 NULL becomes std::nullopt.
template<class T>
requires requires { write(out, *in); }
void write (variant &out, std::optional< T > const &in)
 std::nullopt becomes NULL.
template<class Clock, class Duration>
void read (variant const &in, std::chrono::time_point< Clock, Duration > &out)
template<class Clock, class Duration>
void write (variant &out, std::chrono::time_point< Clock, Duration > in)
 Formats a time point with microsecond precision and no time-zone suffix.
auto & operator<< (ostream auto &out, rowset const &in)
auto & operator<< (ostream auto &out, table const &in)
auto & operator<< (ostream auto &out, raster const &in)
template<class T>
constexpr auto kinds_as_array ()
 Creates a std::array from kind<Field>::value for each field of T.
template<class T>
table to_table ()
rowset to_rowset (std::ranges::input_range auto &&r)
 Converts a range of structures to a rowset.
template<std::convertible_to< variant_base > T>
void read (variant const &in, T &out)
void write (variant &out, std::convertible_to< variant_base > auto const &in)
template<class T>
requires requires(T val) { read(var, val); }
T get (variant const &var)
variant to_variant (auto const &val)

Variables

template<class T>
constexpr auto view
 Converts a rowset row to a structure.

Typedef Documentation

◆ null

using boat::db::null = std::monostate

◆ variant_base

using boat::db::variant_base = std::variant<null, int64_t, double, std::string, blob>

Function Documentation

◆ get()

template<class T>
requires requires(T val) { read(var, val); }
T boat::db::get ( variant const & var)

◆ kinds_as_array()

template<class T>
auto boat::db::kinds_as_array ( )
constexpr

Creates a std::array from kind<Field>::value for each field of T.

◆ operator<<() [1/3]

auto & boat::db::operator<< ( ostream auto & out,
raster const & in )

◆ operator<<() [2/3]

auto & boat::db::operator<< ( ostream auto & out,
rowset const & in )

◆ operator<<() [3/3]

auto & boat::db::operator<< ( ostream auto & out,
table const & in )

◆ read() [1/4]

void boat::db::read ( variant const & in,
geometry::ogc99 auto & out )

Reads WKB from a blob; NULL produces a default-constructed geometry.

◆ read() [2/4]

template<class Clock, class Duration>
void boat::db::read ( variant const & in,
std::chrono::time_point< Clock, Duration > & out )

Parses "YYYY-MM-DD HH:MM:SS[.ffffff]" without a time-zone conversion. NULL is converted to the clock epoch; excess fractional digits are ignored.

◆ read() [3/4]

template<class T>
requires requires { read(in, out.emplace()); }
void boat::db::read ( variant const & in,
std::optional< T > & out )

NULL becomes std::nullopt.

◆ read() [4/4]

template<std::convertible_to< variant_base > T>
void boat::db::read ( variant const & in,
T & out )

NULL becomes T{}.

Exceptions
std::bad_variant_accessif the stored type is incompatible with T.

◆ to_rowset()

rowset boat::db::to_rowset ( std::ranges::input_range auto && r)

Converts a range of structures to a rowset.

◆ to_table()

template<class T>
table boat::db::to_table ( )

◆ to_variant()

variant boat::db::to_variant ( auto const & val)

◆ write() [1/4]

void boat::db::write ( variant & out,
geometry::ogc99 auto const & in )

Serializes an OGC geometry as WKB in a blob.

◆ write() [2/4]

template<class Clock, class Duration>
void boat::db::write ( variant & out,
std::chrono::time_point< Clock, Duration > in )

Formats a time point with microsecond precision and no time-zone suffix.

◆ write() [3/4]

void boat::db::write ( variant & out,
std::convertible_to< variant_base > auto const & in )

◆ write() [4/4]

template<class T>
requires requires { write(out, *in); }
void boat::db::write ( variant & out,
std::optional< T > const & in )

std::nullopt becomes NULL.

Variable Documentation

◆ view

template<class T>
auto boat::db::view
constexpr
Initial value:
= std::views::transform([](range_of<variant> auto&& r) {
T ret;
auto it = std::ranges::begin(r);
if constexpr (requires { read(*it, ret); })
read(*it++, ret);
else
boost::pfr::for_each_field(ret, [&](auto& v) { read(*it++, v); });
check(it == std::ranges::end(r), "out of fields");
return ret;
})
void read(variant const &in, geometry::ogc99 auto &out)
Reads WKB from a blob; NULL produces a default-constructed geometry.
Definition geometry.hpp:12

Converts a rowset row to a structure.