/usr/include/Wt/Dbo/SqlStatement 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 | // 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_SQL_STATEMENT_H_
#define WT_DBO_SQL_STATEMENT_H_
#include <string>
#include <vector>
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <Wt/Dbo/SqlConnection>
namespace Wt {
namespace Dbo {
/*! \brief Abstract base class for a prepared SQL statement.
*
* The statement may be used multiple times, but cannot be used
* concurrently. It also cannot be copied.
*
* This class is part of Wt::Dbo's backend API, and should not be used
* directly. Its interface must be reimplemented for each backend
* corresponding to a supported database.
*
* \sa SqlConnection
*
* \ingroup dbo
*/
class WTDBO_API SqlStatement
{
public:
/*! \brief Destructor.
*/
virtual ~SqlStatement();
/*! \brief Uses the statement.
*
* Marks the statement as in-use. If the statement is already in
* use, return false. In that case, we will later provision that a
* statement can be cloned and that a list of equivalent statement
* is kept in the statement cache of a connectin.
*/
bool use();
/*! \brief Finish statement use.
*
* Marks the statement as no longer used and resets the statement.
*
* \sa use()
*/
void done();
/*! \brief Resets the statement.
*/
virtual void reset() = 0;
/*! \brief Binds a value to a column.
*/
virtual void bind(int column, const std::string& value) = 0;
/*! \brief Binds a value to a column.
*/
virtual void bind(int column, short value) = 0;
/*! \brief Binds a value to a column.
*/
virtual void bind(int column, int value) = 0;
/*! \brief Binds a value to a column.
*/
virtual void bind(int column, long long value) = 0;
/*! \brief Binds a value to a column.
*/
virtual void bind(int column, float value) = 0;
/*! \brief Binds a value to a column.
*/
virtual void bind(int column, double value) = 0;
/*! \brief Binds a value to a column.
*/
virtual void bind(int column, const boost::posix_time::ptime& value,
SqlDateTimeType type) = 0;
/*! \brief Binds a value to a column.
*/
virtual void bind(int column, const boost::posix_time::time_duration& value)
= 0;
/*! \brief Binds a value to a column.
*/
virtual void bind(int column, const std::vector<unsigned char>& value) = 0;
/*! \brief Binds \c null to a column.
*/
virtual void bindNull(int column) = 0;
/*! \brief Executes the statement.
*/
virtual void execute() = 0;
/*! \brief Returns the id if the statement was an SQL <tt>insert</tt>.
*/
virtual long long insertedId() = 0;
/*! \brief Returns the affected number of rows.
*
* This is only useful for an SQL <tt>update</tt> or <tt>delete</tt>
* statement.
*/
virtual int affectedRowCount() = 0;
/*! \brief Fetches the next result row.
*
* Returns \c true if there was one more row to be fetched.
*/
virtual bool nextRow() = 0;
/*! \brief Fetches a result value.
*
* Returns \c true when the value was not \c null.
* The size is the expected size of sql string type and can be used to
* dimension buffers but the return string may be bigger.
*/
virtual bool getResult(int column, std::string *value, int size) = 0;
/*! \brief Fetches a result value.
*
* Returns \c true when the value was not \c null.
*/
virtual bool getResult(int column, short *value) = 0;
/*! \brief Fetches a result value.
*
* Returns \c true when the value was not \c null.
*/
virtual bool getResult(int column, int *value) = 0;
/*! \brief Fetches a result value.
*
* Returns \c true when the value was not \c null.
*/
virtual bool getResult(int column, long long *value) = 0;
/*! \brief Fetches a result value.
*
* Returns \c true when the value was not \c null.
*/
virtual bool getResult(int column, float *value) = 0;
/*! \brief Fetches a result value.
*
* Returns \c true when the value was not \c null.
*/
virtual bool getResult(int column, double *value) = 0;
/*! \brief Fetches a result value.
*
* Returns \c true when the value was not \c null.
*/
virtual bool getResult(int column, boost::posix_time::ptime *value,
SqlDateTimeType type) = 0;
/*! \brief Fetches a result value.
*
* Returns \c true when the value was not \c null.
*/
virtual bool getResult(int column, boost::posix_time::time_duration *value)
= 0;
/*! \brief Fetches a result value.
*
* Returns \c true when the value was not \c null.
*/
virtual bool getResult(int column, std::vector<unsigned char> *value,
int size) = 0;
/*! \brief Returns the prepared SQL string.
*/
virtual std::string sql() const = 0;
protected:
SqlStatement();
private:
SqlStatement(const SqlStatement&); // non-copyable
bool inuse_;
};
class WTDBO_API ScopedStatementUse
{
public:
ScopedStatementUse(SqlStatement *statement = 0);
void operator()(SqlStatement *statement);
~ScopedStatementUse();
private:
SqlStatement *s_;
};
}
}
#endif // WT_DBO_SQL_STATEMENT_H_
|