Difference between revisions of "Documentation/DevGuide/AppendixA/Enums"
OOoWikiBot (talk | contribs) m (Robot: Changing Category:Documentation/Developers Guide/Appendix) |
|||
(One intermediate revision by one other user not shown) | |||
Line 5: | Line 5: | ||
|NextPage=Documentation/DevGuide/AppendixA/Typedefs | |NextPage=Documentation/DevGuide/AppendixA/Typedefs | ||
}} | }} | ||
− | {{DISPLAYTITLE:Enums}} | + | {{Documentation/DevGuideLanguages|Documentation/DevGuide/AppendixA/{{SUBPAGENAME}}}} |
+ | {{DISPLAYTITLE:Enums}} | ||
Enums are non-arbitrary sets of identifying values. If an interface uses an enum type, all implementations have to implement all specified enum values. It is possible to specify exceptions at the interface. Extending enums is not allowed, because this would cause incompatibilities. | Enums are non-arbitrary sets of identifying values. If an interface uses an enum type, all implementations have to implement all specified enum values. It is possible to specify exceptions at the interface. Extending enums is not allowed, because this would cause incompatibilities. | ||
Line 13: | Line 14: | ||
Enum values are completely capitalized in uppercase and words are separated by underscores. Do not use a variant of the enum type name as a prefix for the values, because some language bindings will do that automatically. | Enum values are completely capitalized in uppercase and words are separated by underscores. Do not use a variant of the enum type name as a prefix for the values, because some language bindings will do that automatically. | ||
− | < | + | <syntaxhighlight lang="idl"> |
enum FooBarType | enum FooBarType | ||
{ | { | ||
Line 27: | Line 28: | ||
string FileName | string FileName | ||
}; | }; | ||
− | </ | + | </syntaxhighlight> |
Three typical endings of special enum values are <code>_NONE</code>, <code>_ALL</code> and <code>_USER_DEFINED</code>. | Three typical endings of special enum values are <code>_NONE</code>, <code>_ALL</code> and <code>_USER_DEFINED</code>. | ||
Latest revision as of 13:52, 22 December 2020
Enums are non-arbitrary sets of identifying values. If an interface uses an enum type, all implementations have to implement all specified enum values. It is possible to specify exceptions at the interface. Extending enums is not allowed, because this would cause incompatibilities.
Naming
Enum types begin with an uppercase letter and are put in initial caps. Avoid abbreviations. If there is a possible name-conflict with structs using the same name, add Type or Style to the enum identifier.
Enum values are completely capitalized in uppercase and words are separated by underscores. Do not use a variant of the enum type name as a prefix for the values, because some language bindings will do that automatically.
enum FooBarType
{
NONE,
READ,
WRITE,
USER_DEFINED = 255
};
struct FooBar
{
FooBarType Type;
string FileName
};
Three typical endings of special enum values are _NONE
, _ALL
and _USER_DEFINED
.
Usage
If by general fact an enum represents the most common values within an open set, add a value for USER_DEFINED
and specify the actual meaning by a string in the same object or argument list where the enum is used. In this case, offer a method that returns a sequence of all possible values of this string.
Content on this page is licensed under the Public Documentation License (PDL). |