How to Serialize on a new line???

Hi All:

I am using Visual C++ .NET for my MFC application.

I am serializing an object repeatedly in a file. The 
problem is that when I open the file, all the serialized 
objects appear in one big straight line.

What I want to do is to serialize each object starting on 
a new line so that it is more readable and easy to 
comprehend. The code that I am implementing in my 
Serialize function is as follows:

void CDataStorage::Serialize(CArchive& ar)
{
	CObject::Serialize( ar );
	
	if(ar.IsLoading())
    {
	    ar >> m_nID; // UINT16
	    ar >> m_storeString; //CString
    }
    else
    {
	    ar << m_nID; //UINT16
	    ar << m_storeString; //CString
    }
}

One more thing....CString is human-readable in the file 
but the UINT16 is not? Is there any way that I can make it 
human-readable too?

Thanks a lot for any help.
Rashid Hameed (Annandale, NJ)
0
7/24/2003 12:35:21 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
956 Views

Similar Articles

[PageSpeed] 4

serialize stores data in a binary format that is not meant to be human
readable.  if you want to create a human readable format you would have to
override all the serialize functions for the various data types to make them
human readable when you write them, and to read that new format when you
un-serialize them.

"Rashid Hameed" <hameedrashid@hotmail.com> wrote in message
news:13ac01c351e0$0bdc7fb0$a101280a@phx.gbl...
> Hi All:
>
> I am using Visual C++ .NET for my MFC application.
>
> I am serializing an object repeatedly in a file. The
> problem is that when I open the file, all the serialized
> objects appear in one big straight line.
>
> What I want to do is to serialize each object starting on
> a new line so that it is more readable and easy to
> comprehend. The code that I am implementing in my
> Serialize function is as follows:
>
> void CDataStorage::Serialize(CArchive& ar)
> {
> CObject::Serialize( ar );
>
> if(ar.IsLoading())
>     {
>     ar >> m_nID; // UINT16
>     ar >> m_storeString; //CString
>     }
>     else
>     {
>     ar << m_nID; //UINT16
>     ar << m_storeString; //CString
>     }
> }
>
> One more thing....CString is human-readable in the file
> but the UINT16 is not? Is there any way that I can make it
> human-readable too?
>
> Thanks a lot for any help.
> Rashid Hameed (Annandale, NJ)


0
drobbins (12)
7/24/2003 1:19:54 PM
Rashid Hameed wrote:
> 
> Hi All:
> 
> I am using Visual C++ .NET for my MFC application.
> 
> I am serializing an object repeatedly in a file. The
> problem is that when I open the file, all the serialized
> objects appear in one big straight line.
> 
> What I want to do is to serialize each object starting on
> a new line so that it is more readable and easy to
> comprehend. The code that I am implementing in my
> Serialize function is as follows:
> 
> void CDataStorage::Serialize(CArchive& ar)
> {
>         CObject::Serialize( ar );
> 
>         if(ar.IsLoading())
>     {
>             ar >> m_nID; // UINT16
>             ar >> m_storeString; //CString
>     }
>     else
>     {
>             ar << m_nID; //UINT16
>             ar << m_storeString; //CString
>     }
> }
> 
> One more thing....CString is human-readable in the file
> but the UINT16 is not? Is there any way that I can make it
> human-readable too?
> 
> Thanks a lot for any help.
> Rashid Hameed (Annandale, NJ)

Actually, the serialized CString is not entirely human readable.  The
serialization format preceeds the characters with some binary flags and
a binary length.  If you want a text file you will have to format and
write it yourself.

--
Scott McPhillips [VC++ MVP]
0
scottmcp (342)
7/24/2003 11:03:55 PM
Reply:

Similar Artilces:

2003 wont send new mail from default account
I am running Office Pro 2003 SP1 I have read several postings and accept that Outlook will reply to mails via the account the was received from. However, i have added a new account and set it as default, but mail still gets sent from my other account. This even happens when i select the account from within the new mail... the message says 'This message will be sent via mail.mydefaultdomain.com'.. but its actually gets sent via the non default account.. How do i sort this as it is really annoying.. On 19 Jan 2005 14:44:35 -0800, Winshent wrote: > I am running Office Pro 2003 SP1...

new problem with OL 2000
You helped me with a problem between OL and Ms Exchange. I followed your recommendations and got rid of Ms Echange server. But now every time I open OL, I have a message :"the location messages are delivered to has changed for this user profile. To complete this oeration you may need to copy the contents of the old folders to the new OL folders. For help... see OL help". I went there, but cannot find anything of help. And in the same message it says "some of the shortcut on the OL bar may no longer work. Do you want to recreate your shortcuts...". I answer no. wil...

New Items #2
What is the fastest way to enter new items in the Headquaters Manager? How many do you want to create? For one at a time, find a similar item (or at least an item from the same supplier) and copy it. For dozens or hundreds, either import or use a series of query statements. For the import/query method, you really need to know what you are doing. Tom -- Stop fishing for e-mail "Woofy" wrote: > What is the fastest way to enter new items in the Headquaters Manager? My Office Manager is getting tired of entering items through the many steps that she was shown. We sell Pet ...

Will new Discover Ranges be OK
I am running RMS SO 2.0. Will there be any problems with my CC processing with the new Discover card number ranges? Thanks, TomT ...

Serial Number Problem
Hi Everyone, we run Dynamics on our server anyway we had HUGE problems and lost a lot of work.....anyway after fixing lots up i still have one MAJOR problem. Serial numbers for items in the system do exist if you look up inventory ~ Serials. There is a list of serial numbers in stock ready to use. But when we go to do an invoice there are no serial numbers, it asks you if you want to overide the quantities... Our problem was we lost our inventory file therefore we had to put an old file back on...although these serial numbers are there we can not use them which also means i cant put t...

Duplicate Element Names in Serialized XML
Hi All, Hoping someone can solve a problem for me. I am modifying the schema for a rather complex web service written in VB.NET. The services uses a large number of serialized classes to output the overall XML. The problem I am having is that I require 2 XML elements of the same name to be serialized from the 1 class. Due to the way the web service is written only 1 of these would be ever be called at a time. However, it seems that I get an exception if the same element name is used twice in one class.. any ideas? For example: 'start class here <XMLElement ("elementName&q...

Not New to MFC
Hey everyone I've been using MFC for a while now and I'm ready to graduate. I've heard that COM is better. Exactly what is it, why is it better, and where can I learn about it? I realize that this post is off-topic but I couldn't find a COM group to post it in. I'm using Visual C++ 6.0 Standard -- MiniDisc_2k2 To reply, replace nospam.com with cox dot net. See the following link. http://www.microsoft.com/com/ You can post your COM related questions to 'microsoft.public.vc.atl' newsgroup. COM experts like Alexander Nickolov, Igor Tandetnik, Ja...

How do I prepare a template with default line thickness for boxes?
I am using Publisher2000. I have designed a template with some text formatting attributes. Now I want to include a default “thin line thickness” when I use the drawing tool for drawing a rectangle on the page. Regards Jorgen From Help 1. On the Objects toolbar, click the tool that creates the type of frame or object you want to set the default formats for. Do not create an object at this point; just click the tool and go on to step 2. 2. Choose the commands, dialog box options, or toolbar buttons for the formatting you want. Now each time you use this tool in the current publication, th...

error setting up new user
Hi, If I setup a new user in AD more often than not no mailbox is set up and so when I install the client in Outlook and try to find the mailbox name I get an error saying The name could net be resolved. The name could not be matched to a name in the address list. This is driving me nuts, anyone any clues. I am using SBS 2000 with exchange 2000 Regards Simon Well, the first thing to troubleshoot in this situation is the Recipient Update Service (RUS). If the RUS doesn't stamp Exchange attributes on the user, the won't show up. There are a number of posssibilities: 328675 XADM:...

Serial Motor
How do you control a motor via serial port? What language should I use? Justin Case wrote: > How do you control a motor via serial port? What language should I > use? I don't know, but it certainly isn't possible with SQL Server ... http://lmgtfy.com/?q=How+do+you+control+a+motor+via+serial+port -- HTH, Bob Barrows Bob Barrows (reb01501@NOyahoo.SPAMcom) writes: > I don't know, but it certainly isn't possible with SQL Server ... What? You can't control a motor with an engine? -- Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se...

How to create a new document by clicking open?
**** Post for FREE via your newsreader at post.usenet.com **** Hi I'm using VC++ 6 and my problem is that I have a program (MDI) that displays images whenever a user clicks on the open button (on toolbar or menu). Everything works fine, until the user closes the MDI child window. The way my program works is that he now needs to click on 'File > New' to open a blank window, then to click on 'File > Open' to open the image in the newly created window. The user cannot open an image directly with the 'open' button if a blank window is not already created. How ca...

Compare 2 spreadsheets dump differences into a new sheet.
Good afternoon I would like to have some idea of the VBA code to compare 2 spreadsheets "old" and "new" and then dump the differences into a new sheet -may be named: "changes"- created by the code. If somebody can help me with this I'll be very grateful. Thanks in advance and greetings. Look for Compare.xla on this site http://www.cpearson.com/Excel/whatsnew.htm "Apprentice" wrote: > Good afternoon > > I would like to have some idea of the VBA code to compare 2 spreadsheets > "old" and "new" and then dump ...

How do I get deleted items that stay in inbox with line thru them.
I inherited a computer at work. Outlook is setup so that when I delete a message it stays in the inbox, with a line thru it. How do I get the deleted items to go automatically to the deleted item folder? "rwwhit" <rwwhit@discussions.microsoft.com> wrote in message news:7D17761E-CD1B-4D04-BACB-B0D837C4DD93@microsoft.com... >I inherited a computer at work. Outlook is setup so that when I delete a > message it stays in the inbox, with a line thru it. How do I get the deleted > items to go automatically to the deleted item folder? That's normal behavior...

New Laptop
Will Excel spreadsheets created in Office 97 copied from CD backup to a new laptop with Windows XP Home/Office 2003 retain all formulae and formats, allowing me to continue adding data? Swampy, I don't think you will have any problems with your files -- Paul B Always backup your data before trying something new Please post any response to the newsgroups so others can benefit from it Feedback on answers is always appreciated! Using Excel 2002 & 2003 "swampy" <swampy@discussions.microsoft.com> wrote in message news:C5935905-81BC-41EF-8CED-8FC1C4E5D028@microsoft.com....

Always Show Overtime Lines on Timesheet
Using MSPS2007. Is there a way to default the timesheet to always show the overtime rows so that you do not have to use the menu? Gary -- No, there is no default way to force the Overtime rows whenever a user creates a new Timesheet. Users need to display the Overtime rows after they create their Timesheet. Hope this helps. -- Dale A. Howard [MVP] VP of Educational Services msProjectExperts http://www.msprojectexperts.com http://www.projectserverexperts.com "We write the books on Project Server" "Gary Zag" <GaryZag@discussions.microsoft.com&...

Excel 2003
I've noticed several things which I'd like to be able to understand, control and/or eliminate: 1. On come cells, there's a dark triangle in the upper LH corner of the cell accompanied by a yellow exclamation point in a diamond. The cells in question don't appear to contain anything out of the ordinary. When I paste a cell's contents into other cells, the right side of the screen is taken over by a display of clipboard contents, which I didn't ask for. In addition, a small Paste icon appears next to the cells. Occasionally a Format painter icon appears next to a ce...

serial port communuication
Hi all, I m communicating to a printer device through serial port.It is failing to open the port,but when I disable and enable the com port in device manager,it works fine(i.e)it communicates with the printer and reads the configuration settings of the printer). Regards Hari are u leaving the port opened when ur program terminates ........ what is the frequency of u disabling/enabling port ....... after every run ...... some times works some times not ..... ????? "hari" <haricibi83@gmail.com> wrote in message news:1171455246.402743.203120@k78g2000cwa.googlegrou...

Serialization of jagged Arrays Issue
Hi there, I m trying to return an object (of my own written class) from a web service that contains jagged Arrays as public variables. Asp.Net is showing me the its serialized version on the browser when i invoke the service during test. Code: public class returnType { [System.Xml.Serialization.XmlElementAttribute("chassisdata")] public _chassisdata[] chassisdata; [XmlArray(),XmlArrayItem("wheel", typeof(_wheel[]),IsNullable=false)] public _wheel[][] upsteps; [XmlArray(),XmlArrayItem("wheelsize", typeof(_wheelsize[]),IsNullable=false)] publi...

sales line comments
When a comment is entered on sales line, the comment text is automatically split up into Comment_1, Comment_2 and so on. I am trying to populate the comments (CMMTTXT field) through sql into table SOP10202. However, I dont know how to populate the fields Comment_1, Comment_2 so that the CMMTTXT field is neatly broken into these sub fields. Jack, I haven't done it but it can easily be done in VB as follows and should be able to get done in SQL as well. I hope, someone else would come up with a better suggestion. Each COMMENT_x colum must not exceed 51 characters, so, count the numbe...

New Installation
Hi All Have installed VB6 and MSDN on to my new laptop, It's Winders 7 64bit. I got 2 problems (amongst others): 1. Each time VB6 starts I get a box saying Please wait while winders configures micro$oft office 2007. It then tells me it cannot find required files, It does this 4 times. This PC used to have a trial version of office installed but no longer has. How to stop it doing this? 2. A full install of MSDN was done a few times, MSDN is missing those links at the top of the help file pages. Things like 'See Also, Properties, Methods, Events, Applies to'. Where ...

Higlihting entire rows or lines?
Hi I was wondering is there any way of highlighting entire lines or rows in word? If you are talking about text lines, clicking next to the line in the left margin will select it. Similarly, you can click next to a table row to select it. (The mouse pointer will look like an arrow.) -- Stefan Blom Microsoft Word MVP "D Shah" <D Shah@discussions.microsoft.com> wrote in message news:59141C31-9ABF-4A90-9908-C6E9ACBE8613@microsoft.com... > Hi I was wondering is there any way of highlighting entire lines or rows > in > word? Do you mean as ...

open files serially
Hi, I seek your help for the following; I have few files in one of the folder. The file names are ending with numeric number. The uniqueness of the file names are they are serially numbered e.g. ABC123.xls, XYZ124.xls, MNO_AB125.xls, LKM126.xls. I would like to open these files serially (...123 then ...124 so on so forth till last files in the folder). Once the file is open i would like to do some processing and save it in another folder. The files once opened and saved in another folder it should get deleted from earlier folder (From where the file was opened). Than...

COleDateTimeSpan
I noticed problem in Visual Studio.NET 7.0.9466, don't know if something wrong with my VC source code. the bug could cause data corruption if you use serialization of COleDatTimeSpan object, the problem is in file olevar.cpp, one line of code is missing (at least on my mashine ============= CArchive& AFXAPI operator<<(CArchive& ar, COleDateTimeSpan dateSpanSrc return ar << dateSpanSrc.m_span CArchive& AFXAPI operator>>(CArchive& ar, COleDateTimeSpan& dateSpanSrc ar >> (long&)dateSpanSrc.m_status return ar >> dateSpanSrc.m_span ...

New Opportunity Product (Error on Page)
We are trying to add products to an opportunity, but when we hit the button "New Opportunity Product" on the Products page of the Opportunity module the only thing we get is an "Error on Page" in the bottom left-hand corner. Has anyone experienced this before? If so, any idea(s) how to fix it? Thanks, Tim Do you have a Price list and matching currency associated to the Opportunity? do you have any javascript running on the Opportunity or Opportunity Product? "Tim" wrote: > We are trying to add products to an opportunity, but when we hit the button &g...

New mail notification should not show a red flag
When I receive new mail notification, the little box shows a red flag and a high priority status symbol. When I go to outlook, neither are true for the email. New mail should only show those if it is true ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.micr...