469,950 Members | 1,823 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,950 developers. It's quick & easy.

save an object

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.

Jul 22 '05 #1
9 1401
* 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?
Jul 22 '05 #2
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

Jul 22 '05 #3
On 18 Dec 2004 04:15:51 -0800 in comp.lang.c++, "EventHelix.com"
<ev********@gmail.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.

Jul 22 '05 #5
"danny van elsen" <da*************@hotmail.com> wrote in message
news:pa****************************@hotmail.com...
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
Jul 22 '05 #6
tanx!

On Sat, 18 Dec 2004 05:24:38 -0800, matej.kovac wrote:
http://www.parashift.com/c++-faq-lit...alization.html


Jul 22 '05 #7
> 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?
Jul 22 '05 #8
danny van elsen wrote:
In my application, I want to save an object to a file.
What would be the best way to do this?


I used Google

http://www.google.com/

to seach for

+"C++" +"serialization"

and I found lots of stuff including

http://www.parashift.com/c++-faq-lit...alization.html
Jul 22 '05 #9

"danny van elsen" <da*************@hotmail.com> wrote in message
news:pa****************************@hotmail.com...
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!

Jul 22 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by GJP | last post: by
4 posts views Thread by jmhmaine | last post: by
1 post views Thread by Rocco | last post: by
1 post views Thread by liuliuliu | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.