Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

82 рядки
1.9 KiB

  1. #pragma once
  2. #include <memory>
  3. #include <vector>
  4. #include <cppargs/options/option.h>
  5. namespace cppargs
  6. {
  7. /**
  8. * @brief Struct to collect group meta data.
  9. */
  10. struct group_meta
  11. {
  12. std::string name { "" }; //!< Name of the group.
  13. std::string description { "" }; //!< Description of the group.
  14. inline group_meta& set_name (const std::string& value);
  15. inline group_meta& set_description(const std::string& value);
  16. };
  17. /**
  18. * @brief Struct to manage options and subgroups.
  19. */
  20. struct group
  21. {
  22. public:
  23. using option_type = option;
  24. using option_ptr_type = std::unique_ptr<option_type>;
  25. using option_vector_type = std::vector<option_ptr_type>;
  26. using group_type = group;
  27. using group_ptr_type = std::unique_ptr<group_type>;
  28. using group_vector_type = std::vector<group_ptr_type>;
  29. public:
  30. friend struct parser;
  31. const group_meta meta;
  32. protected:
  33. option_vector_type _options;
  34. group_vector_type _groups;
  35. private:
  36. inline group(const group&) = delete;
  37. public:
  38. /**
  39. * @brief Constructor.
  40. *
  41. * @param[in] p_meta Meta data of the group.
  42. * @param[in] p_args Sub groups and options.
  43. */
  44. template<typename... T_args>
  45. inline group(
  46. const group_meta& p_meta,
  47. T_args&&... p_args);
  48. /**
  49. * @brief Move constructor.
  50. */
  51. inline group(group&&) = default;
  52. /**
  53. * @brief Destructor.
  54. */
  55. virtual ~group() = default;
  56. /**
  57. * @brief Get all options assigned to this group.
  58. */
  59. inline const option_vector_type& options() const;
  60. /**
  61. * @brief Get all subgroups assigned to this group.
  62. */
  63. inline const group_vector_type& groups() const;
  64. };
  65. }