LiteSQL 0.3.10
operations.hpp
Go to the documentation of this file.
1/* LiteSQL
2 *
3 * The list of contributors at http://litesql.sf.net/
4 *
5 * See LICENSE for copyright information. */
6
7#ifndef __litesql_operations_hpp
8#define __litesql_operations_hpp
12namespace litesql {
13using namespace std;
15template <class T>
20
22template <class T>
24 const litesql::DataSource<T>& ds2) {
25 std::string sel = ds1.idQuery().asString() + " INTERSECT "
26 + ds2.idQuery().asString();
27 return litesql::DataSource<T>(ds1.getDatabase(), T::Id.in(sel));
28}
29
30template <class T>
32 const litesql::DataSource<T>& ds2) {
33 std::string sel = ds1.idQuery().asString() + " UNION "
34 + ds2.idQuery().asString();
35 return litesql::DataSource<T>(ds1.getDatabase(), T::Id.in(sel));
36}
37
39template <class T>
41 const litesql::DataSource<T>& ds2) {
42 std::string sel = ds1.idQuery().asString() + " EXCEPT "
43 + ds2.idQuery().asString();
44 return litesql::DataSource<T>(ds1.getDatabase(), T::Id.in(sel));
45}
46
47}
48#endif
template class which holds SelectQuery for selecting objects of type T
Definition datasource.hpp:34
const Database & getDatabase() const
returns database reference
Definition datasource.hpp:53
SelectQuery idQuery() const
returns SelectQuery which selects ID-numbers of objects
Definition datasource.hpp:57
A base class of databases.
Definition database.hpp:37
A base class for expression in WHERE - clause.
Definition expr.hpp:19
selectObjectQuery<T> and DataSource<T>
litesql::DataSource< T > except(const litesql::DataSource< T > &ds1, const litesql::DataSource< T > &ds2)
returns DataSource for accessing objects of type T that are in first DataSource but not in second.
Definition operations.hpp:40
litesql::DataSource< T > intersect(const litesql::DataSource< T > &ds1, const litesql::DataSource< T > &ds2)
returns DataSource for accessing intersection of two sets of objects of type T
Definition operations.hpp:23
litesql::DataSource< T > union_(const litesql::DataSource< T > &ds1, const litesql::DataSource< T > &ds2)
returns DataSource for accessing union of two sets of objects of type T
Definition operations.hpp:31
litesql::DataSource< T > select(const litesql::Database &db, const litesql::Expr &e=litesql::Expr())
returns DataSource for accessing objects of type T
Definition operations.hpp:16

SourceForge.net Logo