| View previous topic :: View next topic |
| Author |
Message |
danny van elsen Guest
|
Posted: Sat Dec 18, 2004 11:55 am Post subject: 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.
|
|
| Back to top |
|
 |
Alf P. Steinbach Guest
|
Posted: Sat Dec 18, 2004 11:57 am Post subject: Re: save an object |
|
|
* danny van elsen:
| Quote: | 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?
|
|
| Back to top |
|
 |
EventHelix.com Guest
|
Posted: Sat Dec 18, 2004 12:15 pm Post subject: Re: save an object |
|
|
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
|
|
| Back to top |
|
 |
matej.kovac@gmail.com Guest
|
|
| Back to top |
|
 |
David Harmon Guest
|
Posted: Sat Dec 18, 2004 6:53 pm Post subject: Re: save an object |
|
|
On 18 Dec 2004 04:15:51 -0800 in comp.lang.c++, "EventHelix.com"
<eventhelix (AT) gmail (DOT) com> wrote,
| Quote: | 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.
|
|
| Back to top |
|
 |
Mike Wahler Guest
|
Posted: Sat Dec 18, 2004 9:14 pm Post subject: Re: save an object |
|
|
"danny van elsen" <danny_van_elsen (AT) hotmail (DOT) com> wrote
| Quote: | 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.
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 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.
| Quote: | 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
|
|
| Back to top |
|
 |
danny van elsen Guest
|
Posted: Sun Dec 19, 2004 10:11 pm Post subject: Re: save an object |
|
|
tanx!
On Sat, 18 Dec 2004 05:24:38 -0800, matej.kovac wrote:
|
|
| Back to top |
|
 |
danny van elsen Guest
|
Posted: Mon Dec 20, 2004 9:26 pm Post subject: Re: save an object |
|
|
| Quote: | 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?
|
|
| Back to top |
|
 |
E. Robert Tisdale Guest
|
|
| Back to top |
|
 |
Howard Guest
|
Posted: Mon Dec 20, 2004 10:04 pm Post subject: Re: save an object |
|
|
"danny van elsen" <danny_van_elsen (AT) hotmail (DOT) com> wrote
| Quote: | 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!
|
|
| Back to top |
|
 |
|