enum

Unable to find enum descriptor PBFieldDescriptorProto_Label while unit testing

匿名 (未验证) 提交于 2019-12-03 08:57:35
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: After adding the GoogleCast framework to the unit test target I'm getting the following exception right before the tests start to run. Apart from that the SDK is fully functional. I'd appreciate any ideas! 2014-02-25 18:03:08.475 otest[3786:303] Unknown Device Type. Using UIUserInterfaceIdiomPhone based on screen size 2014-02-25 18:03:08.593 otest[3786:303] *** Assertion failure in -[GCKPB_PBFieldDescriptor initWithFieldDescription:rootClass:], /Volumes/BuildData/pulse-data/agents/wpye22.hot/recipes/415961027/base/googlemac/iPhone/Chromecast

scala: add methods to an enum

匿名 (未验证) 提交于 2019-12-03 08:54:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a simple enum like this: object ConditionOperator extends Enumeration { val Equal = Value ( "equal" ) val NotEqual = Value ( "notEqual" ) val GreaterOrEqual = Value ( "greaterOrEqual" ) val Greater = Value ( "greater" ) val LessOrEqual = Value ( "lessOrEqual" ) val Less = Value ( "less" ) And I'd like to add a method to each enum so that I can use it like this: def buildSqlCondition ( field : String , operator : ConditionOperator . Value , value : String ) = { val sqlOperator = operator . toSql [...] So, ConditionOperator

C++ string to enum

匿名 (未验证) 提交于 2019-12-03 08:52:47
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is there a simple way in C++ to convert a string to an enum (similar to Enum.Parse in C#)? A switch statement would be very long, so I was wondering if there is a simpler way to do this? EDIT: Thanks for all of your replies. I realized that there was a much simpler way to do it for my particular case. The strings always contained the charater 'S' followed by some number so i just did int i = atoi(myStr.c_str() + 1); and then did a switch on i. 回答1: A std::map (or unordered_map ) could do it easily. Populating the map would be just as tedious

Automapper enum to Enumeration Class

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to use Automapper to map from a regular enum to an Enumeration Class (as described by Jimmy Bogard - http://lostechies.com/jimmybogard/2008/08/12/enumeration-classes/ ). The regular enum doesn't have the same values as the enumeration class does. I would therefore like to map using the Name if possible: Enum: public enum ProductType { ProductType1, ProductType2 } Enumeration Class: public class ProductType : Enumeration { public static ProductType ProductType1 = new ProductType(8, "Product Type 1"); public static ProductType

Enum addition vs subtraction and casting

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Why does addition require a cast but subtraction works without a cast? See the code below to understand what I am asking public enum Stuff { A = 1, B = 2, C = 3 } var resultSub = Stuff.A - Stuff.B; // Compiles var resultAdd = Stuff.A + Stuff.B; // Does not compile var resultAdd2 = (int)Stuff.A + Stuff.B; // Compiles note: For both addition and subtraction it does not matter whether result is out of range (of the enum) or not in all three examples above. 回答1: Good question - I was surprised that the first and third lines worked. However, they

How to change enum definition without impacting clients using it in C#

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have the following enum defined. I have used underscores as this enum is used in logging and i don't want to incur the overhead of reflection by using custom attribute.We use very heavy logging. Now requirement is to change "LoginFailed_InvalidAttempt1" to "LoginFailed Attempt1". If i change this enum, i will have to change its value across application. I can replace underscore by a space inside logging SP. Is there any way by which i can change this without affecting whole application.Please suggest. public enum ActionType { None, Created

List Enum values in dropdown php mysql

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a mysql table which contains following cols. Id Name Sex and sex column have type of enum('Male','Female','Unspecified') How can i list enum values in a dropdown and make current stored value as selected 回答1: Check this link...its pretty awesome..the script is reusable for any enum column: http://jadendreamer.wordpress.com/2011/03/16/php-tutorial-put-mysql-enum-values-into-drop-down-select-box/ 回答2: The fact that it is an enum field doesn't matter much when creating the select (dropdown) fields. Enum fields behave the same

Generic Method With Bounded Extends Enum Parameter - Cannot Access values() method

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I would like to write a generic method that takes a bounded parameter that extends Enum. For example, if I have an Enum as follows: public enum InputFlags{ ONE (0000001), TWO (0000002), THREE (00000004); public final int value; InputFlags(int value){ this.value = value; } } I can then do the following: for (InputFlags ifg : InputFlags.values()){ // Do something with ifg } However if I try to do the above in a generic method whose return parameter is bounded, I cannot access the values() method: public static <T extends Enum> T getFlags(int f

Java: enum values() and valueOf(String)

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Why does javac add values() and valueOf(String) methods to the enum type being defined? Wouldn't it have been better that they were added to Enum class itself? What I mean is, if I have some enum such as enum FooEnum {ONE, TWO} javac adds values() and valueOf(String) to FooEnum when compiling it. I find it a bit odd. What is the reason behind this? Is it only to ensure type safety of the returned value/values or is there anything else? And if it's for type safety alone, wouldn't Generics have helped? 回答1: They're static methods - how could

How do I convert a “Keys” enum value to an “int” character in C#?

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This seems like something that should be easy, but I am having a tough time figuring out what needs to happen here. In the "KeyDown" eventhandler, if the "e.KeyValue" is a number, I want to treat it as a number and store it as an int. So, if I hit "8" on the number pad, I don't want "Numpad8" I want the int value 8 that I can add or subtract or whatever. So, how do I convert from the KeyValue to an int? 回答1: I'd go with this solution: int value = -1; if (e.KeyValue >= ((int) Keys.NumPad0) && e.KeyValue <= ((int) Keys.NumPad9)) { // numpad