Serializing Enums

J

Josh Mcfarlane

What's the best way to serialize and unserialize an enumeration value?

Is there a defined size that an enumeration cannot exceed?

For example, int size may vary based on computers, so is there a set
size that I should use in a binary communication format?

Thanks,
Josh McFarlane
 
V

Victor Bazarov

Josh said:
What's the best way to serialize and unserialize an enumeration value?

Using your own symbolic designators.
Is there a defined size that an enumeration cannot exceed?

The largest integral type, which of course can vary on different systems.
For example, int size may vary based on computers, so is there a set
size that I should use in a binary communication format?

No.

V
 
J

Josh Mcfarlane

Victor said:
Using your own symbolic designators.


The largest integral type, which of course can vary on different systems.


No.

Dealing with a library that will only be used on our enumeration types,
no outside sources, would it be practical to just force enums to fit
within a long and transfer to and from the primitive type?
 
V

Victor Bazarov

Josh said:
Dealing with a library that will only be used on our enumeration
types, no outside sources, would it be practical to just force enums
to fit within a long and transfer to and from the primitive type?

You're still going to run into trouble if on two different systems the
size of 'long' is different, unless, of course, you're going to limit
yourself to the lower 32 bits of it.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top