enums

WPF Binding a ListBox to an enum, displaying the Description Attribute.

Is it possible to use the ObjectDataProvider method to bind a ListBox to an enum, and style it somehow to display the Description attriibute? If so how would one go about doing this...? ...

typedef for enum from template base class

Followup on an answer from last night - I was hoping more comments would answer this for me but no dice. Is there a way to achieve this without inheritance that does not require the cumbersome usage in the penultimate line of code below, which writes the value to cout? struct A { enum E { X, Y, Z }; }; template <class ...

Storing integer values as constants in Enum manner in java

Hi, I'm currently creating integer constants in the following manner. public class Constants { public static int SIGN_CREATE=0; public static int SIGN_CREATE=1; public static int HOME_SCREEN=2; public static int REGISTER_SCREEN=3; } When i try to do this in enum manner public enum PAGE{SIGN_CREATE,SIGN_CREATE,HOME_SCREEN,REGISTER_SC...

Enum with 64 bit underlying integer

I'm using gcc, which implements enums as 32 bit integers on the architecture I have (don't know in general). If I try to assign an enum value too large, I get warning: integer overflow in expression Is there a way to make gcc use 64 bit integers as the underlying integer type? A gcc specific way is fine, although if there's a portabl...

How to manually specify an integer value bound to a particular enumeration value in Scala?

How to manually specify an integer value bound to a particular enumeration value in Scala? ...

Enum and Generic constant specific method

I have an enum like: enum TEST { TEST1, TEST 2; public abstract <T> String stringify (T input); } I need to add a constant specific method , something like stringify. This method will take different types of inputs (for each enum). Can I do that? Eclipse is not letting me do it ..something like: enum TEST { ...

Keeping enums sorted in an arraylist?

Say I had a an enum called Planets that contained VENUS, EARTH, and MARS. I will have a lot of array lists that will hold at most one of each type. I want to keep each array list sorted at all times in order from VENUS, EARTH, and MARS. Would I need to use a comparator for this? Is there a way to keep them sorted automatically after an ...

passing enums by ref in java

How can i pass enum parameter by reference in java? Any solution? ...

How to match compiled class name to an enum member in Java?

In Java, with Sun's JDK 1.6, with an enum such as this: public enum MyEnum { FIRST_MEMBER { public void foo() { } }, SECOND_MEMBER { public void foo() { } }, THIRD_MEMBER { public void foo() { } }; } The compiled files are: MyEnum$1.class MyEnum$2.class MyEnum$3.class MyEnum.class This also means that a stack tra...

Why use the Bitwise-Shift operator for values in a C enum definition?

Apple sometimes uses the Bitwise-Shift operator in their enum definitions. For example, in the CGDirectDisplay.h file which is part of Core Graphics: enum { kCGDisplayBeginConfigurationFlag = (1 << 0), kCGDisplayMovedFlag = (1 << 1), kCGDisplaySetMainFlag = (1 << 2), kCGDisplaySetModeFlag = (1 << 3), ...

How to detect a new value was added to an enum and is not handled in a switch

From time to time I have to add a new value to a enum type in my project. public enum Day { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, FILENOTFOUND //this one is new one } What I would like is to have a compile time error for every switch I have that is not treating the new value, like this one: switch (col...

How can I mimic a multi-tiered menuing system using Java enums?

I need to accomplish the following (this is a simplified version): enum Animals{ enum Cats{tabby("some value"), siamese("some value")}, enum Dogs{poodle("some value"), dachsund("some value")}, enum Birds{canary("some value"), parrot("some value")} private String someValue = ""; private ShopByCategory(String someValue) { th...

Switch on enum in JNI?

Given: enum Foo { FIRST, SECOND } What is the JNI equivalent for the following code? Foo foo = ...; int value; switch (foo) { case FIRST: value = 1; break; case SECOND: value = 2; break; } I know I can use foo.equals(Foo.FIRST) from JNI, but I'd like to get the same performance as switch(enum). Any ideas? ...

C++ enum data structure

Can someone give me a real time need for enum data structure. As in example in some real system where it can be used? And what is the reason for having such a data structure. The example given was enum colors_t {black, blue, green, cyan, red, purple, yellow, white}; But i felt, this is similar to string array. I am trying to underst...

Using enumerations

Hello, I can't understand one problem: Types.hpp: enum SomeEnum { one, two, three }; First.hpp: #include "Types.hpp" class First { public: void someFunc(SomeEnum type) { /* ... */ } }; Second.hpp: #include "Types.hpp" #include "First.hpp" class Second { public: void Foo() { First obj; obj.someFunc(two); // tw...

Can't overload << for Enum in C++

I have created an enumerated data type to define possible flight lengths. I'd like to overload its << operator so the representation is nicer. When I compile this, I get the following error (posted for completeness' sake. Basically multiple definitions of operator <<(ostream&, Categoria&)): g++ -oProjectoAEDA.exe src\voo.o src\tui.o sr...

Enum.valueOf(Class<T> enumType, String name) question

I am trying to get around a compile error ("Bound mismatch: ...") relating to dynamic enum lookup. Basically I want to achieve something like this: String enumName = whatever.getEnumName(); Class<? extends Enum<?>> enumClass = whatever.getEnumClass(); Enum<?> enumValue = Enum.valueOf(enumClass, enumName); Whatever I do, I always end ...

Retrieve Collections and Enums Selected Value WPF Property Grid

Hi All, I am using WPF PropertyGrid (http://www.codeplex.com/wpg) in my project. But i have some problems with this component. 1) I can show my IList collections in a ComboBox. But i can't retrieve selected value. How can i get selected value? 2) Enums are automatically shown in combobox, but i can't retrieve selected value like #1. ...

Enum array from string with delimiter

Hi, I want to give something back - found lots of answers here! The problem is to convert a string (eg. "AA_BB_CC") into an array of enums using a specified enum class. public static <T extends Enum<T>> T[] getEnumArrayFromString( final Class<T> enumType, final String codeStr, final String delimiter){ if(enumType == nul...

Is it possible to use a enum like UITableViewCellStyle as parameter of a method?

I want to have a enum as a parameter of my function. Would this work? (UIFont*) myMethodName:(UITableViewCellStyle) cellStyle { //... if (cellStyle == UITableViewCellStyleValue2) // ... } Then I would call the method like this way UIFont *resultFont = [self myMethodName:UITableViewCellStyleSubtitle]; Only the follow...