cam: options: Move Option struct to options.cpp

The Option structure is an internal implementation detail and shouldn't
be exposed in the API. Move it to options.cpp. This requires moving the
inline constructors and destructors for the KeyValueParser and
OptionsParser classes to options.cpp as well, as they need a full
definition of the Option structure.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Laurent Pinchart
2021-07-06 02:35:37 +03:00
parent 12cb9293fa
commit aeb6390418
2 changed files with 27 additions and 16 deletions
+21
View File
@@ -17,6 +17,21 @@
* Option
*/
struct Option {
int opt;
OptionType type;
const char *name;
OptionArgument argument;
const char *argumentName;
const char *help;
KeyValueParser *keyValueParser;
bool isArray;
bool hasShortOption() const { return isalnum(opt); }
bool hasLongOption() const { return name != nullptr; }
const char *typeName() const;
};
const char *Option::typeName() const
{
switch (type) {
@@ -129,6 +144,9 @@ template class OptionsBase<std::string>;
* KeyValueParser
*/
KeyValueParser::KeyValueParser() = default;
KeyValueParser::~KeyValueParser() = default;
bool KeyValueParser::addOption(const char *name, OptionType type,
const char *help, OptionArgument argument)
{
@@ -349,6 +367,9 @@ std::vector<OptionValue> OptionValue::toArray() const
* OptionsParser
*/
OptionsParser::OptionsParser() = default;
OptionsParser::~OptionsParser() = default;
bool OptionsParser::addOption(int opt, OptionType type, const char *help,
const char *name, OptionArgument argument,
const char *argumentName, bool array)