enums

How to base class behaviors on typedef enums, the way Apple does in Objective-C?

Kind of a weird newbie question...I want to use typedef enum declarations in one of my classes . This particular class gets used by other classes, where a client class might say something like "set your style to Style1 (enumerated type)". Then the target class's behavior would change accordingly. This is analogous to the way that UITa...

Mapping enum with fluent nhibernate

I am following the http://wiki.fluentnhibernate.org/Getting%5Fstarted tutorial to create my first NHibernate project with Fluent NHibernate I have 2 tables 1) Account with fields Id AccountHolderName AccountTypeId 2) AccountType with fields Id AccountTypeName Right now the account types can be Savings or Current So the table Acco...

GridView - Sorting Enum in Alphabetical Order

When sorting on a column in the GridView bound to an Enum, it sorts by the order of the Enum. I need it to sort by the string representation of the Enum. Here are the options I have seen, of which I like none of them. Reorder the Enum in alphabetical order - Bad because now the presentation is relying on the Business and Data Access ...

DataTrigger on Enums as the trigger value on a WPF Style

So here's what I'm trying to do in a little nutshell, I'm just gonna start with code and it will most likely make sense. <bl:InnerGlowBorder x:Name="glow" InnerGlowColor="Teal"> <bl:InnerGlowBorder.Style> <Style TargetType="bl:InnerGlowBorder"> <Style.Triggers> <Da...

how to save enum value to session

I'm creating enum property. This property should saved into session. My code is here public enum TPageMode { Edit=1,View=2,Custom=3} protected TPageMode Mode { get{ if (Session["Mode"] == null) return TPageMode.Edit; else { retur...

how to make java enum elements configurable

hello guys i'm not sure if the title is descriptive enough.what i mean is creating an enum like so public enum Test{ ONE, TWO ,THREE } this looks like hard coded.if for some reason i need to add the FOUR some certain business rules evolution reasons.should i code it and deploy it again? isn't a way to let it pick the elements from ...

Enumerated Type Value Not Comparing Correctly

Hello. I'm writing some C code for an embedded application, and I've run into a problem wherein a compare against an enumerated value is not being executed correctly. Take the following code snippet, for example: typedef unsigned int UINT16; typedef enum enum_items_tag { ITEM_1, ITEM_2, ITEM_3, /* ... */ ITEM_918, ...

How do I add more members to my ENUM-type column in MySQL?

The MySQL reference manual does not provide a clearcut example on how to do this. I have an ENUM-type column of country names that I need to add more countries to. What is the correct MySQL syntax to achieve this? Here's my attempt: ALTER TABLE carmake CHANGE country country ENUM('Sweden','Malaysia'); The error I get is: ERROR 1265 ...

one method classes with enum in java

I have an enum that looks like public enum MyEnum { myValue { @Override public String myMethod(String dostuff) { return dostuff + "One"; } }, myOtherValue { @Override public String myMethod(String dostuff) { return dostuff + "Two"; } }, aThirdValue { @Override public St...

Enum declared outside class scope

I went to this interview for a software developer position and they gave me a test with some corner-case-code situations, with usually 4 options to choose. One of the questions had an enum declared outside the class scope, I promptly checked the "does not compile" answer and went ahead with the other questions. It was something like: en...

Java Enums: Two enum types, each containing references to each other?

Is there a way to get around the class-loading issues caused by having two enums that reference each other? I have two sets of enumerations, Foo and Bar, defined like so: public class EnumTest { public enum Foo { A(Bar.Alpha), B(Bar.Delta), C(Bar.Alpha); private Foo(Bar b) { this.b = b; } public final...

javac complains: cannot find symbol on enum implementing interface

I have three java types as defined below: Main.java: import java.util.Arrays; import java.util.List; public class Main { private Object callFunction() { OperationDefinitions func = OperationDefinitions.CONCATENATE; List<Object> values = Arrays.asList(new Object[] {"ABC", "-", "DEF"}); return func.call (values)...

Check valid enum values before using enum

I'm trying to lookup against an Enum set, knowing that there will often be a non-match which throws an exception: I would like to check the value exists before performing the lookup to avoid the exceptions. My enum looks something like this: public enum Fruit { APPLE("apple"), ORANGE("orange"); ; private final String fruitname...

How can you handle invalid enum types using JAXB?

We are using JAXB to handle our wsdl validation. In the wsdl we have an enumeration like so: <xs:simpleType name="myEnum"> <xs:annotation> <xs:documentation>The enums which matter.</xs:documentation> </xs:annotation> <xs:restriction base="xs:string"> <xs:enumeration value="MYENUM_1"> <xs:annotatio...

#defined bitflags and enums - peaceful coexistence in "c"

I have just discovered the joy of bitflags. I have several questions related to "best-practices" regarding the use of bitflags in C. I learned everything from various examples I found on the web but still have questions. In order to save space, I am using a single 32bit integer field in a struct (A->flag) to represent several different ...

model classes in a database with my own enum types

Hi, I have an application that I need to query lifetables (for insurance calculation). I was thinking about using XML to store the data, but thought it was a little big, but maybe a little small for using a full-fledged database. So I chose to use SQLite. In my application, I have enums defining a few different things. For example, GEN...

Multiple output operators?

Hi, is it possible to define multiple output operators for an enum? I want to use this std::ostream& operator<< (std::ostream& os, my_enum e); operator to (1) print a human readable text and to (2) convert it to some code for storing in a database. Thanks ...

Creating a dynamic enum and attempting to reference it fail with BindingFailure

I need to create a dynamic enum and then be able to get the type using Type.GetType(). Is this possible? The below code will create a dynamic enum, and attempt to use it's qualifying name. This is fine if I first store the assembly (using AssemblyBuilderAccess.RunAndSave). However, this is not possible if I'm solely using AssemblyBuilde...

How to work with Enums in Entity Framework?

What is the best way to work with Enums in Entity Framework? Remarks: I'm using EF 3 againts Firebird. ...

How can I extend a lexical cast to support enumerated types?

I have the following function that will convert a string into a numeric data type: template <typename T> bool ConvertString(const std::string& theString, T& theResult) { std::istringstream iss(theString); return !(iss >> theResult).fail(); } This does not work for enumerated types, however, so I have done something like this: ...