/usr/include/Wt/Dbo/SqlConnection 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 | // 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_CONNECTION_H_
#define WT_DBO_SQL_CONNECTION_H_
#include <map>
#include <string>
#include <Wt/Dbo/WDboDllDefs.h>
namespace Wt {
namespace Dbo {
/*! \brief Enum that defines a date time type.
*/
enum SqlDateTimeType {
SqlDate, //!< Date only
SqlDateTime,//!< Date and time
SqlTime //!< Time duration
};
class SqlStatement;
/*! \class SqlConnection Wt/Dbo/SqlConnection Wt/Dbo/SqlConnection
* \brief Abstract base class for an SQL connection.
*
* An sql connection manages a single connection to a database. It
* also manages a map of previously prepared statements indexed by
* id's.
*
* This class is part of Wt::Dbo's backend API, and should not be used
* directly.
*
* \ingroup dbo
*/
class WTDBO_API SqlConnection
{
public:
/*! \brief Destructor.
*/
virtual ~SqlConnection();
/*! \brief Clones the connection.
*
* Returns a new connection object that is configured like this
* object. This is used by connection pool implementations to create
* its connections.
*/
virtual SqlConnection *clone() const = 0;
/*! \brief Executes an SQL statement.
*
* This is a convenience method for preparing a statement, executing
* it, and deleting it.
*/
virtual void executeSql(const std::string& sql);
/*! \brief Starts a transaction
*
* This function starts a transaction.
*/
virtual void startTransaction() = 0;
/*! \brief Commits a transaction
*
* This function commits a transaction.
*/
virtual void commitTransaction() = 0;
/*! \brief Rolls back a transaction
*
* This function rolls back a transaction.
*/
virtual void rollbackTransaction() = 0;
/*! \brief Returns the statement with the given id.
*
* Returns 0 if no such statement was already added.
*
* \sa saveStatement()
*/
virtual SqlStatement *getStatement(const std::string& id) const;
/*! \brief Saves a statement with the given id.
*
* Saves the statement for future reuse using getStatement()
*/
virtual void saveStatement(const std::string& id,
SqlStatement *statement);
/*! \brief Prepares a statement.
*
* Returns the prepared statement.
*/
virtual SqlStatement *prepareStatement(const std::string& sql) = 0;
/*! \brief Sets a property.
*
* Properties may tailor the backend behavior. Some properties are
* applicable to all backends, while some are backend specific.
*
* General properties are:
* - <tt>show-queries</tt>: when value is "true", queries are shown
* as they are executed.
*/
void setProperty(const std::string& name, const std::string& value);
/*! \brief Returns a property.
*
* Returns the property value, or an empty string if the property was
* not set.
*
* \sa setProperty()
*/
std::string property(const std::string& name) const;
/** @name Methods that return dialect information
*/
//@{
/*! \brief Returns the 'autoincrement' SQL type modifier.
*
* This is used by Session::createTables() to create the <i>id</i>
* column.
*/
virtual std::string autoincrementSql() const = 0;
/*! \brief Returns the 'autoincrement' SQL type.
*
* This is used by Session::createTables() to create the <i>id</i>
* column.
*/
virtual std::string autoincrementType() const = 0;
/*! \brief Returns the suffix for an 'autoincrement' insert statement.
*
* This is appended to the <tt>insert</tt> statement, since some back-ends
* need to be indicated that they should return the autoincrement id.
*/
virtual std::string autoincrementInsertSuffix() const = 0;
/*! \brief Returns the date/time type.
*
* \sa SqlStatement::bind(int, const boost::posix_time::ptime&, SqlDateTimeType)
*/
virtual const char *dateTimeType(SqlDateTimeType type) const = 0;
/*! \brief Returns the blob type.
*
* \sa SqlStatement::bind(int, const std::vector<unsigned char>&)
*/
virtual const char *blobType() const = 0;
//@}
bool showQueries() const;
protected:
SqlConnection();
SqlConnection(const SqlConnection& other);
void clearStatementCache();
private:
typedef std::map<std::string, SqlStatement *> StatementMap;
StatementMap statementCache_;
std::map<std::string, std::string> properties_;
};
}
}
#endif // WT_DBO_SQL_STATEMENT_H_
|