CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 1999
    Posts
    5

    Using serialization for making packets of byte arrays

    I'm trying to make packets that will each contain a 3D byte array. Currently I have something like the following. Please help!


    #include "stdafx.h"
    #include "Twixt.h"
    #include "Packet.h"


    IMPLEMENT_SERIAL(CPacket,CObject,1)

    //#include <string.h>
    //#include <stdio.h>

    //char stringy[80];

    //strcat(stringy, "hello" );






    void CPacket::Serialize(CArchive &ar)
    {
    if (ar.IsLoading()) {
    ar>>cmd>>x>>y;
    // ar.WriteObject((CObject *)data);
    ar.WriteObject((CByteArray *)data);
    }
    else {
    ar<<cmd<<x<<y;
    ar.ReadObject((CByteArray *)data);
    //data=ar.ReadObject((IsKindOf(*data))data);
    }
    }





  2. #2
    Join Date
    May 1999
    Posts
    667

    Re: Using serialization for making packets of byte arrays

    If you are trying to serailize a CByteArray ptr created using the new operator just use
    ar << data;
    else
    ar >> data;

    if the CByteArray is a memeber variable

    use
    data.Serialize(ar); for both the save and load

    HTH,
    Chris



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured