LiteSQL
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
9 #include "litesql/datasource.hpp"
12 namespace litesql {
13 using namespace std;
15 template <class T>
17  const litesql::Expr &e=litesql::Expr()) {
18  return litesql::DataSource<T>(db, e);
19 }
22 template <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 }
30 template <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 }
39 template <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:35
SelectQuery idQuery() const
returns SelectQuery which selects ID-numbers of objects
Definition: datasource.hpp:58
const Database & getDatabase() const
returns database reference
Definition: datasource.hpp:54
A base class of databases.
Definition: database.hpp:33
A base class for expression in WHERE - clause.
Definition: expr.hpp:18
selectObjectQuery<T> and DataSource<T>
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
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 > 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

SourceForge.net Logo