Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Can I extend the Serialization to other types?
Can I extend the Serialization to other types? [message #10743] Thu, 26 July 2007 23:09 Go to next message
jlfranks is currently offline  jlfranks
Messages: 57
Registered: May 2007
Location: Houston, TX, USA
Member
How can I serialize the following:

typedef enum {
FOO_A = 0,
FOO_B = 2,
FOO_C = 42
} FooType;

The serialization does not know what a FooType is.
How can I extend serialization to know about this new type?

--jlf
Re: Can I extend the Serialization to other types? [message #10744 is a reply to message #10743] Fri, 27 July 2007 11:07 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
template <>
inline Stream& operator%(Stream& s, FooType& x)
{
        int n = x;
        s % n;
        x = (FooType)n;
	return s;
}


If FooType is a struct or class, the easier way is to provide Serialize(Stream& s) method for it.
Previous Topic: How to do interation on Vector<String>
Next Topic: best way to parse XML/svg/html style kind attribute pairs?
Goto Forum:
  


Current Time: Sun May 05 01:37:51 CEST 2024

Total time taken to generate the page: 0.01870 seconds