/usr/include/soci/soci-backend.h is in libsoci-dev 3.2.3-2ubuntu2.
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 | //
// Copyright (C) 2004-2008 Maciej Sobczak, Stephen Hutton
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef SOCI_BACKEND_H_INCLUDED
#define SOCI_BACKEND_H_INCLUDED
#include "soci-config.h"
#include "error.h"
// std
#include <cstddef>
#include <map>
#include <string>
namespace soci
{
// data types, as seen by the user
enum data_type
{
dt_string, dt_date, dt_double, dt_integer, dt_long_long, dt_unsigned_long_long
};
// the enum type for indicator variables
enum indicator { i_ok, i_null, i_truncated };
class session;
namespace details
{
// data types, as used to describe exchange format
enum exchange_type
{
x_char,
x_stdstring,
x_short,
x_integer,
x_long_long,
x_unsigned_long_long,
x_double,
x_stdtm,
x_statement,
x_rowid,
x_blob
};
// type of statement (used for optimizing statement preparation)
enum statement_type
{
st_one_time_query,
st_repeatable_query
};
// polymorphic into type backend
class standard_into_type_backend
{
public:
standard_into_type_backend() {}
virtual ~standard_into_type_backend() {}
virtual void define_by_pos(int& position, void* data, exchange_type type) = 0;
virtual void pre_fetch() = 0;
virtual void post_fetch(bool gotData, bool calledFromFetch, indicator* ind) = 0;
virtual void clean_up() = 0;
private:
// noncopyable
standard_into_type_backend(standard_into_type_backend const&);
standard_into_type_backend& operator=(standard_into_type_backend const&);
};
class vector_into_type_backend
{
public:
vector_into_type_backend() {}
virtual ~vector_into_type_backend() {}
virtual void define_by_pos(int& position, void* data, exchange_type type) = 0;
virtual void pre_fetch() = 0;
virtual void post_fetch(bool gotData, indicator* ind) = 0;
virtual void resize(std::size_t sz) = 0;
virtual std::size_t size() = 0;
virtual void clean_up() = 0;
private:
// noncopyable
vector_into_type_backend(vector_into_type_backend const&);
vector_into_type_backend& operator=(vector_into_type_backend const&);
};
// polymorphic use type backend
class standard_use_type_backend
{
public:
standard_use_type_backend() {}
virtual ~standard_use_type_backend() {}
virtual void bind_by_pos(int& position, void* data,
exchange_type type, bool readOnly) = 0;
virtual void bind_by_name(std::string const& name,
void* data, exchange_type type, bool readOnly) = 0;
virtual void pre_use(indicator const* ind) = 0;
virtual void post_use(bool gotData, indicator * ind) = 0;
virtual void clean_up() = 0;
private:
// noncopyable
standard_use_type_backend(standard_use_type_backend const&);
standard_use_type_backend& operator=(standard_use_type_backend const&);
};
class vector_use_type_backend
{
public:
vector_use_type_backend() {}
virtual ~vector_use_type_backend() {}
virtual void bind_by_pos(int& position, void* data, exchange_type type) = 0;
virtual void bind_by_name(std::string const& name,
void* data, exchange_type type) = 0;
virtual void pre_use(indicator const* ind) = 0;
virtual std::size_t size() = 0;
virtual void clean_up() = 0;
private:
// noncopyable
vector_use_type_backend(vector_use_type_backend const&);
vector_use_type_backend& operator=(vector_use_type_backend const&);
};
// polymorphic statement backend
class statement_backend
{
public:
statement_backend() {}
virtual ~statement_backend() {}
virtual void alloc() = 0;
virtual void clean_up() = 0;
virtual void prepare(std::string const& query, statement_type eType) = 0;
enum exec_fetch_result
{
ef_success,
ef_no_data
};
virtual exec_fetch_result execute(int number) = 0;
virtual exec_fetch_result fetch(int number) = 0;
virtual long long get_affected_rows() = 0;
virtual int get_number_of_rows() = 0;
virtual std::string rewrite_for_procedure_call(std::string const& query) = 0;
virtual int prepare_for_describe() = 0;
virtual void describe_column(int colNum, data_type& dtype,
std::string& column_name) = 0;
virtual standard_into_type_backend* make_into_type_backend() = 0;
virtual standard_use_type_backend* make_use_type_backend() = 0;
virtual vector_into_type_backend* make_vector_into_type_backend() = 0;
virtual vector_use_type_backend* make_vector_use_type_backend() = 0;
private:
// noncopyable
statement_backend(statement_backend const&);
statement_backend& operator=(statement_backend const&);
};
// polymorphic RowID backend
class rowid_backend
{
public:
virtual ~rowid_backend() {}
};
// polymorphic blob backend
class blob_backend
{
public:
blob_backend() {}
virtual ~blob_backend() {}
virtual std::size_t get_len() = 0;
virtual std::size_t read(std::size_t offset, char* buf,
std::size_t toRead) = 0;
virtual std::size_t write(std::size_t offset, char const* buf,
std::size_t toWrite) = 0;
virtual std::size_t append(char const* buf, std::size_t toWrite) = 0;
virtual void trim(std::size_t newLen) = 0;
private:
// noncopyable
blob_backend(blob_backend const&);
blob_backend& operator=(blob_backend const&);
};
// polymorphic session backend
class session_backend
{
public:
session_backend() {}
virtual ~session_backend() {}
virtual void begin() = 0;
virtual void commit() = 0;
virtual void rollback() = 0;
// At least one of these functions is usually not implemented for any given
// backend as RDBMS support either sequences or auto-generated values, so
// we don't declare them as pure virtuals to avoid having to define trivial
// versions of them in the derived classes. However every backend should
// define at least one of them to allow the code using auto-generated values
// to work.
virtual bool get_next_sequence_value(session&, std::string const&, long&)
{
return false;
}
virtual bool get_last_insert_id(session&, std::string const&, long&)
{
return false;
}
virtual std::string get_backend_name() const = 0;
virtual statement_backend* make_statement_backend() = 0;
virtual rowid_backend* make_rowid_backend() = 0;
virtual blob_backend* make_blob_backend() = 0;
private:
// noncopyable
session_backend(session_backend const&);
session_backend& operator=(session_backend const&);
};
} // namespace details
// simple base class for the session back-end factory
class connection_parameters;
class SOCI_DECL backend_factory
{
public:
backend_factory() {}
virtual ~backend_factory() {}
virtual details::session_backend* make_session(
connection_parameters const& parameters) const = 0;
};
} // namespace soci
#endif // SOCI_BACKEND_H_INCLUDED
|