19 #pragma warning(disable:4355 4996) 20 #define snprintf _snprintf // TODO: use soci-platform.h 31 if (statement_.boundByName_)
34 "Binding for use elements must be either by position or by name.");
39 position_ = position++;
41 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 (by name) to " << name_;
67 statement_.boundByName_ =
true;
72 std::size_t
const vsize = size();
75 if (statement_.useData_.size() != vsize)
77 statement_.useData_.resize(vsize);
80 int const pos = position_ - 1;
82 for (
size_t i = 0; i != vsize; ++i)
87 if (statement_.useData_[i].size() <
static_cast<std::size_t
>(position_))
89 statement_.useData_[i].resize(position_);
93 if (ind != NULL && ind[i] ==
i_null)
95 statement_.useData_[i][pos].isNull_ =
true;
96 statement_.useData_[i][pos].data_ =
"";
97 statement_.useData_[i][pos].blobBuf_ = 0;
98 statement_.useData_[i][pos].blobSize_ = 0;
107 std::vector<char> *pv
108 =
static_cast<std::vector<char> *
>(data_);
109 std::vector<char> &v = *pv;
118 std::vector<std::string> *pv
119 =
static_cast<std::vector<std::string> *
>(data_);
120 std::vector<std::string> &v = *pv;
122 buf =
new char[v[i].size() + 1];
123 std::strcpy(buf, v[i].c_str());
128 std::vector<short> *pv
129 =
static_cast<std::vector<short> *
>(data_);
130 std::vector<short> &v = *pv;
132 std::size_t
const bufSize
133 = std::numeric_limits<short>::digits10 + 3;
134 buf =
new char[bufSize];
135 snprintf(buf, bufSize,
"%d", static_cast<int>(v[i]));
141 =
static_cast<std::vector<int> *
>(data_);
142 std::vector<int> &v = *pv;
144 std::size_t
const bufSize
145 = std::numeric_limits<int>::digits10 + 3;
146 buf =
new char[bufSize];
147 snprintf(buf, bufSize,
"%d", v[i]);
152 std::vector<long long> *pv
153 =
static_cast<std::vector<long long> *
>(data_);
154 std::vector<long long> &v = *pv;
156 std::size_t
const bufSize
157 = std::numeric_limits<long long>::digits10 + 3;
158 buf =
new char[bufSize];
164 std::vector<unsigned long long>* pv
165 =
static_cast<std::vector<unsigned long long>*
>(data_);
166 std::vector<unsigned long long>& v = *pv;
168 std::size_t
const bufSize
169 = std::numeric_limits<unsigned long long>::digits10 + 2;
170 buf =
new char[bufSize];
178 std::vector<double> *pv
179 =
static_cast<std::vector<double> *
>(data_);
180 std::vector<double> &v = *pv;
182 std::size_t
const bufSize = 100;
183 buf =
new char[bufSize];
185 snprintf(buf, bufSize,
"%.20g", v[i]);
190 std::vector<std::tm> *pv
191 =
static_cast<std::vector<std::tm> *
>(data_);
192 std::vector<std::tm> &v = *pv;
194 std::size_t
const bufSize = 20;
195 buf =
new char[bufSize];
197 snprintf(buf, bufSize,
"%d-%02d-%02d %02d:%02d:%02d",
198 v[i].tm_year + 1900, v[i].tm_mon + 1, v[i].tm_mday,
199 v[i].tm_hour, v[i].tm_min, v[i].tm_sec);
204 "Use vector element used with non-supported type.");
207 statement_.useData_[i][pos].isNull_ =
false;
208 statement_.useData_[i][pos].data_ = buf;
209 statement_.useData_[i][pos].blobBuf_ = 0;
210 statement_.useData_[i][pos].blobSize_ = 0;
227 sz = get_vector_size<char>(data_);
230 sz = get_vector_size<short>(data_);
233 sz = get_vector_size<int>(data_);
236 sz = get_vector_size<long long>(data_);
239 sz = get_vector_size<unsigned long long>(data_);
242 sz = get_vector_size<double>(data_);
245 sz = get_vector_size<std::string>(data_);
248 sz = get_vector_size<std::tm>(data_);
251 throw soci_error(
"Use vector element used with non-supported type.");
virtual void pre_use(indicator const *ind)
virtual std::size_t size()
virtual void bind_by_name(std::string const &name, void *data, details::exchange_type type)
virtual void bind_by_pos(int &position, void *data, details::exchange_type type)