save an object

D

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,
Danny.
 
A

Alf P. Steinbach

* 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?".
 
E

EventHelix.com

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
 
D

David Harmon

On 18 Dec 2004 04:15:51 -0800 in comp.lang.c++, "EventHelix.com"
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.
 
M

Mike Wahler

danny van elsen said:
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
 
H

Howard

danny van elsen said:
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!
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top