473,657 Members | 2,415 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1588
* 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********@gma il.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.c om...
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.c om...
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3709
by: Glenn M | last post by:
I have a shared XML file on a server . i also have one xslt file that performs a simple transform on in to view the data. now i want to have another page that lets users modify the shared xml file via some editable controls such as text boxes , option boxes etc. how can i implment this , should i use another xslt file with <INPUT> controls . if so how can i save the result back using the asp.net
7
1265
by: Shanli RICHEZ | last post by:
I'm using ASP.NET and quite a lot of object in memory instead of a database. The question is that I tried to save the data, serialize them in a XML file to save them when the application is ending. event : Application_End in Global.asax. But the object are not accesible from there so I can't save them. Any idea ???
10
4339
by: GJP | last post by:
Hello. Ive been asked to make my own notepade for college assignment. All ig going well, but i cant get the save to work. I can get Save a (shows dialog box), i can get it to just save too, but when i try to put an IF in it to check if the file has already been saved before, it will not save.
4
2954
by: jmhmaine | last post by:
The following code works when Option Strict is off: Dim thumbSize As New Size thumbSize = CType(NewthumbSize(g.Width, g.Height, 100), System.Drawing.Size) Dim imgThumbOutput As New Bitmap(g, thumbSize.Width, thumbSize.Height) imgThumbOutput.Save(Server.MapPath(ThumbnailPath), thisFormat) When I turn on Option Strict, I receive the following compile error: Overload resolution failed because no accessible 'Save' can be called with these...
2
2467
by: zheng | last post by:
ÇçÌì I have a word document and it has a picture object, I want save the picture object as other single picture file by C# program. I have a idea, by clipboard, copy the picture to clipboard, and then save as a file from clipboard, it is work well in application,but don't work in a web application. how can I to do? and are there other ideas to save the picture object in web application? help me !!
1
9501
by: Rocco | last post by:
I have a single Excel workbook stored as an OLE object in an Access table. I am trying to figure out how to save this object as an .xls file, open it, modify it, and resave it. I know how I can modify it once it has been saved, but how do I retrieve and save this object programmatically from Access?
1
6803
by: liuliuliu | last post by:
hi -- sorry if this is trivial -- but how do you make a screenshot of a pygame display? i have a surface which is basically the entire visible screen -- how do you write this surface as an image file during specific events in the script execution? image format doesnt matter. thanks! christine
13
2288
by: Joe | last post by:
does anyone know why this source code throws an error?? Dim myBitmap As System.Drawing.Bitmap Dim myGraphics As Graphics myBitmap = New System.Drawing.Bitmap(fileName:="C:\test.tif") myGraphics = PictureBox1.CreateGraphics Dim expansionRectangle As New Rectangle(25, 550, 1000, 350) Dim destRectangle1 As New Rectangle(0, 0, 1000, 350) myGraphics.DrawImage(myBitmap, destRectangle1, expansionRectangle,
0
3738
by: ppardi | last post by:
I'm developing an addin for Word 2007 and I need to determine whether a user saves a Word 2007 document in an older format (97-2003) after a save as is done. The scenario is that the user starts out with a Word 2007 document, saves that document to disk, then saves the same document in an older format If the user saves a doc in an older format, I want to turn off certain features of my add-in. I'm able to trap the save event easily...
0
1337
by: phanibiddu | last post by:
How to draw on windows form and save it as Jpeg file I am trying with this code but not comming public Form3() { InitializeComponent(); //rnd = new Random((int)DateTime.Now.Ticks); // seeded with ticks myPen = new Pen(Color.Red);
0
8324
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8842
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8740
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7352
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2742
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1970
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.