Merge pull request #9 from luca3m/fix-array-serialization

Bug fix on array serialization
This commit is contained in:
Emiel Bruijntjes 2014-04-14 09:28:07 +02:00
commit c252c53751
2 changed files with 9 additions and 7 deletions

View File

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

View File

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