Type: New Feature
Priority: Major - P3
Affects Version/s: None
Fix Version/s: 3.5.7
Sprint:Platforms 2017-05-08, Platforms 2017-05-29
Enums provide a powerful way to document the values accepted by a particular field in a BSON document. The two most popular types of fields to use for enums are integer and string fields. IDL will add support for both of these two types of values for enums.
- Name must be globally unique among all types, enums, commands, and structs
- Validates range of integers is continuous so simple boundary checks can done before a static_cast from int -> c++ enum.
- Generated by the idl file that defines them like structs and commands
- Generates a pair of global functions for parsing and serializing the enum to/from StringData
Generates the following global type:
For string maps:
Generates the following pseudo C++ code:
A future optimization for big enums is to use a hash table instead of lots of string comparisons.
Sample struct using the enums
Sample Pseudo C++ Generated Code:
Requested by: William Schultz