How can I have an abstract enum, or some kind of base enum?
In my common code I'd like a notion of an enum placeholder, MyItems, without tying myself to a concrete enum. Then in each of my projects I would have a concrete implementation.
E.g.
Common Code
public interface MyItems {
// Marker interface
}
Project A
public enum I...
I want to iterate through the items in an enumeration.
I'd like to be able to say something like this:
type
TWeekdays = (wdMonday, wdTuesday, wdWednesday, wdThursday, wdFriday);
...
elementCount := GetElementCount(TypeInfo(TWeekDays));
for i := 0 to elementCount - 1 do begin
ShowMessage(GetEnumName(TypeInfo(TWeekdays),i));
end;
...
I would like to achieve something similar to how scala defines Map as both a predefined type and object. In Predef:
type Map[A, +B] = collection.immutable.Map[A, B]
val Map = collection.immutable.Map //object Map
However, I'd like to do this using Java enums (from a shared library). So for example, I'd have some global alias:
type Co...
Hi. Is there a way I could point an Enum to another Enum? Here are the needs and details:
Currently:
I have a two public classes com.abcd.MyManager and com.abcd.data.MyObject.
MyObject class have pretty much everything is private except Types enum member.
MyManager class uses MyObject class
Notice MyObject class lives in a separate n...
To allow for different formatting options on a method that displays a news story, I've created an enumeration that can be passed in to specify how it gets displayed.
[Flags]
private enum NewsStyle
{
Thumbnail = 0,
Date = 1,
Text = 2,
Link = 4,
All = 8
}
string FormatNews( DataRow news, NewsStyle style )
{
String...
I'm looking for a open source library or examples for working with Enum types in .Net. In addition to the standard extensions that people use for Enums (TypeParse, etc.), I need a way to perform operations like returning the value of the Description attribute for a given enumeration value or to return a enumeration value that has a Desc...
Hello there,
I have a number of enums in my application
which are used as property type in some classes.
What is the best way to store these values in database, as String or Int?
FYI, I will also be mapping these attribute types using fluent Nhibernate.
Sample code:
public enum ReportOutputFormat
{
DOCX,
PDF,
HTML
}
pub...
The below code makes it easy to pass in a set HtmlParserOptions and then check against a single option to see if it's been selected.
[Flags]
public enum HtmlParserOptions
{
NotifyOpeningTags = 1,
NotifyClosingTags = 2,
NotifyText = 4,
NotifyEmptyText = 8
}
private bool IsOptionSet(HtmlParserOptions options, HtmlParserOp...
Postgresql got enum support some time ago.
CREATE TYPE myenum AS ENUM (
'value1',
'value2',
);
How do I get all values specified in the enum with a query?
...
I'm working with java.awt.Color instances. Is there any way to do arithmetic operations on colors? Something like rgb(20, 20, 20) + rgb(10, 200, 170) = rgb(30, 220, 190)?
What I'm trying to do: I have a gui that features a table, where if the user clicks on a cell, the other cells change color based on their relationship to the selected...
I have a file with values like: START and STOP. I also have the following enum declared:
enum Type {
START,
STOP
};
I'm trying to set the enum equal to the first value in the file with something like this:
enum Type foo;
ifstream ifile;
ifile.open("input.txt");
ifile >> foo;
I'm getting the error: no match for ‘operator>>...
Is it possible to specialize a templatized method for enums?
Something like (the invalid code below):
template <typename T>
void f(T value);
template <>
void f<enum T>(T value);
In the case it's not possible, then supposing I have specializations for a number of types, like int, unsigned int, long long, unsigned long long, etc, then...
I'm trying to get an Action in Struts 2 to work with an Enum as an input parameter. What I've done so far looks like:
public TestAction {
public enum Module {
VALUE1;
}
private Module module;
public void setModule(Module module) {
this.module = module;
}
public Module getModule() {
return module;
}
}
But wh...
This feels like a really basic question, but I can't figure it out anyway..
How do I get the type of System.Windows.Visibility? I need to pass the type definition to a function. More precisly I'm writing unit tests for a IValueConverter I'm writing where the target type is a System.Windows.Visibility. What do I pass as target type when...
I need to emulate enum type in Javascript and approach seems pretty straight forward:
var MyEnum = {Left = 1; Right = 2; Top = 4; Bottom = 8}
Now, in C# I could combine those values like this:
MyEnum left_right = MyEnum.Left | MyEnum.Right
and then I can test if enum has certain value:
if (left_right && MyEnum.Left == MyEnum.Left)...
I've got the class object for an enum (I have a Class<? extends Enum>) and I need to get a list of the enumerated values represented by this enum. The values static function has what I need, but I'm not sure how to get access to it from the class object.
...
namespace ValueType {
enum Enum {
Boolean = 0,
Float = 1,
Double,
SInt = 8,
SLong,
UInt = SInt + (1 <<4),
ULong = SLong + (1 << 4)
};
}
...
I'm a veteran .NET developer making my first foray into Objective C programming. I'm having difficulty with a property of an enum type. Some context... I have an class header and enum like this:
typedef enum {
Open,
Unavailable,
Unknown
} LocationStatus;
@interface Location : NSObject {
LocationStatus status;
}
@pr...
Ideally I would like a following examples to work, but I guess some of it is not implementable in C++.
{
typedef StrongEnum<Red=0, Green=1, Blue=2> Color; // not a C++ syntax
Color c = Color::Red; // static const
Color d; //error: default constructor is private
Color d = c;
Color e = Color::OfInt(5); // ifdef DEBUG - Runti...
enum Answer : int { Yes = 1, No = 2 }
Answer answer = (Answer)100;
It throws, but I don't want it to. How?
...