Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » strange behaviour of Vector serialization (unexpectable data serialized)
strange behaviour of Vector serialization [message #54092] Sun, 31 May 2020 14:19 Go to previous message
michael79 is currently offline  michael79
Messages: 4
Registered: May 2020
Junior Member
Here is the serialization of struct data which contains Vector(byte):

#pragma pack(push, 1)
struct OttMessage
{
uint16 descriptor;
uint16 msgNum;
int32 sec;
int32 nsec;

Vector<byte> data;

void Serialize(Stream& s)
{
s % descriptor % msgNum % sec % nsec % data;
}
};
#pragma pack(pop)


DUMP of buffer show the next:
(int)buf[0] = 102
(int)buf[1] = 0
(int)buf[2] = 111
(int)buf[3] = 0
(int)buf[4] = 123
(int)buf[5] = 0
(int)buf[6] = 0
(int)buf[7] = 0
(int)buf[8] = 222
(int)buf[9] = 0
(int)buf[10] = 0
(int)buf[11] = 0
(int)buf[12] = 7
(int)buf[13] = 10
(int)buf[14] = 144
(int)buf[15] = 56
(int)buf[16] = 233
(int)buf[17] = 77

Data from Vector begins since buf[12], but the value 7 unexpectable, it was not added to Vector.

When I change Serialize() as the following, then all data correct:

void Serialize(Stream& s)
{
s % descriptor % msgNum % sec % nsec;

for(int i = 0; i < data.size(); i++)
{
s % data[i];
}
}

(int)buf[0] = 102
(int)buf[1] = 0
(int)buf[2] = 111
(int)buf[3] = 0
(int)buf[4] = 123
(int)buf[5] = 0
(int)buf[6] = 0
(int)buf[7] = 0
(int)buf[8] = 222
(int)buf[9] = 0
(int)buf[10] = 0
(int)buf[11] = 0
(int)buf[12] = 10
(int)buf[13] = 144
(int)buf[14] = 56
(int)buf[15] = 233
(int)buf[16] = 77
(int)buf[17] = 188

Can anyone explane such strange behaviour?
Why I need to add Vector data one by one?


 
Read Message
Read Message
Read Message
Previous Topic: serialization
Next Topic: [SOLVED] ParseJSON weird behaviour
Goto Forum:
  


Current Time: Sat Apr 27 08:43:23 CEST 2024

Total time taken to generate the page: 0.03958 seconds