save an object

Discussion in 'C++' started by danny van elsen, Dec 18, 2004.

  1. hello all,

    in my application, I want to save an object to a file: what would be
    the best way to do this?

    binary or text?
    self written or existing library?

    thanks for any answer,
    Danny.
    danny van elsen, Dec 18, 2004
    #1
    1. Advertising

  2. * danny van elsen:
    > hello all,
    >
    > in my application, I want to save an object to a file: what would be
    > the best way to do this?
    >
    > binary or text?
    > self written or existing library?
    >
    > thanks for any answer,


    Well, you might check out Niels Bohr's answer to the question: "How
    many tails does a dog have?".

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is it such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
    Alf P. Steinbach, Dec 18, 2004
    #2
    1. Advertising

  3. If it is a windows application, you have two options:

    - Use the built in serialization support in MFC. Fairly complicated
    objects containing
    arrays/lists of objects can be saved.

    - Use the XmlSerializer for .NET applications. Your objects will be
    saved in XML.

    Deepa
    --
    http://www.EventHelix.com/EventStudio
    EventStudio 2.5 - Generate sequence diagrams from plain text input
    EventHelix.com, Dec 18, 2004
    #3
  4. danny van elsen

    Guest

  5. danny van elsen

    David Harmon Guest

    On 18 Dec 2004 04:15:51 -0800 in comp.lang.c++, "EventHelix.com"
    <> wrote,
    >If it is a windows application, you have two options:


    Oh come on! Those two are just the options you have _only_ on a
    windows platform, in addition to all the many platform-independent
    options you could use without selling your soul^W^W^W^W.

    The first thing I would look at is the Boost serialization library.
    David Harmon, Dec 18, 2004
    #5
  6. danny van elsen

    Mike Wahler Guest

    "danny van elsen" <> wrote in message
    news:p...
    > hello all,
    >
    > in my application, I want to save an object to a file: what would be
    > the best way to do this?


    "Best" depends upon context and opinion.

    > binary or text?


    Text will be more portable. Binary will constrain use
    to a specific platform/implementation (or 'category'
    of them). The 'trade-off' is that binary can often
    have better performance than text (the 'footprint'
    will usually be smaller).

    > self written


    Self-written is always an option. It has the advantage
    that it you can make it work exactly how you want, and
    you can modify it at will.

    >or existing library?


    Existing libraries can save large amounts of time and effort,
    but sometimes might restrict you more than you'd like (though
    many libs come with source, and if you understand it, you
    could change it -- but often this imposes usage restrictions)

    If you're looking for a 'get it done as quickly as possible'
    solution, try to find a library that does what you need.
    If you can't, you could try modifying a library or creating
    your own.

    If your motivation is learning, or functionality for which
    you can't find a library, or perhaps simply 'for fun', try
    writing it yourself.

    IMO the most pertinent question to ask yourself when determining
    how to serialize data, is "how/when/where will this data need
    to be accessed?"

    HTH,
    -Mike
    Mike Wahler, Dec 18, 2004
    #6
  7. danny van elsen, Dec 19, 2004
    #7
  8. > Well, you might check out Niels Bohr's answer to the question: "How
    > many tails does a dog have?".


    does it involve talking chinese to people?
    danny van elsen, Dec 20, 2004
    #8
  9. E. Robert Tisdale, Dec 20, 2004
    #9
  10. danny van elsen

    Howard Guest

    "danny van elsen" <> wrote in message
    news:p...
    >> Well, you might check out Niels Bohr's answer to the question: "How
    >> many tails does a dog have?".

    >
    > does it involve talking chinese to people?


    No, but it is "any answer", which is what you thanked us for. :) Careful
    what you ask for...some joker just might give it to you!
    Howard, Dec 20, 2004
    #10
    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. user
    Replies:
    1
    Views:
    761
    Bruce Barker
    Apr 4, 2005
  2. teo
    Replies:
    1
    Views:
    460
  3. BusyBoy
    Replies:
    2
    Views:
    601
    =?Utf-8?B?TGVvbiBNYXluZQ==?=
    Oct 31, 2006
  4. subhadip
    Replies:
    0
    Views:
    628
    subhadip
    Mar 28, 2007
  5. hell2heaven
    Replies:
    0
    Views:
    413
    hell2heaven
    Oct 26, 2008
Loading...

Share This Page