/usr/include/Poco/Data/SQLite/Binder.h is in libpoco-dev 1.8.0.1-1ubuntu4.
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 | //
// Binder.h
//
// Library: Data/SQLite
// Package: SQLite
// Module: Binder
//
// Definition of the Binder class.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef Data_SQLite_Binder_INCLUDED
#define Data_SQLite_Binder_INCLUDED
#include "Poco/Data/SQLite/SQLite.h"
#include "Poco/Data/AbstractBinder.h"
#include "Poco/Data/LOB.h"
#include "Poco/Any.h"
#include "Poco/DynamicAny.h"
#include "sqlite3.h"
namespace Poco {
namespace Data {
namespace SQLite {
class SQLite_API Binder: public Poco::Data::AbstractBinder
/// Binds placeholders in the sql query to the provided values. Performs data types mapping.
{
public:
Binder(sqlite3_stmt* pStmt);
/// Creates the Binder.
~Binder();
/// Destroys the Binder.
void bind(std::size_t pos, const Poco::Int8 &val, Direction dir);
/// Binds an Int8.
void bind(std::size_t pos, const Poco::UInt8 &val, Direction dir);
/// Binds an UInt8.
void bind(std::size_t pos, const Poco::Int16 &val, Direction dir);
/// Binds an Int16.
void bind(std::size_t pos, const Poco::UInt16 &val, Direction dir);
/// Binds an UInt16.
void bind(std::size_t pos, const Poco::Int32 &val, Direction dir);
/// Binds an Int32.
void bind(std::size_t pos, const Poco::UInt32 &val, Direction dir);
/// Binds an UInt32.
void bind(std::size_t pos, const Poco::Int64 &val, Direction dir);
/// Binds an Int64.
void bind(std::size_t pos, const Poco::UInt64 &val, Direction dir);
/// Binds an UInt64.
#ifndef POCO_LONG_IS_64_BIT
void bind(std::size_t pos, const long &val, Direction dir);
/// Binds a long
void bind(std::size_t pos, const unsigned long &val, Direction dir);
/// Binds an unsigned long
#endif
void bind(std::size_t pos, const bool &val, Direction dir);
/// Binds a boolean.
void bind(std::size_t pos, const float &val, Direction dir);
/// Binds a float.
void bind(std::size_t pos, const double &val, Direction dir);
/// Binds a double.
void bind(std::size_t pos, const char &val, Direction dir);
/// Binds a single character.
void bind(std::size_t pos, const char* const &pVal, Direction dir);
/// Binds a const char ptr.
void bind(std::size_t pos, const std::string& val, Direction dir);
/// Binds a string.
void bind(std::size_t pos, const Poco::Data::BLOB& val, Direction dir);
/// Binds a BLOB.
void bind(std::size_t pos, const Poco::Data::CLOB& val, Direction dir);
/// Binds a CLOB.
void bind(std::size_t pos, const Date& val, Direction dir);
/// Binds a Date.
void bind(std::size_t pos, const Time& val, Direction dir);
/// Binds a Time.
void bind(std::size_t pos, const DateTime& val, Direction dir);
/// Binds a DateTime.
void bind(std::size_t pos, const NullData& val, Direction dir);
/// Binds a null.
private:
void checkReturn(int rc);
/// Checks the SQLite return code and throws an appropriate exception
/// if error has occurred.
template <typename T>
void bindLOB(std::size_t pos, const Poco::Data::LOB<T>& val, Direction dir)
{
// convert a blob to a an unsigned char* array
const T* pData = reinterpret_cast<const T*>(val.rawContent());
int valSize = static_cast<int>(val.size());
int rc = sqlite3_bind_blob(_pStmt, static_cast<int>(pos), pData, valSize, SQLITE_STATIC); // no deep copy, do not free memory
checkReturn(rc);
}
sqlite3_stmt* _pStmt;
};
//
// inlines
//
inline void Binder::bind(std::size_t pos, const Poco::Int8 &val, Direction dir)
{
Poco::Int32 tmp = val;
bind(pos, tmp, dir);
}
inline void Binder::bind(std::size_t pos, const Poco::UInt8 &val, Direction dir)
{
Poco::Int32 tmp = val;
bind(pos, tmp, dir);
}
inline void Binder::bind(std::size_t pos, const Poco::Int16 &val, Direction dir)
{
Poco::Int32 tmp = val;
bind(pos, tmp, dir);
}
inline void Binder::bind(std::size_t pos, const Poco::UInt16 &val, Direction dir)
{
Poco::Int32 tmp = val;
bind(pos, tmp, dir);
}
inline void Binder::bind(std::size_t pos, const Poco::UInt32 &val, Direction dir)
{
Poco::Int32 tmp = static_cast<Poco::Int32>(val);
bind(pos, tmp, dir);
}
inline void Binder::bind(std::size_t pos, const Poco::UInt64 &val, Direction dir)
{
Poco::Int64 tmp = static_cast<Poco::Int64>(val);
bind(pos, tmp, dir);
}
inline void Binder::bind(std::size_t pos, const bool &val, Direction dir)
{
Poco::Int32 tmp = (val ? 1 : 0);
bind(pos, tmp, dir);
}
inline void Binder::bind(std::size_t pos, const float &val, Direction dir)
{
double tmp = val;
bind(pos, tmp, dir);
}
inline void Binder::bind(std::size_t pos, const char &val, Direction dir)
{
Poco::Int32 tmp = val;
bind(pos, tmp, dir);
}
inline void Binder::bind(std::size_t pos, const char* const &pVal, Direction dir)
{
std::string val(pVal);
bind(pos, val, dir);
}
inline void Binder::bind(std::size_t pos, const Poco::Data::BLOB& val, Direction dir)
{
bindLOB<Poco::Data::BLOB::ValueType>(pos, val, dir);
}
inline void Binder::bind(std::size_t pos, const Poco::Data::CLOB& val, Direction dir)
{
bindLOB<Poco::Data::CLOB::ValueType>(pos, val, dir);
}
} } } // namespace Poco::Data::SQLite
#endif // Data_SQLite_Binder_INCLUDED
|