9 #define SOCI_MYSQL_SOURCE 25 #pragma warning(disable:4355) 38 position_ = position++;
51 std::size_t
const vsize = size();
52 for (
size_t i = 0; i != vsize; ++i)
57 if (ind != NULL && ind[i] ==
i_null)
60 std::strcpy(buf,
"NULL");
70 =
static_cast<std::vector<char> *
>(data_);
71 std::vector<char> &v = *pv;
73 char tmp[] = { v[i],
'\0' };
74 buf =
quote(statement_.session_.conn_, tmp, 1);
79 std::vector<std::string> *pv
80 =
static_cast<std::vector<std::string> *
>(data_);
81 std::vector<std::string> &v = *pv;
83 buf =
quote(statement_.session_.conn_,
84 v[i].c_str(), v[i].size());
89 std::vector<short> *pv
90 =
static_cast<std::vector<short> *
>(data_);
91 std::vector<short> &v = *pv;
93 std::size_t
const bufSize
94 = std::numeric_limits<short>::digits10 + 3;
95 buf =
new char[bufSize];
96 snprintf(buf, bufSize,
"%d", static_cast<int>(v[i]));
102 =
static_cast<std::vector<int> *
>(data_);
103 std::vector<int> &v = *pv;
105 std::size_t
const bufSize
106 = std::numeric_limits<int>::digits10 + 3;
107 buf =
new char[bufSize];
108 snprintf(buf, bufSize,
"%d", v[i]);
113 std::vector<long long> *pv
114 =
static_cast<std::vector<long long> *
>(data_);
115 std::vector<long long> &v = *pv;
117 std::size_t
const bufSize
118 = std::numeric_limits<long long>::digits10 + 3;
119 buf =
new char[bufSize];
125 std::vector<unsigned long long> *pv
126 =
static_cast<std::vector<unsigned long long> *
>(data_);
127 std::vector<unsigned long long> &v = *pv;
129 std::size_t
const bufSize
130 = std::numeric_limits<unsigned long long>::digits10 + 3;
131 buf =
new char[bufSize];
137 std::vector<double> *pv
138 =
static_cast<std::vector<double> *
>(data_);
139 std::vector<double> &v = *pv;
143 "Use element used with infinity or NaN, which are " 144 "not supported by the MySQL server.");
147 std::size_t
const bufSize = 100;
148 buf =
new char[bufSize];
150 snprintf(buf, bufSize,
"%.20g", v[i]);
155 std::vector<std::tm> *pv
156 =
static_cast<std::vector<std::tm> *
>(data_);
157 std::vector<std::tm> &v = *pv;
159 std::size_t
const bufSize = 22;
160 buf =
new char[bufSize];
162 snprintf(buf, bufSize,
"\'%d-%02d-%02d %02d:%02d:%02d\'",
163 v[i].tm_year + 1900, v[i].tm_mon + 1, v[i].tm_mday,
164 v[i].tm_hour, v[i].tm_min, v[i].tm_sec);
170 "Use vector element used with non-supported type.");
174 buffers_.push_back(buf);
180 statement_.useByPosBuffers_[position_] = &buffers_[0];
185 statement_.useByNameBuffers_[name_] = &buffers_[0];
195 case x_char: sz = get_vector_size<char> (data_);
break;
196 case x_short: sz = get_vector_size<short> (data_);
break;
197 case x_integer: sz = get_vector_size<int> (data_);
break;
198 case x_long_long: sz = get_vector_size<long long> (data_);
break;
200 sz = get_vector_size<unsigned long long>(data_);
202 case x_double: sz = get_vector_size<double> (data_);
break;
203 case x_stdstring: sz = get_vector_size<std::string> (data_);
break;
204 case x_stdtm: sz = get_vector_size<std::tm> (data_);
break;
207 throw soci_error(
"Use vector element used with non-supported type.");
215 std::size_t
const bsize = buffers_.size();
216 for (std::size_t i = 0; i != bsize; ++i)
218 delete [] buffers_[i];
bool is_infinity_or_nan(T x)
virtual void bind_by_name(std::string const &name, void *data, details::exchange_type type)
char * quote(MYSQL *conn, const char *s, int len)
virtual std::size_t size()
virtual void pre_use(indicator const *ind)
virtual void bind_by_pos(int &position, void *data, details::exchange_type type)