This file is indexed.

/usr/include/Wt/Dbo/WtSqlTraits is in libwtdbo-dev 3.3.6+dfsg-1.1.

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
// This may look like C code, but it's really -*- C++ -*-
/*
 * Copyright (C) 2009 Emweb bvba, Kessel-Lo, Belgium.
 *
 * See the LICENSE file for terms of use.
 */
#ifndef WT_DBO_WT_TYPE_TRAITS_H_
#define WT_DBO_WT_TYPE_TRAITS_H_

#include <string>

#include <Wt/WDate>
#include <Wt/WDateTime>
#include <Wt/WTime>
#include <Wt/WString>

#include <Wt/Dbo/SqlTraits>
#include <Wt/Dbo/SqlStatement>

#include <boost/lexical_cast.hpp>

namespace Wt {
  namespace Dbo {

template<>
struct sql_value_traits<WDate, void>
{
  static const bool specialized = true;

  static const char *format;

  static const char *type(SqlConnection *conn, int size);
  static void bind(const WDate& v, SqlStatement *statement, int column, int size);
  static bool read(WDate& v, SqlStatement *statement, int column, int size);
};

template<>
struct sql_value_traits<WDateTime, void>
{
  static const bool specialized = true;

  static const char *type(SqlConnection *conn, int size);
  static void bind(const WDateTime& v, SqlStatement *statement, int column,
		   int size);
  static bool read(WDateTime& v, SqlStatement *statement, int column, int size);
};

template<>
struct sql_value_traits<WTime, void>
{
  static const bool specialized = true;

  static const char *format;

  static const char *type(SqlConnection *conn, int size);
  static void bind(const WTime& v, SqlStatement *statement, int column,
		   int size);
  static bool read(WTime& v, SqlStatement *statement, int column, int size);
};

template<>
struct sql_value_traits<WString, void>
{
  static const bool specialized = true;

  static std::string type(SqlConnection *conn, int size);
  static void bind(const WString& v, SqlStatement *statement, int column,
		   int size);
  static bool read(WString& v, SqlStatement *statement, int column, int size);
};

    /*
     * WDate
     */

inline const char *sql_value_traits<WDate, void>::type(SqlConnection *conn,
						       int size)
{
  return conn->dateTimeType(SqlDate);
}

inline void sql_value_traits<WDate, void>
::bind(const WDate& v, SqlStatement *statement, int column, int size)
{
  if (v.isNull())
    statement->bindNull(column);
  else
    statement->bind(column, Wt::WDateTime(v).toPosixTime(), SqlDate);
}

inline bool sql_value_traits<WDate, void>
::read(WDate& v, SqlStatement *statement, int column, int size)
{
  boost::posix_time::ptime t;

  if (statement->getResult(column, &t, SqlDate)) {
    boost::gregorian::date d = t.date();
    v.setDate(d.year(), d.month(), d.day());
    return true;
  } else {
    v = WDate();
    return false;
  }
}

    /*
     * WTime
     */

inline const char *sql_value_traits<WTime, void>::type(SqlConnection *conn,
						       int size)
{
  return conn->dateTimeType(SqlTime);
}

inline void sql_value_traits<WTime, void>
::bind(const WTime& v, SqlStatement *statement, int column, int size)
{
  if (v.isNull())
    statement->bindNull(column);
  else {
    boost::posix_time::time_duration::fractional_seconds_type ticks_per_msec =
      boost::posix_time::time_duration::ticks_per_second() / 1000;

    statement->bind
      (column,
       boost::posix_time::time_duration(v.hour(), v.minute(), v.second(),
					v.msec() * ticks_per_msec));
  }
}

inline bool sql_value_traits<WTime, void>
::read(WTime& v, SqlStatement *statement, int column, int size)
{
  boost::posix_time::time_duration t;
 
  if (statement->getResult(column, &t)) {
    int h = t.hours();
    int m = t.minutes();
    int s = t.seconds();
    int ms = static_cast<int>(t.total_milliseconds() % 1000);

    if (!v.setHMS (h, m, s, ms)) {
      std::cerr << "Wt::Dbo: WTime can only hold durations < 24h"
		<< std::endl;
      return true;
    } else
      return false;

  } else {
    v = WTime();
    return false;
  }
}

    /*
     * WDateTime
     */

inline const char *sql_value_traits<WDateTime, void>::type(SqlConnection *conn,
							   int size)
{
  return conn->dateTimeType(SqlDateTime);
}

inline void sql_value_traits<WDateTime, void>
::bind(const WDateTime& v, SqlStatement *statement, int column, int size)
{
  if (v.isNull())
    statement->bindNull(column);
  else
    statement->bind(column, v.toPosixTime(), SqlDateTime);
}

inline bool sql_value_traits<WDateTime, void>
::read(WDateTime& v, SqlStatement *statement, int column, int size)
{
  boost::posix_time::ptime t;

  if (statement->getResult(column, &t, SqlDateTime)) {
    v = WDateTime::fromPosixTime(t);
    return true;
  } else {
    v = WDateTime();
    return false;
  }
}

    /*
     * WString
     */

inline std::string sql_value_traits<WString, void>::type(SqlConnection *conn,
							 int size)
{
    return conn->textType(size) + " not null";
}

inline void sql_value_traits<WString, void>
::bind(const WString& v, SqlStatement *statement, int column, int size)
{
  statement->bind(column, v.toUTF8());
}

inline bool sql_value_traits<WString, void>
::read(WString& v, SqlStatement *statement, int column, int size)
{
  std::string d;
  if (statement->getResult(column, &d, size)) {
    v = WString::fromUTF8(d);
    return true;
  } else {
    v = WString::Empty;
    return false;
  }
}

  }
}

#endif // WT_DBO_WT_TYPE_TRAITS_H_