No puede seleccionar más de 25 temas
Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
|
- #pragma once
-
- #include <string>
- #include <cppargs/misc/context.h>
-
- namespace cppargs
- {
-
- /**
- * @brief Class to store all meta data for a option.
- */
- struct option_meta
- {
- char short_name { '\0' }; //!< short option of the option (without the prependding -)
- std::string long_name { "" }; //!< long name of the option (without the prepending --)
- std::string description { "" }; //!< description for this option
- std::string arguments { "" }; //!< arguments to pass to this option
- std::string default_value { "" }; //!< default value for this option
- bool mandatory { false }; //!< TRUE if this option is optional, FALSE otherwise
-
- inline option_meta& set_short_name (char value);
- inline option_meta& set_long_name (const std::string& value);
- inline option_meta& set_description (const std::string& value);
- inline option_meta& set_arguments (const std::string& value);
- inline option_meta& set_default_value (const std::string& value);
- inline option_meta& set_mandatory (bool value = true);
-
- template<typename T_value>
- static option_meta prepare_arguments(const option_meta& meta);
- };
-
- /**
- * @brief Option to parse from command line arguments
- */
- struct option
- {
- public:
- const option_meta meta; //!< meta data of the option
-
- protected:
- /**
- * @brief Constructor.
- *
- * @param[in] p_long_name Long name of the option.
- * @param[in] p_short_name Short name of the option.
- */
- inline option(const option_meta& meta);
-
- public:
- /**
- * @brief Destructor.
- */
- virtual ~option() = default;
-
- /**
- * @brief Parse the option using the current context.
- *
- * @param[in|out] c Context to use for parsing.
- */
- virtual void parse(context& c) const = 0;
- };
-
- }
|