Serialize and DeSerialize of CObArray

This is a discussion on Serialize and DeSerialize of CObArray within the C++ Programming forums, part of the General Programming Boards category; Need help in the Serializing and DeSerializing of an CObArray. I know to Serialize I just do this: CObArray testList; ...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    2

    Serialize and DeSerialize of CObArray

    Need help in the Serializing and DeSerializing of an CObArray.
    I know to Serialize I just do this:

    CObArray testList;
    testList.Serialize(ar);

    so how to I take out the CObArray and assign it to another CObArray object test2List?

    thanks in advance.

  2. #2
    Unregistered
    Guest
    You need to be more precise in what you are trying to say/do.

    From posted code I would say CObArray is a user defined class. The the CObArray class has a method called Serialize() that takes a single argument. You declare testlist as a CObArray object. Then you pass ar, whatever that is, to the Serialize() method of that object.

    Now to the crux of the problem: Are you trying to "copy" one CObArray object to another (a process accomplished by an overloaded assignment operator, and/or a copy constructor) or do you wish to transfer data in a member variable of one object into a member variable, method of another object?

  3. #3
    Unregistered
    Guest
    CObArray is an array of Objects.

  4. #4
    Unregistered
    Guest
    Do you mean that CObArray is an array of objects like

    objectType CObArray[numberOfObjects];

    or

    objectType * CObArray = new objectType[numberOFObjects];

    and the line

    CObArray testlist;

    is gibberish. Or do you mean something like a class that has an array of objects in it. Like this:


    class CObArray
    {
    public:
    int array[numberOfObjects];
    void Serialize(int);
    }

    in which case the line:

    CObArray testline;

    makes sense.

  5. #5
    Registered User
    Join Date
    Feb 2002
    Posts
    591
    CObArray is something MS wrote, Kinda like CString.It works like so

    CObArray coMyArray;

    Then you have a whole bunch of methods to maniulate this array ex

    coMyArray.Add(),,,,,
    coMyArray.RemoveAll()....
    coMyArray[2],,,,,

    It stored a pointer to the object and the size is dynamicly allocated.

    http://msdn.microsoft.com/library/de...ss_members.asp

    It works really well

  6. #6
    Registered User
    Join Date
    Apr 2002
    Posts
    2
    Ermm let me be more precise.

    I declared a CObArray Object called tempList.

    code:
    CObArray tempList;


    Than lets say I added stuff to it.
    So the should be like this:

    void CModule1Doc::Serialize(CArchive& ar)
    {
    if (ar.IsStoring())
    {
    // TODO: add storing code here
    // Serialize tempList
    tempList.Serialize(ar)
    }
    else
    {
    // TODO: add loading code here
    }
    }

    Now the problem I have is how to DeSerialize my tempList out.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21