Skip to main content
Filter by
Sorted by
Tagged with
-2 votes
1 answer
30 views

What is the best way to implement named colors in Rust? [closed]

(I'm a Rust newbie coming from a strong C/C++/Java background.) I was hoping to be able to do something like: struct MyColor { Red : u8, Green : u8, Blue : u9, } #[repr(MyColor)] enum ...
David Elrod's user avatar
-2 votes
0 answers
40 views

Enums in C# to be created from lookup table in sql [closed]

In my project there is an ENUM defined which has around 240 values and we need to keep updating the values if there is any change. This requires deployment of entire application which is causing a lot ...
Naveed Qureshi's user avatar
1 vote
1 answer
24 views

How can I write an alias of an enum in TypeScript

I am refactoring a large codebase, which contained this definition: export const enum Direction { NORTH, SOUTH, } and much code like this: console.log(Direction.NORTH); The new definition is ...
user27357906's user avatar
3 votes
1 answer
42 views

In Kotlin, how to declare a class with Enum property?

I'm creating a Kotlin structure that I intend to reuse in several Android games with a similar format: a single grid with multiple cells. Depending on the game, the cells will have a different set of ...
gotube's user avatar
  • 741
0 votes
0 answers
69 views

Convert C++ typesafe enum to C# enum using swig

I have a library with typesafe enums in the following form: struct MyEnum { enum Value { One, Two, Three }; MyEnum() : value(-1) {} MyEnum(Value v) : value(v) {} Value value; }; And I want ...
kjoel's user avatar
  • 1
0 votes
0 answers
19 views

How do I use ValidationAttribute or IModelBinder to ensure that an enum property exists in the JSON body and has a valid value?

Given a model that looks like this: public enum Types { Emergency, Notice, Event } public class Message { public Types Type { get; set; } public string Title { get; set; } } And ...
SiBrit's user avatar
  • 1,490
-2 votes
1 answer
145 views

How to iterate over an enumeration with a ranged-for loop [duplicate]

#define DEFINE_ENUM_CLASS(Name, ...) \ enum class Name { __VA_ARGS__ }; \ constexpr const char* Name##Strings[] = { #__VA_ARGS__ }; int main() { DEFINE_ENUM_CLASS(Color, Red, Green, Blue); ...
sick nasty's user avatar
-1 votes
0 answers
75 views

How to add enums into a set in modern C++?

I am working with about 10 different numbers that are constant and represent product ids and would like to find the fastest and most readable way to represent the semantics of the products without ...
heretoinfinity's user avatar
0 votes
1 answer
31 views

How to initialize a colour from a raw value in swiftUI

The below code when initialized with a raw value returns NamedColor(name: "colorName" bundle:nil) with colourName being the name of the case in the enum and the raw value being passed in ...
Josh Totten's user avatar
-1 votes
1 answer
48 views

Proper way to utilize python's "enums" as flags in an easily entendable manner

I'm picking back up an old personal project involving a dice calculator for TTRPGs like DnD. I'm looking to use a python Enum object as a means of pre-defining several common roll distributions, such ...
Minty's user avatar
  • 53
2 votes
2 answers
60 views

Accessing an enum value in a nested templated class in C++03

I have the unfortunate task in 2024 of adding some code to a codebase that needs to be used in a C++03 setting - where unfortunately the original class myclass can't be changed. I've gotten stuck on ...
Penny Dreudter's user avatar
-1 votes
1 answer
52 views

Generate chained like string with enums and struct

I'm experimenting with proc-macro, the goal is that I can chain functions like a struct that contain fields of enums, Look at the test, the response will be permission::auth::moderator::execute::...
FatihAziz's user avatar
  • 454
0 votes
1 answer
31 views

Storing the value of a PdfSharpCore (XPen) enumeration

I'm pretty sure that I'm just missing something simple with this and am going to smack my forehead when someone answers but the dent in my desk is getting pretty large at this point. I'm tasked with ...
C. Michael Warden's user avatar
-1 votes
1 answer
29 views

postgres enum hibernate 6 takes wrong type name

Here is my setup: spring boot 3 + hibernate 6 + postgres 15 I have an entity with field that is enum: @Slf4j @Getter @Setter @Entity @Table(name = "foo") public class FooEntity { @...
k31's user avatar
  • 51
2 votes
2 answers
121 views

How can a member of an enum be of the same type as the enum itself?

Internally enums seem to be a pair of arrays, one of strings for the names and the other usually of ints. When I select a specific enum member and pass it into a method (i.e. NflTeams.Raiders) I would ...
TakingTheHobbitsToIsengard's user avatar
-1 votes
1 answer
63 views

How could I loop through a list of strings and use each string to pull an Enum?

I'm not even remotely sure how to phrase this question, so hopefully the wording wasn't too unintelligible. I'm making a game where the dialogue box can pull each character sprite through an enum ...
carrigan__'s user avatar
1 vote
1 answer
59 views

Should Polars Enum Datatype Result in More Efficient Storage and Memory Footprint of DataFrame?

I have this dataframe in Python Polars having dimensions (8442x7), basically, 1206 rows for each day of the week. The day of week appears as a simple string. Thought I would exploit the pl.Enum to ...
Della's user avatar
  • 1,572
-2 votes
1 answer
38 views

How can I update enum type with a function in swift?

I have an enum which I want toggle it. with a code like this which is accessible from enum type itself, I tried using this code but did not solved the issue: enum MyEnum { case yes case no ...
swiftPunk's user avatar
  • 16.5k
0 votes
1 answer
57 views

finding max from Vec<Enum> - using reduce()?

I'm sure there is a better way to do this, but I do not know how to extract structure from Enum during reduce(). Assume ALL enums are identical in vector (but prob. solution needs to handle if this is ...
Igor Lautar's user avatar
3 votes
1 answer
91 views

How can I override the default behavior of `list(MyEnum)`?

I have a custom enum, MyEnum, with some elements that have different names but the same value. from enum import Enum class MyEnum(Enum): A = 1 B = 2 C = 3 D = 1 # Same value as A ...
the.real.gruycho's user avatar
0 votes
0 answers
53 views

String Deserializes to null instead of Enum in Java Record [duplicate]

I'm trying to deserialize an enum from a json list. Here is my enum public enum ContactType { FAX, EMAIL, SOCIAL_MEDIA, WEBSITE, ADDRESS, PHONE } I have a ContactInfo ...
clattenburg cake's user avatar
0 votes
1 answer
55 views

C# Xml Deserialization of null Enum values [duplicate]

I wonder if someone can help with the following. I'm looking into an issue that we have discovered in our codebase. We have an model in C# that's been generated from an xsd and within the resultant ...
Tim Butterfield's user avatar
0 votes
1 answer
39 views

Matching a single enum variant in a test, not interested in other other matches

pub enum State { Started(Vec<Id>), InProgress, Terminated } pub trait Locker { async fn start(&mut self, id: Id) -> State; } #[tokio::test] async fn test_locker() { let ...
unsafe_where_true's user avatar
0 votes
0 answers
42 views

Difference of Enums in python

I was exploring different fields in Tortoise ORM and found out about CharEnumField which accepts a string enum for it to work. In the docs author used this class: class Currency(str, Enum): HUF = &...
Andrew's user avatar
  • 115
1 vote
1 answer
29 views

How to solve error "Constructor cannot be applied to the specified types", when using jooq custom EnumConverter

I created a custom EnumConverter so that instead of the Enum ordinal the customized value typeId is saved in the database: public class CustomAntragTypEnumConverter extends EnumConverter<Integer, ...
Isa dBC's user avatar
  • 13
1 vote
2 answers
70 views

kotlin get enum value by it's generic type in case it is enum

I'm working on a task to create an API to application string properties which can be represented as Enum, Int, String and probably some more types. So I tried to write kind of this class: object ...
mr.nothing's user avatar
  • 5,379
0 votes
0 answers
168 views

Using an enum to allow for a class instance to be using as a Generic Value

I noticed mypy will not raise an error when you provide a class instance for a generic type if you set the instance to an enum value first. At times it would be useful to provide a literal class ...
Rob's user avatar
  • 3,457
0 votes
1 answer
85 views

Getting "undeclared attribute type for enum, Enums must be backed by a database column" error, but the enum ~is~ backed by a database column

Can anyone see what I'm doing wrong here? Rails 7.2.0. I am getting this error on #status and #billing_status attributes when running any test related to the Tournament model: RuntimeError: Undeclared ...
Yardboy's user avatar
  • 2,785
-2 votes
1 answer
47 views

Python code working on windows doesn't work properly on Debian RetroPi

I have coded a discord bot using my Windows 11 computer, with python 3.12.3. Searching for a hosting way, a friend shared me her private server running RetroPi project. When running my code on my ...
Daeltam's user avatar
2 votes
3 answers
57 views

Matching a string input against a Python enum

I'm want to do a basic case-insensitive match against some set of strings, as in the following code: class Fruit(Enum): APPLE = "Apple" ORANGE = "Orange" BANANA = "...
Alex Eustis's user avatar
2 votes
1 answer
48 views

Serialising JSON consts as enums into C#

I am writing a C# program to import JSON data in the form of this JSON schema. The authors of this schema have chosen to implement some enumeration types as anyOf arrays of objects with const string ...
Jamie Kitson's user avatar
  • 4,133
0 votes
3 answers
130 views

Convert enum to string and back in dart

Is there any way to convert a enum to a string and back, without knowing the specific enum. The enums also share a mixin. For example: mixin TestMixin { String get value; } enum FirstEnum with ...
Flojomojo's user avatar
1 vote
1 answer
41 views

Enum related error when updating from Angular v15 to v16

I recently updated from Angular 15 to 16 and some pages don't seem to load up at all. The error I'm getting is "Uncaught Error: Uncaught (in promise): ReferenceError: Cannot access 'HomeModule' ...
LeoDiCap235's user avatar
0 votes
0 answers
46 views

How to use Enum with mapped_column in SqlAlchemy

I'm having trouble defining my models with SQLAlchemy, especially when it comes to defining columns of the Enum type. from enum import Enum from sqlalchemy import Column, DateTime, ForeignKey, Integer,...
Corentin Kittel's user avatar
2 votes
2 answers
68 views

How can a Python enum accept any value without raising ValueError

Suppose I am implementing a network service that receives commands. I want to have an enumeration of these commands, so I can write something like: class Command(enum.Enum): ECHO = 0x01 LOGIN =...
rgov's user avatar
  • 4,161
1 vote
1 answer
45 views

Use java enum in graphql schema with different values

I have java enum public enum JavaStatus{ ACTIVE, PAUSED, STOPPPED; } I want to send and receive this enum through graphql with lowercase values. And frontend should be able to load graphl schema to ...
DanR's user avatar
  • 13
0 votes
0 answers
8 views

How do I give role based access control to the users for a hospital management system using enum in python?

I am new to python programming and I need to write a python code for giving access controls to the users based on their roles like doctors, nurses, staffs, managers, etc. using enum implementation. I ...
Prabin Maharjan's user avatar
0 votes
2 answers
76 views

Reference enum members in XAML elements

I want to make a ComboBox whose elements are a subset of the members of an enum type. If I once knew the syntax for this, I can't remember it now! I'm basically looking for the markup equivalent of ...
Jonathan Gilbert's user avatar
2 votes
2 answers
78 views

How to implement Enum with mutable members, comparable and hashable by their index

I am writing a class to represent sequential stages of an industrial process, composed of ADMISSION, PROCESSING, QC and DELIVERY stages. Each stage has a unique, progressive sequence number, a ...
Afelium's user avatar
  • 65
0 votes
0 answers
52 views

Scala enum not working with rdd map function in Spark

When I try to use enum in custom mapping function in Scala it throws the following error Caused by: java.lang.NoSuchFieldException: MODULE$ at java.lang.Class.getField(Class.java:1703) at scala....
Utkarsh Goel's user avatar
1 vote
1 answer
58 views

FastAPI - Pydantic model does not allow space in value of string Enum value?

python 3.12.5 pydantic 2.8.2 fastapi 0.111.1 Running in a docker container on WSL2 Ubuntu 22.04 LTS. Here is the model class definition: from enum import Enum from app.models.common.base import ...
H.Sheng's user avatar
  • 397
-1 votes
2 answers
99 views

How can I test for an invalid enum type in a switch case?

I'm facing an issue where all the enum values are implemented in the switch statement, and I'm unable to force an UnsupportedOperationException to be thrown. I've read several articles, but nothing ...
Eduardo Lopes's user avatar
0 votes
1 answer
50 views

How to specify type for keys of type of enum in Typescript?

I have enum and type export enum MyPerfectEnum { self = 'self', first = 'first', prev = 'prev', next = 'next', last = 'last' } export type MyPerfectType = { [key in ...
Maksym Tymofeiev's user avatar
-1 votes
2 answers
51 views

Enum reference variable to show as output in a table in java

I have a Enum class named Status. I have a table of "servers" that I would like to show the Status of them in the table output. When I run a while loop, and perform a result set, it does not ...
user24637246's user avatar
0 votes
2 answers
80 views

ConvertIng an element of enum class type into its matching string

I have an enum class, I'm trying to create a function that will return a string of its matching enum class member. For example if I have the following enum class: enum class SignalState { red, ...
tadm123's user avatar
  • 8,734
0 votes
1 answer
60 views

How to query a GORM Domain with a hasMany enum relationship to find entries containing only specific Enum values?

I'm working with a Grails application where I have a domain class that has a hasMany relationship with an enum. Here’s a simplified version of the code: class Domain { static hasMany = [ ...
Ev0oD's user avatar
  • 1,791
0 votes
2 answers
46 views

Can a same enum be used for multiple properties in a dto in the nestjs?

In Nestjs I'm using a DTO whose properties have the same set of values, so decided to use the same enum for both. But I was informed that using same enum for multiple properties is incorrect. I have ...
Udayaprakash's user avatar
0 votes
1 answer
71 views

How to make CloudKit compatible when you have enum driven selectable list

For a book club app I'm writing In SwiftUI, I have a NavigationSplitView that has a selectable List on its leading column. The first item on the list is "Book" and will take the user to a ...
Ser Pounce's user avatar
  • 14.5k
2 votes
2 answers
67 views

C enum implementing from_str and to_str functions? - Maybe an X-macro?

Given trivial typedef-free ANSI C code, how does one implement an X-macro to define everything in one place? enum Foo { CAN, BAR, UNKNOWN }; const char *Foo_to_str(enum Foo foo) { switch (foo)...
A T's user avatar
  • 13.7k
0 votes
0 answers
12 views

i keep geting error: use of enum 'Motions' without previous declaration

It works fine on the Arduino IDE, but always returns an error on TinkerCad, where i am required to submit my task. I tried changing the return type of the functions, as always, compiles on the Arduino ...
Mina Salama's user avatar

1
2 3 4 5
455