Is there a simple (and quick) serialisation method for simple vectors?

Discussion in 'C++' started by Pierre Couderc, Jul 29, 2005.

  1. I want to serialise quickly a "simple" vector :
    (simple is to say with basic types and no pointers)
    such as :

    class c
    {
    int i,j;
    double z;
    }

    vector<c> cs;

    Is there some simple efficient way such as :
    memcpy(mybuff, cs , sizeof(what?))...

    I am using SGI stl.

    Thank you in advance
    Pierre Couderc
    Pierre Couderc, Jul 29, 2005
    #1
    1. Advertising

  2. Re: Is there a simple (and quick) serialisation method for simplevectors?

    Pierre Couderc wrote:
    > I want to serialise quickly a "simple" vector :
    > (simple is to say with basic types and no pointers)
    > such as :
    >
    > class c
    > {
    > int i,j;
    > double z;
    > }

    ;
    >
    > vector<c> cs;


    Supposedly you included the proper headers...

    > Is there some simple efficient way such as :
    > memcpy(mybuff, cs , sizeof(what?))...
    >
    > I am using SGI stl.


    What's "mybuff"?

    You should probably do

    memcpy(mybuff, &cs[0], cs.size() * sizeof(c));

    V
    Victor Bazarov, Jul 29, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lefevre
    Replies:
    1
    Views:
    323
    Victor Bazarov
    Nov 12, 2003
  2. Replies:
    3
    Views:
    691
    Shadowman
    Mar 26, 2008
  3. Replies:
    0
    Views:
    248
  4. Guest
    Replies:
    0
    Views:
    438
    Guest
    Sep 14, 2005
  5. Paul  Moore
    Replies:
    4
    Views:
    104
    Paul Moore
    Feb 23, 2013
Loading...

Share This Page