Common ODB Runtime Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
query.hxx
Go to the documentation of this file.
1 // file : odb/query.hxx
2 // copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
3 // license : GNU GPL v2; see accompanying LICENSE file
4 
5 #ifndef ODB_QUERY_HXX
6 #define ODB_QUERY_HXX
7 
8 #include <odb/pre.hxx>
9 
10 #include <odb/forward.hxx>
11 #include <odb/traits.hxx>
12 
13 namespace odb
14 {
15  // Table alias for type T and tag Tag.
16  //
17  // The alias_traits interface consists of two things: the table_name
18  // static variable containing the name and, in case of a derived type
19  // in a polymorphic hierarchy, the base_traits typedef. Note that the
20  // same interface is exposed by object_traits, which is used when
21  // we need straight tables instead of aliases.
22  //
23  //
24  template <typename T, database_id DB, typename Tag>
25  struct alias_traits;
26 
27  template <typename T, database_id DB>
29 
30  template <typename T, database_id DB, typename A>
31  struct query_columns;
32 
33  template <typename T, database_id DB, typename A>
35 
36  // Object pointer syntax wrapper.
37  //
38  template <typename T>
40  {
42  {
43  // For some reason GCC needs this dummy c-tor if we make a static
44  // data member of this type const.
45  }
46 
47  T*
48  operator-> () const
49  {
50  return 0; // All members in T are static.
51  }
52  };
53 
54  // Query parameter decay traits.
55  //
56  template <typename T>
57  struct decay_traits
58  {
59  typedef const T& type;
60 
61  static type
62  instance ();
63  };
64 
65  template <typename T, std::size_t N>
66  struct decay_traits<T[N]>
67  {
68  typedef const T* type;
69 
70  // Use the pointer comparability as a proxy for data comparability.
71  // Note that it is stricter than using element comparability (i.e.,
72  // one can compare int to char but not int* to char*).
73  //
74  static type
75  instance ();
76  };
77 
78  // VC9 cannot handle certain cases of non-type arguments with default
79  // values in template functions (e.g., database::query()). As a result,
80  // we have to use the impl trick below instead of simply having kind
81  // as a second template argument with a default value.
82  //
83  template <typename T, database_id DB, class_kind kind>
85 
86  template <typename T, database_id DB>
88  {
90 
91  typedef
94  };
95 
96  template <typename T, database_id DB>
98  {
101  };
102 
103  template <typename T, database_id DB>
104  struct query_selector: query_selector_impl<T, DB, class_traits<T>::kind>
105  {
106  };
107 
108  template <typename T,
109  typename B = typename query_selector<T, id_common>::base_type>
110  class query;
111 
112  namespace core
113  {
114  using odb::query;
115  }
116 }
117 
118 #include <odb/post.hxx>
119 
120 #endif // ODB_QUERY_HXX
Definition: query.hxx:31
Definition: query.hxx:84
const T & type
Definition: query.hxx:59
Definition: query.hxx:28
Definition: traits.hxx:80
T * operator->() const
Definition: query.hxx:48
query_pointer()
Definition: query.hxx:41
Definition: query.hxx:110
Definition: query.hxx:25
static type instance()
Definition: forward.hxx:132
Definition: forward.hxx:126
view_traits_impl< T, DB >::query_columns columns_type
Definition: query.hxx:100
Definition: traits.hxx:79
object_traits_impl< T, DB >::query_base_type base_type
Definition: query.hxx:89
Definition: query.hxx:57
Definition: query.hxx:34
Definition: query.hxx:104
const T * type
Definition: query.hxx:68
query_columns< T, DB, access::object_traits_impl< T, DB > > columns_type
Definition: query.hxx:93
view_traits_impl< T, DB >::query_base_type base_type
Definition: query.hxx:99
Definition: query.hxx:39