Skip to content

querying valid values for enums #149

@mbunkus

Description

@mbunkus

Looking at #148 which embeds the information about the minimum & maximum version number an element is valid for in libMatroska, I thought about also having the information available which values are valid for the various enums we have in the specs. At the moment we only have C-style enum for them, which means we can use them in the code via their names, but there's no way to have the program query the library if a given value is valid or not.

For example, it would be nice to be able to query libMatroska & ask if the value 1 is valid for the "color primaries" element (it is) or if 14 is (it isn't).

On top of that it would be nice if the library simply provided a list of valid value/description pairs that an application can use for selection or to translate what a given value refers to (think mkvinfo outputting the name of the "color primaries" along with the numeric value).

I'm thinking about two or three functions, the example being for an unsigned integer-based enum:

static bool IsValueInSpecs(uint64_t value);
static std::string GetDescriptionForValueFromSpecs(uint64_t value);
static std::vector<std::pair<uint64_t, std::string>> GetValuesDescriptionsFromSpecs();

I'm trying to avoid the word "valid" here as these functions are all static; they only provide information straight from the specs. Not really happy with the names, though…

Metadata

Metadata

Assignees

No one assigned

    Labels

    SemanticChange in the semantic interepretationabi-breakbreaks the ABI (e.g. programs linked against the library have to be recompiled)enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions