All the functions in the join()
family, other than jump()
, support mapped classes as an output
format, as an alternative to std::tuple
s.
Just like the collector classes
for select()
,
they don't affect the generated SQL, but they might afford some extra
convenience, if you like to use meaningful member names instead of get<0>()
etc.
If:
J
is a call to a function in the join()
family that would have returned a query with value type std::tuple<
j0
,
j1
,
...>
,
and
C
is a mapped class, with mapped members
m0
, m1
, ....
(in the order they were listed to QUINCE_MAP_CLASS
),
and with no mapped bases,
then you can add C
as a template parameter
to the call J
, provided that:
J
are satisfied
C
::
mi
equals
the length of std::tuple<
j0
,
j1
,
...>
(i.e. the number of queries being joined), and
C
::
mi
is of the same type as the corresponding ji
.
Then the returned query has the following characteristics:
C
.
class_mapper<
C
>
, in which each member
mi
is identical to the i
'th
member of J
's value mapper.
J
's, except
that what would have gone into member i
of an output std::tuple
now goes into member mi
of an output
C
.
// Somewhere in a namespace, not in a function struct movie_deployment { boost::optional<screen> s; movie m; }; QUINCE_MAP_CLASS(movie_deployment, (s)(m)); // Somewhere inside a function: const query<movie_deployment> movie_deployments = screens.right_join<movie_deployment>(movies, screens->current_movie_id == movies->id);