fastcgi++
A C++ FastCGI/Web API
parameters.cpp
Go to the documentation of this file.
1 
10 /*******************************************************************************
11 * Copyright (C) 2017 Eddie Carle [eddie@isatec.ca] *
12 * *
13 * This file is part of fastcgi++. *
14 * *
15 * fastcgi++ is free software: you can redistribute it and/or modify it under *
16 * the terms of the GNU Lesser General Public License as published by the Free *
17 * Software Foundation, either version 3 of the License, or (at your option) *
18 * any later version. *
19 * *
20 * fastcgi++ is distributed in the hope that it will be useful, but WITHOUT ANY *
21 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for *
23 * more details. *
24 * *
25 * You should have received a copy of the GNU Lesser General Public License *
26 * along with fastcgi++. If not, see <http://www.gnu.org/licenses/>. *
27 *******************************************************************************/
28 
29 #include "fastcgi++/sql/parameters.hpp"
30 
31 #include <locale>
32 #include <codecvt>
33 
34 void Fastcgipp::SQL::Parameters_base::build()
35 {
36  const size_t columns = size();
37  m_raws.clear();
38  m_raws.reserve(columns);
39  m_sizes.clear();
40  m_sizes.reserve(columns);
41  build_impl();
42 }
43 
44 Fastcgipp::SQL::Parameter<std::string>&
45 Fastcgipp::SQL::Parameter<std::string>::operator=(const std::wstring& x)
46 {
47  std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> converter;
48  try
49  {
50  m_data = converter.to_bytes(x);
51  }
52  catch(const std::range_error& e)
53  {
54  WARNING_LOG("Error in code conversion to utf8 in SQL parameter")
55  }
56  return *this;
57 }
#define WARNING_LOG(data)
Log any externally caused "errors".
Definition: log.hpp:124