Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 

58 righe
1.5 KiB

  1. #pragma once
  2. #include <list>
  3. #include <vector>
  4. #include <cpputils/misc/type_helper.h>
  5. #include <cppargs/misc/misc.h>
  6. namespace cppargs
  7. {
  8. inline std::string enwrap_type(const std::string& type, bool optional)
  9. {
  10. auto opn = optional ? "(" : "<";
  11. auto cls = optional ? ")" : ">";
  12. return std::string(opn) + type + cls;
  13. }
  14. template<>
  15. struct argument_props<std::string, void>
  16. {
  17. static std::string type(bool optional = false)
  18. { return enwrap_type("string", false); }
  19. };
  20. template<typename T_value>
  21. struct argument_props<T_value, utl::mp::enable_if_c<!std::is_class<T_value>::value>>
  22. {
  23. static std::string type(bool optional = false)
  24. { return enwrap_type(utl::type_helper<T_value>::name(), false); }
  25. };
  26. template<typename T_value>
  27. struct argument_props<std::list<T_value>, void>
  28. {
  29. static std::string type(bool optional = false)
  30. {
  31. return
  32. argument_props<T_value>::type(false) + ' ' +
  33. argument_props<T_value>::type(true) + ' ' +
  34. enwrap_type("...", true);
  35. }
  36. };
  37. template<typename T_value>
  38. struct argument_props<std::vector<T_value>, void>
  39. {
  40. static std::string type(bool optional = false)
  41. {
  42. return
  43. argument_props<T_value>::type(false) + ' ' +
  44. argument_props<T_value>::type(true) + ' ' +
  45. enwrap_type("...", true);
  46. }
  47. };
  48. }