can I serialize to xml instead of proprietary format

Hello,

For example in the case of CObject::Serialize(archive); is there a way
to get that to write out in xml format instead of proprietary? Then I
wouldn't have to erase the preferences file each time I add a new
element to add, e.g.

if (archive.IsStoring()) {
		archive << GetSize();
		archive << m_debug;

if above code in use for a while, and now if I want to add

		archive << m_do_not_use_skin;

I need to erase preferences because serialize only knows about the
order in which to expect the properties, but if it could understand xml
would not need to be in any specific order and could add new
properties.

Thx!

0
6/8/2005 4:13:26 AM
vc.mfc 33608 articles. 0 followers. Follow

6 Replies
627 Views

Similar Articles

[PageSpeed] 45

can't you overload << ? (maybe you really can't, I don't know, but that
seems to be a way to go)

0
6/8/2005 6:26:28 AM
XML is fairly easy to read and write. I would simply skip the whole CArchive nonsense and
write simple XML input and output routines. I have done this using the ExPat library.
				joe

On 7 Jun 2005 21:13:26 -0700, "alexl" <alextheblade@gmail.com> wrote:

>Hello,
>
>For example in the case of CObject::Serialize(archive); is there a way
>to get that to write out in xml format instead of proprietary? Then I
>wouldn't have to erase the preferences file each time I add a new
>element to add, e.g.
>
>if (archive.IsStoring()) {
>		archive << GetSize();
>		archive << m_debug;
>
>if above code in use for a while, and now if I want to add
>
>		archive << m_do_not_use_skin;
>
>I need to erase preferences because serialize only knows about the
>order in which to expect the properties, but if it could understand xml
>would not need to be in any specific order and could add new
>properties.
>
>Thx!

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
6/8/2005 6:41:24 AM
Hello!

On 7 Jun 2005 21:13:26 -0700, alexl wrote:

> Hello,
> 
> For example in the case of CObject::Serialize(archive); is there a way
> to get that to write out in xml format instead of proprietary?
Have a look at Mr. Dhandapani Ammasai's article "XMLize Your Class" at
CodeProject.
http://www.codeproject.com/soap/xmlize.asp

> Then I
> wouldn't have to erase the preferences file each time I add a new
> element to add, e.g.
> 

The first thing you should save is the version of the data! This way you
can change the data format and still be able to read the old format.

#define DATAVER 1

> if (archive.IsStoring()) {
		archive << DATAVER
> 		archive << GetSize();
> 		archive << m_debug;
> 
> if above code in use for a while, and now if I want to add
> 
> 		archive << m_do_not_use_skin;
> 

Then when you read the data you first do:

	archive >> dataver;
	switch(dataver)
	{
	case 1:
		// get version 1 of the data
		break;
	case 2:
		// get version 2 of the data
		break;
	}

NB! Always save the data in the Active/latest version.

Best wishes!

// Anders
-- 
There are probably many errors in the code! I just entered from memory and
my memory is usually returning memroy error...
0
6/8/2005 6:51:22 AM
alexl wrote:
> Hello,
>
> For example in the case of CObject::Serialize(archive); is there a way
> to get that to write out in xml format instead of proprietary? Then I
> wouldn't have to erase the preferences file each time I add a new
> element to add, e.g.
>
> if (archive.IsStoring()) {
> archive << GetSize();
> archive << m_debug;
>
> if above code in use for a while, and now if I want to add
>
> archive << m_do_not_use_skin;
>
> I need to erase preferences because serialize only knows about the
> order in which to expect the properties, but if it could understand
> xml would not need to be in any specific order and could add new
> properties.

See http://www.boost.org/libs/serialization/doc/index.html

This library allows you to serialize to xml, binary and text archives 
seemlessly. It takes some inspiration from MFC serialization, but does away 
with many of it's shortcomings. It's a fairly straightforward transformation 
to convert your Serialize(archive) member functions to boost serialize 
functions. In fact you'll end up with less code. The library uses templates 
and operator overloading to allow a single source code line to both 
store/load. For example:

   template< class Archive >  void serialize( Archive &ar, tVersion 
version )
   {
      using namespace boost::serialization;

      ar & make_nvp( "FileRef"        , base_object<CFileRef>(*this) );
      ar & make_nvp( "CompileOptions" , mCompileOptions              );
      ar & make_nvp( "CompileDebug"   , mCompileDebug                );
      ar & make_nvp( "CompileOptimize", mCompileOptimize             );
   }

Jeff Flinn


0
not1 (120)
6/8/2005 11:55:25 AM
You could consider using an external XML parsing library such as
CMarkup: http://www.firstobject.com/dn_markup.htm

If you would like to preserve the framework of CArchive, then you could
create an CXMLArchive which inherits from CArchive and uses a CMarkup
member to actually perform the XML loading, saving and parsing tasks to
retrieve/modify your data.

However, for a project that I did, I just created custom XML loading
and storing objects with CMarkup instead of reusing CArchive's
framework and interface.

0
fong5216 (3)
6/9/2005 1:52:43 AM
thx for the replies,

would the microsoft MSXML 6.0 library come in handy for these types of
projects?

thx!

0
6/15/2005 9:18:40 PM
Reply:

Similar Artilces:

Can I fade the edges of photos that I use?
I am trying to use photos in a publisher document that I want to fade the edges of, is this possible to do with publisher? -- D:o) krazy-4-coke wrote: > I am trying to use photos in a publisher document that I want to fade the > edges of, is this possible to do with publisher? Not really. You should use dedicated image manipulation software for this, such as Photoshop Elements, Paint Shop Pro, or Microsoft Digital Image. -- Ed Bennett - MVP Microsoft Publisher http://ed.mvps.org Ed, Are any of these programs typically come loaded on a computer?? I have another question - ca...

Trying to Get Subset of XML
I want to display a segment of an XML (see below) file in a datagrid. I want to select a specific <EventID> and get all of its children into a dataset so that I can bind a datagrid to those values. I am trying an expression as follows but I get an error "Value of type 'System.Xml.XmlNode' cannot be converted to 'System.Xml.XmlNodeList'." myNodes = xmldoc.ChildNodes("/Dataset/Events/[ShowName=Round 2]") What is the correct way to "get" that set of nodes and convert them to a dataset? ================== Portion of XML File ===============...

Can I delete my switchboard and make a new one?
I do not like my switchboard and would like to delete this one and start all over. But when I did delete it I couldn't make another one, because I couldn't delete the default. What should I do?Thanks,Dustin Just delete the form and the table that were created by the wizard, then start over.-- Rick B"Dustin" <Dustin@discussions.microsoft.com> wrote in message news:42F94A44-9352-4D02-9104-65593869B271@microsoft.com...>I do not like my switchboard and would like to delete this one and start >all> over. But when I did delete it I couldn't make another one, beca...

transfer inbox in table format to word
In my older version I could cut and paste the table format in Outlook to a word file. Now I don't seem to be able to do it although I can print the file in that format within Outlook. When I export the inbox to word I get the whole text not just the headings. Is it possible to transfer the table format to a word file? ...

how can I drag formulas with other cell references
example cell A1 contains formula "=stdev(a2:a7) cell a2 contains formula "=stdev(a8:a13) Is it possible to drag the formula down so that cell a3 contains "=stdev(a14:19) and cell a4 contains "=stdev(a20:a25) and so on for cells a5, a6, a7 etc. etc. Hi Bram, See http://www.mvps.org/dmcritchie/excel/snakecol.htm#snkAddr B1: =stdev(OFFSET($A$1,6*ROW()-5,0):OFFSET($A$1,6*ROW(),0)) B2: =stdev(OFFSET($A$1,6*ROW()-5,0):OFFSET($A$1,6*ROW(),0)) It was easier to test and verify using SUM instead of stdev, but the formula is same NOTE the formulas are in a different colu...

BP XML Exception
Using Dynamics GP v9.0- BP 3.0 As the administrator of our Business Portal, I was updating the results viewer for Sales>Customers>Document>Customer Document Detail> and had modified the query to show more information (columns etc). I clicked accept and the admins viewing is fine, HOWEVER, our users can no longer see any information in that viewer. They get the following exception: System.Xml.XmlException "Unable to update the specified query, Customer Document Detail, from the specified XML definition." Any advice? Thank you Pam, Thanks for using the newsgro...

can i have more sender in outlook setting ?
i using win server 2003 , exchange 2003 , i using exchange client in outlook to send & receive , but my boss have more than one mail address , can i use another AD mail address for send out mail , i have try to add a pop3 , the sender also is computer user thank your ...

Question Regarding Excel 2007 Formatting Corruption
Hi Folks, I am having a problem with Excel 2007 files losing all formatting (merged cells, colors, borders, and data formatting (99% turns into 0.99)) when I open a file on our office server make edits and then save the new file on the server. Each sheet usually has a mix of locked and unlocked cells and I unprotect the sheet to make edits. Also, something is fundamentally changed with the file as its size doubles or triples. If I reopen the corrupted file and redo any of the formatting and try to save it none of the new formatting is retained either. Has anyone else ever experienced a pr...

IE8 can't access Microsoft Office site when all other browsers can
When trying to access the Microsoft Office page using IE8 I keep getting the "Internet Explorer cannot display the webpage" message. If I use any other browser (Firefox, Opera, Safari, Chrome) I have no problem accessing the page. This happens whether running in normal or No Add-on's mode. Despite how many people keep complaining about all the problems with IE8, neither the MVP's or Microsoft acknowledge that they exist. Asus P5E Intel E8400 Core2Duo 3.0GHz 4 GB PC2-6400 DDR2 Windows 7 Ultimate (with all the latest updates installed) NIS 2010 (all up to date)...

I can't get rid of 1 "Payment to Send' Reminder-M07
On my Home Page in the Reminder section, I have a "1 Payment to Send" listed there. But there is NO payment to send. I"ve opened up back-up copies as far back as May and the reminder is there, but there is no payment that needs sending. Does anybody have an idea how I can get rid of this Reminder? Just removing the Reminder from Home Page doesn't do it. When you put the Reminder back on the Home Page, the "Payment to Send" is still there. Clicking on the link just takes me to Bill Summary page. ...

How to convert privatekey(string) to XML
Hi all, I need to convert privatekey toXML format. I read privatekey from file. Here is how: -------------------------------- Dim myStream As System.IO.StringWriter = New System.IO.StringWriter Dim testfile As String = "c:\RSAprivate.txt" Dim objStreamReader As System.IO.StreamReader objStreamReader = System.IO.File.OpenText(testfile) Dim readfile As String = objStreamReader.ReadToEnd() TextBox1.Text = readfile objStreamReader.Close() -------------------------------- and the privatekey looks like this: -----BEGIN RSA PRIV...

is there any way I can trap for the use of navigation buttons?
Hi Is there any way I can trap for the use of navigation buttons, such as Next, Previous and New record? Stapes Probably. Trap what and when? "Stapes" <steve.staple@gmail.com> wrote in message news:7fe0fd6b-0da1-495e-a369-29bc72ca3af9@s8g2000prg.googlegroups.com... > Hi > > Is there any way I can trap for the use of navigation buttons, such as > Next, Previous and New record? > > Stapes On Wed, 16 Jan 2008 05:14:20 -0800 (PST), Stapes <steve.staple@gmail.com> wrote: No. And there shouldn't be a reason for that. There are plenty of events in...

how can I look into store.exe
I have an email sobig that i cant even download it on my outlook express 6.0.... The adviced for is to locate it on the Queues in Outbound or inbound messages on IMC, but if it is not in there the message may be stuck up in Store. How can I locate it and delete the massega in store.exe they say I can use the MFCmapi but i'm a newbie how can do this. Do I have to download the MFCMapi? what is it? thanks ...

can't change/delete bills and deposits
suddenly one day i realized that when i tried to change a bill, i could click "ok" but nothing would happen. I thought it was because i upgraded to 2004, so i deleted the bills and rescheduled. about 5 of the bills will not delete either. the error message is: "Money could not write to your Money file. The operation could not be performed or another application finished this task before you. Please try again." Now some of the newly scheduled bills will not allow me to change the properties, i click ok but nothing happens when i edit the series. I have repaired ...

Can't Install IBF for CRM on CRM Server
first i'm install IBF On my CRM v1.2 (it's name testcrm) after that i'm try to install IBF for CRM on my CRM Server but in Step "Publish Metadata" i'm type "http://testcrm:8082" and click next button but it's show message box "The Information Bridge metadata service location is not avaliable" and can't install it. -_-' . but i can access "http://testcrm:8082/IBFWriteService.asmx" and "http://testcrm:8081/IBFReadService.asmx". so how can i install it ? I had the same problem - try using http://localhost:8082 for...

Can Work thread get a windows class and manipulate it?
Suppose that I create a work thread when my dialog box started, then in the thread I get the pointer to the dialog mfc class and call updateData method. Does that work? I tried, but failed. Is there any other way to do? thanks!! No, it won't work, don't even waste time trying. It is almost guaranteed to fail. You do not manipulate the windows owned by one thread from a different thread. What you do is PostMessage requests from the worker thread to the main UI thread, usually to the window that contains the controls. The fact that you are using UpdateData already says you are in t...

Why can't I send email messages with Trial Outlook 2007?
I have a new HP laptop that came with the 60 day trial of Office'07. I receive email but the send/reply/compose functions are grayed out. I am certain my settings are correct. Why can't I send email? KK What happens when you use the Test Account Settings? What is the exact error message you get? -- Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. ALWAYS post your Outlook version. How to ask a question: http://support.microsoft.com/KB/555375 After furious head scratching, KK asked: | I have a new HP laptop that came with the 60 day...

Export Format not avaiable
"The Format in which you are attempting to output the currentobject is not available." I hate access sometimes. It just get's weird, throwing bogus error messages all over the place. I have about 30 seperate queries that I run out to spreadsheets via macro. I have already found out that things can get all screwed up, (meaning it bombs) when those spreadsheets already exist, so the first thing I do is delete the existing spreadsheets, then let them rip. I run into this every once in a while: 20 or so queries into my macro, a query will fail with the above er...

How can I keep the header in view at all times
In Word, a header and footer s always in view when you work in th document. However, I cannot seem to do the same in Excel - any suggestions please. Thanks - M Select a cell below your column header and just right of your ro header, then goto "Window" and select Freeze Panes. HTH J -- pinmaste ----------------------------------------------------------------------- pinmaster's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=626 View this thread: http://www.excelforum.com/showthread.php?threadid=49759 ...

xy scatter format
Hi Hope someone can help. I have a chart i want to make look a little more professional. The chart plots three points within two boxes. the points should be inside the box box 1 has the following coordinates x y 15 70000 15 115000 21.5 155800 30 155800 30 115000 25 70000 15 70000 the chart scale is x 14-32 & y 60000-160000 I would like to make the plot area outside the box black to indicate the no go area. Is this possible? Then to take it further there should be a further smaller box (coordinates unimportant) inside the 1st box to indicate a warning. I would like the plot area ...

The code below worked for a few days and just totally stopped working. What can I do to make sure it continues to work? Thanks!
The code below worked for a few days and just totally stopped working. What can I do to make sure it continues to work? Thanks! ----- Private Sub Worksheet_Change(ByVal Target As Range) Dim C As Range, D As Range Set D = Intersect(Range("A:A"), Target) If D Is Nothing Then Exit Sub For Each C In D On Error Resume Next Target.Offset(0, 6).FormulaR1C1 = "=RC[-2]&RC[-5]" ' - For Column E Target.Offset(0, 7).FormulaR1C1 = "=RC[-2]&RC[-5]" ' - For Column F Target.Offset(0, 9).FormulaR1C1 = "=IF(ISNA(VLOOKUP(RC7,I.O.! R2C1:R5...

Someone must have asked this before but I can't find it!
Being a relative Excel newcomer I,m not sure of all the terminology so may have used the wrong terms when searching. What I am trying to do is create a worksheet in which a cell shows one of 3 values (LOW,AVERAGE or HIGH) according to the value in the cell to the left of it, which itself is the sum of the 2 preceding cells. To be more specific, cell D6 is Men, E6 is Women and F6 is"=SUM(D6,E6)". I then want G6 to show "LOW" if F6 is less than 5, "AVERAGE" if it is between 5 and 20, and "HIGH" if it is over 20. If anyone understands the question and can h...

Print Full Bleed in Publisher? Can I eliminate the non-printable a
Hi there I have a "Print Merge" document I am printing. It's basically tickets 6 up on a page and I'm using Print Merge to number the tickets. Also have it set up to print multiple (page size is 2.75inch by 5.5inch). I have the margins set to ZERO and the horizontal, and sides set to ZERO as well. My printer supports full bleed and I can print full bleed from this PC using the same driver with all other programs (Adobe Illustrator, Photoshop, etc, etc), just not with Publisher. I've checked the forums here and can't seem to find a solution. I've selected t...

XML Deserialize of empty value
Hello, I'm encountering a strange issue when deserializing a piece of XML. If I have the following XML and try to deserialize it, everything works: <page> <format>Letter</format> <margin>1</margin> </page> If I have the following XML, everything works: <page> <format></format> <margin>1</margin> </page> BUT if instead I have the following XML, the "margin" element is always 0: <page> <format /> <margin>1</margin> </page> Why...

Serialize a Dictionary
Hello, I am trying to serialize a Generic Dictionary(of Arrays) to store in a Db and I am a little stuck. I want to create a stream to write to and serialize the dictionary, BUT I dont want to create a file. I am a little unsure of how. Any help would be appreciated. Thanks AMP wrote: > Hello, > I am trying to serialize a Generic Dictionary(of Arrays) to store in a > Db and I am a little stuck. > I want to create a stream to write to and serialize the dictionary, > BUT I dont want to create a file. > I am a little unsure of how. > Any help would be apprecia...