I am working with Apple's ScriptingBridge framework, and have generated a header file for iTunes that contains several enums like this:
typedef enum {
iTunesESrcLibrary = 'kLib',
iTunesESrcIPod = 'kPod',
iTunesESrcAudioCD = 'kACD',
iTunesESrcMP3CD = 'kMCD',
iTunesESrcDevice = 'kDev',
iTunesESrcRadioTuner = 'kTun'...
Hi All,
If i declare an enum as follows:
typedef enum A
{
a = 0x00000001,
b = 0x00000002
} AObj;
Now if i declare a variable of AObj as follows what does this mean?
AObj myAObj : 2;
...
An associate has created a schema that uses an ENUM() column for the primary key on a lookup table. The table turns a product code "FB" into it's name "Foo Bar".
This primary key is then used as a foreign key elsewhere. And at the moment, the FK is also an ENUM().
I think this is not a good idea. This means that to join these two table...
If there was a base class DeriveMe that had a function virtual void DoSomething(int) and a class that inherits DeriveMe called DerivedThat that had a function void DoSomething(SomeEnum)...would the DerivedThat override the base class DoSomething because enums evaluate to ints during compile time in C++?
I could try this by making DoSome...
What is the best way to localize enumeration descriptions in .net?
(See Adding descriptions to enumeration constants for enum description example)
Ideally I would like something that uses ResourceManager and resource files so it fits in with how other areas of the app are localized.
...
Intersection types allow you to (kinda sorta) do enums that have an inheritance hierarchy. You can't inherit implementation, but you can delegate it to a helper class.
enum Foo1 implements Bar {}
enum Foo2 implements Bar {}
class HelperClass {
static <T extends Enum<T> & Bar> void fooBar(T the enum) {}
}
This is useful when you ha...
If I have the following enum:
public enum ReturnValue{
Success = 0,
FailReason1 = 1,
FailReason2 = 2
//Etc...
}
Can I avoid casting when I return, like this:
public static int main(string[] args){
return (int)ReturnValue.Success;
}
If not, why isn't an enum value treated as an int by default?
...
I'm trying to learn some Lisp (Common Lisp) lately, and I wonder if there is a way to give constant numbers a name just like you can do in C via enums.
I don't need the full featureset of enums. In the end I just want to have fast and readable code.
I've tried globals and little functions, but that always came with a degration in perf...
The syntax sugar provided by Java's enum facility can sometimes be a little confusing. Consider this example, which does not compile:
public enum TestEnum {
FOO("foo") {
public void foo() {
helper(); // <- compiler error
}
};
String name;
TestEnum(String name) {
this.name = name;
...
I have two flags:
[Flags]
enum Flags
{
A = 1,
B = 2
};
I set them like this:
Mode = Flags.A | Flags.B; // default value
for(int i = 0; i < args.Length; i++) {
switch(args[i])
{
case "--a":
{
if ((Mode & Flags.A) == Flags.A && (Mode & Flags.B) == Flags.B)
// both, default assume
{
Mode = Flags.A; // only A
...
Problem: I have an enumerated type which has description tags in the following style: [URL="http://xml.indelv.com/data-binding-enum.html"]description tag tutorial[/URL] . I have a Windows SQL Server Database from which I am pulling the data (as integers then castine to Enums) which is then being bound to a datagrid. Instead of pulling an...
Let's say I have a set of Countries in my application. I expect this data to change but not very often. In other words, I do not look at this set as an operational data (I would not provide CRUD operations for Country, for example).
That said I have to store this data somewhere. I see two ways to do that:
Database driven. Create and p...
I have 2 files which are interacting with each other. I wanted to define an enum to make the code more readable, but if I define it in file 1, file 2 complains about having no knowledge of said enum. If I define ii in file 2, file 1 does the same. I am defining it as public too.
The solution was to define the enum in both files, but th...
Hi I have a Java enum and I want serialize a variable containing an enum value back and forth from XML for persistence. My enum is defined like this...
public enum e_Type
{
e_Unknown,
e_Categoric,
e_Numeric
}
My variable is declared like this...
private e_Type type;
I want it to go into an XML tag like this...
<type>value</typ...
I saw some .NET 2.0 code which looked like this:
public enum abc : int
{
value1 = 1,
value2 = 2,
value3 = 4
}
etc...
Now I know the flags enum can be used for bit values (like above, right?) so you can do | "or" &, etc, but what is the reason for not using that? What is the point in overriding int?
If I design an enum for c...
I have a simple .Net enum. I also have a view model object which has a "CurrentValue" property of the type of my enum. This property can be data-bound (the object implements INotifyPropertyChanged). Now I'd like to show one UI element for each value of the enum, in a specific order, and have the "CurrentValue" highlighted (bold). I would...
Say I have an enum which is just
public enum Blah {
A, B , C, D
}
and I would like to find the enum value of a string of for example "A" which would be Blah.A. How would it be possible to do this?
Is the Enum.ValueOf() the method I need? If so, how would I use this?
...
We are using NHibernate, and one of the common patterns we have for storing enum-like information is to define separate tables for the enum, and just make a reference to the ID in the main entity/table that uses the enum. A simple example:
Message
-------
ID (bigint PK)
MessageTypeID (bigint FK)
Body (varchar)
MessageType
-----------
...
I have a data object (let's say it's called 'Entry') that has a set of potential states that look something like this:
1 - Created
2 - File added
3 - Approved
4 - Invalid
This is represented in the database with a 'Status' table with an autonumber primary key, then a 'StatusId' field in the main table, with the appropriate relationship...
Check out this quote from here, towards the bottom of the page. (I believe the quoted comment about consts apply to invariants as well)
Enumerations differ from consts in that they do not consume any space
in the final outputted object/library/executable, whereas consts do.
So apparently value1 will bloat the executable, while va...