$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Robert Ramey (ramey_at_[hidden])
Date: 2008-04-08 18:28:41
binary_object will do it - but you have to create the array by hand.
look at using a reference to an array in stead of a pointer.
Robert Ramey
  "Ariel Brunetto" <abrunetto_at_[hidden]> wrote in message news:c1bd22250804081247i4c34489fh5f69a0d0c8595b73_at_mail.gmail.com...
  My pointer to a char is actually an array. Is it possible to serialize it in this way?
  Ariel
  On Tue, Apr 8, 2008 at 4:54 PM, Robert Ramey <ramey_at_[hidden]> wrote:
    serializing a pointer to a char is will only serialize one char.
    try serializating either an array of characters or an std::string
    Robert Ramey
      "Ariel Brunetto" <abrunetto_at_[hidden]> wrote in message news:c1bd22250804081016m1bf9c734s143a08b9a166a2bb_at_mail.gmail.com...
      Hello!
      My name is Ariel and this is my first time with boost. I spent a few days looking arround the serialization library, and right now I have a project with my first serialized classes.
      I spent some time reading the documentation and the tutorial. I am having problems serializing pointers. I am trying to serialize a const char* and it seems that doesn't work in the trivial way.
      This is my code:
      //-----------------------------------------------------------------------------
      // myserializeclass.h
      //-----------------------------------------------------------------------------
      #include <fstream>
      #include <boost/archive/binary_iarchive.hpp>
      #include <boost/archive/binary_oarchive.hpp>
      #include <boost/serialization/base_object.hpp>
      //-----------------------------------------------------------------------------
      class MySerializeClass
      {
      private:
       friend class boost::serialization::access;
       template<class Archive>
       void serialize(Archive & ar, const unsigned int uiVersion)
       {
        ar & m_pChar;
       }
      // members to serialize
      public:
       char* m_pChar;
      };
      //-----------------------------------------------------------------------------
      BOOST_CLASS_TRACKING(MySerializeAbstractBase, ::boost::serialization::track_never)
      //-----------------------------------------------------------------------------
      //-----------------------------------------------------------------------------
      // myserializeclass.cpp
      //-----------------------------------------------------------------------------
      int main()
      {
       MySerializeClass MySerializeClassObject;
       
       std::ofstream ofs(akFilename);
       boost::archive::binary_oarchive oa(ofs);
       
       oa << MySerializeClassObject;
       return 0;
      }
      //-----------------------------------------------------------------------------
      It doesn't compile. I get the following error:
      1>c:\program files\microsoft visual studio 8\vc\platformsdk\include\boost\serialization\access.hpp(109) : error C2228: left of '.serialize' must have class/struct/union
      I know that this is my mistake, but I don't know how to fix it ;). I know that there is a lot of consideration about pointer serialization. Could you point me in the right direction?
      Thanks in advance!
      Ariel
--------------------------------------------------------------------------
      _______________________________________________
      Boost-users mailing list
      Boost-users_at_[hidden]
      http://listarchives.boost.org/mailman/listinfo.cgi/boost-users 
    _______________________________________________
    Boost-users mailing list
    Boost-users_at_[hidden]
    http://listarchives.boost.org/mailman/listinfo.cgi/boost-users
  -- 
  ________________
  Ariel Brunetto
  www.aquadize.com 
------------------------------------------------------------------------------
  _______________________________________________
  Boost-users mailing list
  Boost-users_at_[hidden]
  http://listarchives.boost.org/mailman/listinfo.cgi/boost-users