Bug fix on array serialization

This commit is contained in:
Luca Marturana 2014-04-11 11:18:59 +02:00
parent 400c619b01
commit 3680d621ba
2 changed files with 9 additions and 7 deletions

View File

@ -95,11 +95,11 @@ size_t Array::size() const
size_t size = 4; size_t size = 4;
// iterate over all elements // iterate over all elements
for (auto iter(_fields.begin()); iter != _fields.end(); ++iter) for (auto item : _fields)
{ {
// add the size of the field type and size of element // add the size of the field type and size of element
size += sizeof((*iter)->typeID()); size += sizeof(item->typeID());
size += (*iter)->size(); size += item->size();
} }
// return the result // return the result
@ -111,12 +111,14 @@ size_t Array::size() const
*/ */
void Array::fill(OutBuffer& buffer) const void Array::fill(OutBuffer& buffer) const
{ {
buffer.add(static_cast<uint32_t>(size()-4));
// iterate over all elements // iterate over all elements
for (auto iter(_fields.begin()); iter != _fields.end(); ++iter) for (auto item : _fields)
{ {
// encode the element type and element // encode the element type and element
buffer.add((*iter)->typeID()); buffer.add((uint8_t)item->typeID());
(*iter)->fill(buffer); item->fill(buffer);
} }
} }

View File

@ -145,7 +145,7 @@ size_t Table::size() const
void Table::fill(OutBuffer& buffer) const void Table::fill(OutBuffer& buffer) const
{ {
// add size // add size
buffer.add((uint32_t) size()-4); buffer.add(static_cast<uint32_t>(size()-4));
// loop through the fields // loop through the fields
for (auto iter(_fields.begin()); iter != _fields.end(); ++iter) for (auto iter(_fields.begin()); iter != _fields.end(); ++iter)