Improvements to the CrudModel
The new data of modified rows is now stored directly within the row_mapping also changed how new rows are handled so the new empty row for inserting is not a special case but is part of the list.
This commit is contained in:
parent
a7f247bdee
commit
06504ecc1f
9 changed files with 213 additions and 317 deletions
|
|
@ -12,7 +12,7 @@ Params::Params(const Params& rhs)
|
|||
, m_paramFormats(rhs.m_paramFormats)
|
||||
{
|
||||
//std::vector<const char *> m_paramValues;
|
||||
copyValues(rhs.m_paramValues);
|
||||
appendValues(rhs.m_paramValues);
|
||||
}
|
||||
|
||||
Params& Params::operator=(const Params& rhs)
|
||||
|
|
@ -21,7 +21,7 @@ Params& Params::operator=(const Params& rhs)
|
|||
m_paramTypes = rhs.m_paramTypes;
|
||||
m_paramLengths = rhs.m_paramLengths;
|
||||
m_paramFormats = rhs.m_paramFormats;
|
||||
copyValues(rhs.m_paramValues);
|
||||
appendValues(rhs.m_paramValues);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -82,20 +82,21 @@ Param Params::add(const char *data, Oid oid)
|
|||
p[len] = 0;
|
||||
}
|
||||
return addText(p, oid);
|
||||
|
||||
// m_paramTypes.push_back(oid);
|
||||
// m_paramValues.push_back(p);
|
||||
// m_paramLengths.push_back(len);
|
||||
// m_paramFormats.push_back(0);
|
||||
}
|
||||
|
||||
//void Params::addBinary(const char *data, int length, Oid oid)
|
||||
//{
|
||||
// m_paramTypes.push_back(oid);
|
||||
// m_paramValues.push_back(data);
|
||||
// m_paramLengths.push_back(length);
|
||||
// m_paramFormats.push_back(1);
|
||||
//}
|
||||
template <typename T, typename U>
|
||||
void concatContainers(T &d, const U& s)
|
||||
{
|
||||
d.insert(d.end(), s.begin(), s.end());
|
||||
}
|
||||
|
||||
void Params::addParams(const Params ¶ms)
|
||||
{
|
||||
concatContainers(m_paramTypes, params.m_paramTypes);
|
||||
concatContainers(m_paramLengths, params.m_paramLengths);
|
||||
concatContainers(m_paramFormats, params.m_paramFormats);
|
||||
appendValues(params.m_paramValues);
|
||||
}
|
||||
|
||||
void Params::clear()
|
||||
{
|
||||
|
|
@ -106,13 +107,14 @@ void Params::clear()
|
|||
m_paramFormats.clear();
|
||||
}
|
||||
|
||||
void Params::copyValues(const t_paramValues &r)
|
||||
void Params::appendValues(const t_paramValues &r)
|
||||
{
|
||||
const int n = static_cast<int>(m_paramTypes.size());
|
||||
m_paramValues.reserve(n);
|
||||
const int n = static_cast<int>(r.size());
|
||||
const int ofs = m_paramValues.size();
|
||||
m_paramValues.reserve(ofs + n);
|
||||
for (int i = 0; i < n; ++i) {
|
||||
if (r[i]) {
|
||||
const int len = m_paramLengths[i];
|
||||
const int len = m_paramLengths[ofs + i];
|
||||
char * p = new char[len+1];
|
||||
std::memcpy(p, r[i], len+1);
|
||||
m_paramValues.push_back(p);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue