/usr/include/Wt/Dbo/ptr_tuple is in libwtdbo-dev 3.1.10-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | // This may look like C code, but it's really -*- C++ -*-
/*
* Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
*
* See the LICENSE file for terms of use.
*/
#ifndef WT_DBO_TUPLE_PTR_H_
#define WT_DBO_TUPLE_PTR_H_
#include <boost/tuple/tuple.hpp>
#include <Wt/Dbo/Query>
namespace Wt {
namespace Dbo {
template <>
struct persist<boost::tuples::null_type, void>
{
template <class A>
static void apply(boost::tuples::null_type& obj, A& action)
{ }
};
namespace Impl {
template <class T>
struct ptr_type
{
typedef ptr<T> type;
};
template <>
struct ptr_type< boost::tuples::null_type >
{
typedef boost::tuples::null_type type;
};
template <int N, class T>
struct helper
{
typedef typename boost::tuples::element<N, T>::type ElementType;
static void getFields(Session& session,
std::vector<std::string> *aliases,
std::vector<FieldInfo>& result)
{
helper<N-1, T>::getFields(session, aliases, result);
query_result_traits<ElementType>::getFields(session, aliases, result);
}
static void load(Session& session, SqlStatement& statement,
int& column, T& result)
{
helper<N-1, T>::load(session, statement, column, result);
boost::get<N>(result)
= query_result_traits<ElementType>::load(session, statement, column);
}
static void getValues(const T& result, std::vector<boost::any>& values)
{
helper<N-1, T>::getValues(result, values);
query_result_traits<ElementType>::getValues(boost::get<N>(result),
values);
}
static void setValue(T& result, int& index, const boost::any& value)
{
if (index >= 0) {
helper<N-1, T>::setValue(result, index, value);
if (index >= 0) {
query_result_traits<ElementType>::setValue(boost::get<N>(result),
index, value);
}
}
}
static void create(T& result)
{
helper<N-1, T>::create(result);
boost::get<N>(result) = query_result_traits<ElementType>::create();
}
static void add(Session& session, T& result)
{
helper<N-1, T>::add(session, result);
query_result_traits<ElementType>::add(session, boost::get<N>(result));
}
static void remove(T& result)
{
helper<N-1, T>::remove(result);
query_result_traits<ElementType>::remove(boost::get<N>(result));
}
};
template <class T>
struct helper<-1, T>
{
static void getFields(Session& session,
std::vector<std::string> *aliases,
std::vector<FieldInfo>& result)
{ }
static void load(Session& session, SqlStatement& statement,
int& column, T& result)
{ }
static void getValues(const T& result, std::vector<boost::any>& values)
{ }
static void setValue(T& result, int& index, const boost::any& value)
{ }
static void create(T& result)
{ }
static void add(Session& session, T& result)
{ }
static void remove(T& result)
{ }
};
}
/*! \brief A utility class for defining a tuple of database objects.
*
* Since C++ (at least prior to C++0x) does not support template
* typedefs, this class provides a nested \p type that is a typedef
* for a Boost.Tuple containing one or more Wt::Dbo::ptr.
*
* Thus:
* \code
* namespace dbo = Wt::Dbo;
* typedef dbo::ptr_tuple<A, B, C>::type ABC;
* \endcode
* Is equivalent to:
* \code
* namespace dbo = Wt::Dbo;
* typedef boost::tuple<dbo::ptr<A>, dbo::ptr<B>, dbo::ptr<C> > ABC;
* \endcode
*
* \note Boost.Tuple (in its general form) is supported as a result for a
* Session::query() by a partial template specialization of
* query_result_traits.
*
* \ingroup dbo
*/
#ifdef DOXYGEN_ONLY
template <class T0 = boost::tuples::null_type,
class T1 = boost::tuples::null_type,
...,
class T9 = boost::tuples::null_type>
#else
template <class T0 = boost::tuples::null_type,
class T1 = boost::tuples::null_type,
class T2 = boost::tuples::null_type,
class T3 = boost::tuples::null_type,
class T4 = boost::tuples::null_type,
class T5 = boost::tuples::null_type,
class T6 = boost::tuples::null_type,
class T7 = boost::tuples::null_type,
class T8 = boost::tuples::null_type,
class T9 = boost::tuples::null_type>
#endif
struct ptr_tuple
{
/*! \brief A typedef for a Boost.Tuple for ptrs.
*/
#ifdef DOXYGEN_ONLY
typedef boost::tuple< ptr<T0>, ptr<T1>, ..., ptr<T9> > type;
#else
typedef boost::tuple< typename Impl::ptr_type<T0>::type,
typename Impl::ptr_type<T1>::type,
typename Impl::ptr_type<T2>::type,
typename Impl::ptr_type<T3>::type,
typename Impl::ptr_type<T4>::type,
typename Impl::ptr_type<T5>::type,
typename Impl::ptr_type<T6>::type,
typename Impl::ptr_type<T7>::type,
typename Impl::ptr_type<T8>::type,
typename Impl::ptr_type<T9>::type > type;
#endif // DOXYGEN_ONLY
};
template <class T0, class T1, class T2, class T3, class T4,
class T5, class T6, class T7, class T8, class T9>
struct query_result_traits< boost::tuple<T0, T1, T2, T3, T4,
T5, T6, T7, T8, T9> >
{
typedef boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> tuple_type;
typedef Impl::helper<boost::tuples::length<tuple_type>::value - 1, tuple_type>
helper;
static void getFields(Session& session,
std::vector<std::string> *aliases,
std::vector<FieldInfo>& result);
static tuple_type load(Session& session, SqlStatement& statement,
int& column);
static void getValues(const tuple_type& t, std::vector<boost::any>& values);
static void setValue(tuple_type& t, int& index, const boost::any& value);
static tuple_type create();
static void add(Session& session, tuple_type& t);
static void remove(tuple_type& t);
};
template <class T0, class T1, class T2, class T3, class T4,
class T5, class T6, class T7, class T8, class T9>
void query_result_traits< boost::tuple<T0, T1, T2, T3, T4,
T5, T6, T7, T8, T9> >
::getFields(Session& session,
std::vector<std::string> *aliases,
std::vector<FieldInfo>& result)
{
helper::getFields(session, aliases, result);
}
template <class T0, class T1, class T2, class T3, class T4,
class T5, class T6, class T7, class T8, class T9>
boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>
query_result_traits< boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> >
::load(Session& session, SqlStatement& statement, int& column)
{
tuple_type result;
helper::load(session, statement, column, result);
return result;
}
template <class T0, class T1, class T2, class T3, class T4,
class T5, class T6, class T7, class T8, class T9>
void
query_result_traits< boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> >
::getValues(const tuple_type& t, std::vector<boost::any>& values)
{
helper::getValues(t, values);
}
template <class T0, class T1, class T2, class T3, class T4,
class T5, class T6, class T7, class T8, class T9>
void
query_result_traits< boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> >
::setValue(tuple_type& t, int& index, const boost::any& value)
{
helper::setValue(t, index, value);
}
template <class T0, class T1, class T2, class T3, class T4,
class T5, class T6, class T7, class T8, class T9>
boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>
query_result_traits< boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> >
::create()
{
tuple_type result;
helper::create(result);
return result;
}
template <class T0, class T1, class T2, class T3, class T4,
class T5, class T6, class T7, class T8, class T9>
void
query_result_traits< boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> >
::add(Session& session, tuple_type& t)
{
helper::add(session, t);
}
template <class T0, class T1, class T2, class T3, class T4,
class T5, class T6, class T7, class T8, class T9>
void
query_result_traits< boost::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> >
::remove(tuple_type& t)
{
helper::remove(t);
}
}
}
#endif // WT_DBO_DBO_PTR_H_
|