22 #pragma warning(disable:4355 4996) 23 #define snprintf _snprintf // TODO: use soci-platform.h 32 if (statement_.boundByName_)
35 "Binding for use elements must be either by position or by name.");
40 position_ = position++;
42 statement_.boundByPos_ =
true;
48 if (statement_.boundByPos_)
51 "Binding for use elements must be either by position or by name.");
58 statement_.reset_if_needed();
59 position_ = sqlite3_bind_parameter_index(statement_.stmt_, name_.c_str());
63 std::ostringstream ss;
64 ss <<
"Cannot bind to (by name) " << name_;
67 statement_.boundByName_ =
true;
72 statement_.useData_.resize(1);
73 int const pos = position_ - 1;
75 if (statement_.useData_[0].size() <
static_cast<std::size_t
>(position_))
77 statement_.useData_[0].resize(position_);
80 if (ind != NULL && *ind ==
i_null)
82 statement_.useData_[0][pos].isNull_ =
true;
83 statement_.useData_[0][pos].data_ =
"";
84 statement_.useData_[0][pos].blobBuf_ = 0;
85 statement_.useData_[0][pos].blobSize_ = 0;
95 buf_[0] = *
static_cast<char*
>(data_);
101 std::string *s =
static_cast<std::string *
>(data_);
102 buf_ =
new char[s->size() + 1];
103 std::strcpy(buf_, s->c_str());
108 std::size_t
const bufSize
109 = std::numeric_limits<short>::digits10 + 3;
110 buf_ =
new char[bufSize];
111 snprintf(buf_, bufSize,
"%d",
112 static_cast<int>(*static_cast<short*>(data_)));
117 std::size_t
const bufSize
118 = std::numeric_limits<int>::digits10 + 3;
119 buf_ =
new char[bufSize];
120 snprintf(buf_, bufSize,
"%d",
121 *static_cast<int*>(data_));
126 std::size_t
const bufSize
127 = std::numeric_limits<long long>::digits10 + 3;
128 buf_ =
new char[bufSize];
130 *static_cast<long long *>(data_));
135 std::size_t
const bufSize
136 = std::numeric_limits<unsigned long long>::digits10 + 2;
137 buf_ =
new char[bufSize];
139 *static_cast<unsigned long long *>(data_));
146 std::size_t
const bufSize = 100;
147 buf_ =
new char[bufSize];
149 snprintf(buf_, bufSize,
"%.20g",
150 *static_cast<double*>(data_));
155 std::size_t
const bufSize = 20;
156 buf_ =
new char[bufSize];
158 std::tm *t =
static_cast<std::tm *
>(data_);
159 snprintf(buf_, bufSize,
"%d-%02d-%02d %02d:%02d:%02d",
160 t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
161 t->tm_hour, t->tm_min, t->tm_sec);
172 std::size_t
const bufSize
173 = std::numeric_limits<unsigned long>::digits10 + 2;
174 buf_ =
new char[bufSize];
176 snprintf(buf_, bufSize,
"%lu", rbe->
value_);
181 blob *b =
static_cast<blob *
>(data_);
185 std::size_t len = bbe->
get_len();
186 buf_ =
new char[len];
187 bbe->
read(0, buf_, len);
188 statement_.useData_[0][pos].blobBuf_ = buf_;
189 statement_.useData_[0][pos].blobSize_ = len;
193 throw soci_error(
"Use element used with non-supported type.");
196 statement_.useData_[0][pos].isNull_ =
false;
199 statement_.useData_[0][pos].blobBuf_ = 0;
200 statement_.useData_[0][pos].blobSize_ = 0;
201 statement_.useData_[0][pos].data_ = buf_;
virtual void bind_by_pos(int &position, void *data, details::exchange_type type, bool readOnly)
virtual std::size_t get_len()
details::rowid_backend * get_backend()
virtual void bind_by_name(std::string const &name, void *data, details::exchange_type type, bool readOnly)
virtual std::size_t read(std::size_t offset, char *buf, std::size_t toRead)
virtual void pre_use(indicator const *ind)
details::blob_backend * get_backend()
virtual void post_use(bool gotData, indicator *ind)