enums

What is the best way to send structs containing enum values via sockets in C.

I've lots of different structs containing enum members that I have to transmit via TCP/IP. While the communication endpoints are on different operating systems (Windows XP and Linux) meaning different compilers (gcc 4.x.x and MSVC 2008) both program parts share the same header files with type declarations. For performance reasons, the s...

How to define properties for Enum items

i have read the following on Java enum but still confused. i would like the following: public enum Checker { EMPTY ("Empty"), RED ("Red"), YELLOW ("Yellow"); } to return the related String. from what i have read, this should be possible. just would like you to shed some light on it on how to implement it. thank you. ...

How do I use an enum with custom values for a Sharepoint Web part?

I'm trying to design a Web Part that has a drop-down list for the user to choose from. Eventually, these values will be automatically generated based on some kind of outside data source, so they're going to have somewhat arbitrary numeric values associated with them. This is the code I have now: public enum filterChoice { Al...

How to ensure consistency of enums in Java serialization?

When I serialize an object, I can use the serialVersionUID mechanism at the class level to ensure the compatibility of the two types. However, what happens when I serialize fields of enum values? Is there a way to ensure that the enum type has not been manipulated between serialization and deserialization? Suppose that I have an enum ...

Why in java enum is declared as Enum<E extends Enum<E>>

Possible Duplicate: java Enum definition if language designers were to use simply Enum<E extends Enum> how would that affect the language? The only difference now would be that someone coud write A extends Enum<B> but since it is not allowed in java to extend enums that would be still illegal. I was also thinking about ...

Closest cocoa equivalent of enum

Is there a Cocoa class has similar functionality to enumerated values from C? I know that I can just use enums in Cocoa, but what if I want to put an enum in an NSArray (which only accepts objects)? ...

org.hibernate.HibernateException: Error while accessing enum.values(): class com.mksoft.fbautomate.domain.Account$Type

This error is driving me nuts!!! Caused by: java.lang.NoSuchMethodException: com.mksoft.fbautomate.domain.Account$Type.values() The same exact class works fine in a separate Groovy file. Any ideas/help much appreciated. Most confusing... http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Enum.html has no values() method! Here is m...

What would be different in Java if Enum declaration didn't have the recursive part

Please see http://stackoverflow.com/questions/211143/java-enum-definition and http://stackoverflow.com/questions/3061759/why-in-java-enum-is-declared-as-enume-extends-enume for general discussion. Here I would like to learn what exactly would be broken (not typesafe anymore, or requiring additional casts etc) if Enum class was defined a...

Java - how to design your own type?

Is it possible to design your own Java Type, similar to an extensible enum? For instance, I have user roles that a certain module uses and then a sub-package provides additional roles. What would be involved on the JDK side of things? ...

C# enums/reflection

Let's say I have a function that takes a string. That string contains the fully name of an enum type (e.g. "MyCompany.Area.AotherNamespace.MyEnum"). How could I create an array of strings (or List<string>) whose elements are the values of MyCompany.Area.AotherNamespace.MyEnum? Is that even possible? I'm basically trying to serialize a...

Get Enum List via GetType

Hello everybody I have code that gives a list of all possible values for any given enum i bound it pretty often to dropdownlists in my webpages now im trying to make a usercontrol which accepts the type name as a parameter, which in turn calls the code to create the value list as my sub expects a type parameter Shared Function EnumLis...

How to capture an Enum from an AnnotationValue in an Annotation Processor

I am trying to read the value of an enum in an annotation using an annotation processor and annotation mirror, but I am getting back null. I think this has to do with the AnnotationValue wrapping an Enum as a VariableElement. The doc for VariableElement#getConstantValue() says "Returns the value of this variable if this is a final field ...

Check if a C enum exists

How would I check that NSRegularExpressionSearch exists before using it? enum { NSCaseInsensitiveSearch = 1, NSLiteralSearch = 2, NSBackwardsSearch = 4, NSAnchoredSearch = 8, NSNumericSearch = 64, NSDiacriticInsensitiveSearch = 128, NSWidthInsensitiveSearch = 256, NSForcedOrderingSearch = 512, NSRegularExpressionSearch...

Converting enum to int

I have the following enum public enum TESTENUM { Value1 = 1, Value2 = 2 } I then want to use this to compare to an integer variable that I have, like this: if ( myValue == TESTENUM.Value1 ) { } But in order to do this test I have to cast the enum as follows (or presumably declare the integer as type enum): if ( myValue == ...

How to reuse enum operator overloads in C++?

I have several flag-like enumerations, in C++. For example: enum some_state { state_normal = 1 << 0, state_special = 1 << 1, state_somethingelse = 1 << 2, state_none = 0, }; some_state var1; Now on using bit operators like & or |, I get compilers errors. I know I can overload operator | et.al. for enums, ...

What's the best way to store a value from a list of pre-defined values in a database?

Let's say I have a pre-defined list of values (RW, FW, 4W) representing drive type of a vehicle: RW - Rear Wheel FW - Front Wheet 4W - Four Wheel Now, I want to take a value from the above 3 values as an input from my user and then store it in a database. Upto my knowledge, I can perform this with the help of any of the following me...

How to use Enum with strings in a function?

Basically, I have a Linked List which implements a display()function that simply loops throught he elements and prints out their values. I wanted to do it like this: void List::display( std::string type ) { switch(type) { // Do stuff... The compiler immediately complained. My teacher said this would be because the strin...

C#: Return enum value based on an enum value of a different enum type

So I want to have a property getter that returns an enum value based on an enum value of a different type without having to resort to a long switch statement. Is there a way to match up the two enum lists using an index or values? public enum LanguageName { Arabic, Chinese, Dutch, English, Far...

How to Bind Enum Types to the DropDownList ?

If have the following enum public enum EmployeeType { Manager = 1, TeamLeader, Senior, Junior } and i have DropDownList and i want to bind this enum to it .. is it any way to do that ? ...

How do I increment an enum in VS C++ 6.0?

I copy and pasted some code that increments an enum: myenum++; This code worked fine as it was compiled in VS.NET C++ 2003 I am now developing in VS 6.0 and get the error: error C2676: binary '++' : 'enum ID' does not define this operator or a conversion to a type acceptable to the predefined operator How can I get t...