[Ns-developers] How to serialize a array
Mathieu Lacage
mathieu.lacage at sophia.inria.fr
Tue Dec 23 10:29:09 PST 2008
On Mon, 2008-12-22 at 10:58 +0000, Nuno Farias wrote:
> Hi!
>
> I having a problem that probably has a very easy solution but I don't
> know how to solve it.
>
> Basically I have a class (here is resumed):
>
> class PREQElement
> {
> public:
> PREQElement ();
>
> uint8_t m_pdflags;
> Mac48Address m_destinationaddress;
> uint64_t m_destinationseqnum;
>
> uint32_t GetSerializedSize (void) const
> { return 1+6+8;}
>
> void Serialize (Buffer::Iterator start) const
> {
> i.WriteU8(m_pdflags);
> WriteTo (i, m_destinationaddress);
> i.WriteU64 (m_destinationseqnum);
> }
>
> Buffer::Iterator Deserialize (Buffer::Iterator start)
> {
> m_pdflags = i.ReadU8 ();
> ReadFrom (i, m_destinationaddress);
> m_destinationaddress = i.ReadU64 ();
> }
> };
>
> and in other class called "class PREQElement :: public Header" I have to
> do a
>
> PREQElement example[50];
>
> How do I serialize this? I can't just call serialize... How can I do it?
Sorry if I missed something obvious, but, what is wrong about this ?
for (int i = 0; i < 50; i++)
{
p->AddHeader (example[i]);
}
>
> Sorry if this is very easy.
>
> Thanks,
> Nuno.
More information about the Ns-developers
mailing list