16 #include <resultset.h> 17 #include "rapidjson/document.h" 18 #include "rapidjson/writer.h" 19 #include "rapidjson/stringbuffer.h" 20 #include "rapidjson/error/error.h" 28 InsertValue(
const std::string& column,
const std::string& value) :
31 m_value.str = (
char *)malloc(value.length() + 1);
32 strncpy(m_value.str, value.c_str(), value.length() + 1);
33 m_type = STRING_COLUMN;
35 InsertValue(
const std::string& column,
const int value) :
41 InsertValue(
const std::string& column,
const long value) :
47 InsertValue(
const std::string& column,
const double value) :
51 m_type = NUMBER_COLUMN;
53 InsertValue(
const std::string& column,
const rapidjson::Value& value) :
56 rapidjson::StringBuffer sb;
57 rapidjson::Writer<rapidjson::StringBuffer> writer(sb);
59 std::string s = sb.GetString();
60 m_value.str = (
char *)malloc(s.length() + 1);
61 strncpy(m_value.str, s.c_str(), s.length() + 1);
79 m_value.ival = rhs.m_value.ival;
82 m_value.fval = rhs.m_value.fval;
85 m_value.str = strdup(rhs.m_value.str);
88 m_value.str = strdup(rhs.m_value.str);
100 if (m_type == STRING_COLUMN || m_type == JSON_COLUMN)
105 const std::string toJSON()
const 107 std::ostringstream json;
109 json <<
"\"" << m_column <<
"\" : ";
116 json << m_value.ival;
119 json << m_value.ival;
122 json << m_value.fval;
125 json <<
"\"" << m_value.str <<
"\"";
136 const std::string m_column;
148 const std::string toJSON()
const 150 std::ostringstream json;
153 for (std::vector<InsertValue>::const_iterator it = this->cbegin();
154 it != this->cend(); ++it)
157 json << it->toJSON();
158 if (it + 1 != this->cend())
Class that defines data to be inserted or updated in a column within the table.
Definition: insert.h:26