473,394 Members | 1,703 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Serializing Enums

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

Mar 3 '06 #1
3 2388
Josh Mcfarlane wrote:
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
--
Please remove capital As from my address when replying by mail
Mar 3 '06 #2
Victor Bazarov wrote:
Josh Mcfarlane wrote:
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.


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?

Mar 3 '06 #3
Josh Mcfarlane wrote:
Victor Bazarov wrote:
Josh Mcfarlane wrote:
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.


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
--
Please remove capital As from my address when replying by mail
Mar 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: SpaceCowboy | last post by:
I recently got into a discussion with a co-worker about using enums across a dll interface. He wanted to use chars instead, argueing that depending on compiler settings the size of an enum could...
2
by: Faisal | last post by:
Can anyone tell me if it is possible to enumerate through all the Enums within a class . I have a class with many Enums and would like to accees the Enums through an array/collection etc. I can't...
27
by: Mark A. Gibbs | last post by:
i have been toying with the idea of making my enums smarter - ie, more in line with the rest of the language. i haven't tested it yet, but what i came up with is a template like this: template...
1
by: Ivo Bronsveld | last post by:
All, I have quite a challenging task ahead of me. I need to write an object model (for code access) based on a schema, which cannot be made into a dataset because of it's complexity. So I...
2
by: Tobias Zimmergren | last post by:
Hi, just wondering what serializing really is, and howto use it? Thanks. Tobias __________________________________________________________________ Tobias ICQ#: 55986339 Current ICQ status: +...
4
by: Martin Pritchard | last post by:
Hi, I'm working on a project that historically contains around 40 enums. In the database various fields refer to the int values of these enums, but of course ref integrity is not enofrced and...
2
by: Simon Elliott | last post by:
I have some legacy C++ code which requires some enums to be 1 or 2 bytes in size. I'd ideally like to be able to specify that a few carefully selected enums are a particular size. By default,...
11
by: Marc Gravell | last post by:
This one stumped me while refactoring some code to use generics... Suppose I declare an enum MyEnum {...} Is there a good reason why MyEnum doesn't implement IEquatable<MyEnum> ? Of course,...
10
by: yu_kuo | last post by:
I got series warning when using write enum type to a ostream using operator<<, like in call to `std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) '...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.