Table of Contents
join()Family of Functions
I use the noun “query”, in normal font, for objects of various C++ types:
This chapter describes features that all queries have in common, and here are some to get started:
>, and consequently:
operator->(), which returns a const pointer to the value mapper, and an
operator*(), which returns a const reference to the value mapper (so the conventional relationship between
Creating a query always begins with creating a table. That part is not explained until the next chapter, so examples in this chapter tend to start with a puff of smoke, along the lines of:
extern table<point> points;
Once we have that, we can get our hands on the common query features, i.e.
the methods declared in the
interface, and any free functions that accept an
as an argument. That gives us
join() etc.: all the tools for building more
complex queries. It also gives us the means for executing them.
As far as possible, we should write code that treats all the flavors of
query alike. If we're writing a function and we want it to take a query
argument by reference, let's declare the argument as
If we're creating a variable so we can put queries into it, let's declare
the variable as
junctions etc. will all
be implicitly converted on the way in, and they'll all look the same on
the way out.
One more thing that all queries have in common: they know which database
they belong to. That is because (as we shall see), tables have that information
from the moment they are constructed, and it is passed down the line every
time one query is used to build another. If a query is built from more
than one other query (e.g. by
join()), then all the constituent queries must
belong to the same database as one other (this is checked at run time).