1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-04-29 12:13:52 +00:00

Adding more documentation to fix some warnings

This commit is contained in:
Henry Fredrick Schreiner 2018-07-01 10:21:22 +02:00
parent 9d6830e8d2
commit 20c304fa01
5 changed files with 16 additions and 5 deletions

View File

@ -334,7 +334,7 @@ BUILTIN_STL_SUPPORT = NO
# enable parsing support. # enable parsing support.
# The default value is: NO. # The default value is: NO.
CPP_CLI11_SUPPORT = NO CPP_CLI_SUPPORT = NO
# Set the SIP_SUPPORT tag to YES if your project consists of sip (see: # Set the SIP_SUPPORT tag to YES if your project consists of sip (see:
# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen # http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen

View File

@ -86,9 +86,11 @@ class FormatterBase {
class FormatterLambda final : public FormatterBase { class FormatterLambda final : public FormatterBase {
using funct_t = std::function<std::string(const App *, std::string, AppFormatMode)>; using funct_t = std::function<std::string(const App *, std::string, AppFormatMode)>;
/// The lambda to hold and run
funct_t lambda_; funct_t lambda_;
public: public:
/// Create a FormatterLambda with a lambda function
explicit FormatterLambda(funct_t funct) : lambda_(std::move(funct)) {} explicit FormatterLambda(funct_t funct) : lambda_(std::move(funct)) {}
/// This will simply call the lambda function /// This will simply call the lambda function

View File

@ -51,6 +51,7 @@ template <typename CRTP> class OptionBase {
/// Policy for multiple arguments when `expected_ == 1` (can be set on bool flags, too) /// Policy for multiple arguments when `expected_ == 1` (can be set on bool flags, too)
MultiOptionPolicy multi_option_policy_{MultiOptionPolicy::Throw}; MultiOptionPolicy multi_option_policy_{MultiOptionPolicy::Throw};
/// Copy the contents to another similar class (one based on OptionBase)
template <typename T> void copy_to(T *other) const { template <typename T> void copy_to(T *other) const {
other->group(group_); other->group(group_);
other->required(required_); other->required(required_);
@ -440,7 +441,7 @@ class Option : public OptionBase<Option> {
/// The number of times the option expects to be included /// The number of times the option expects to be included
int get_expected() const { return expected_; } int get_expected() const { return expected_; }
/// \breif The total number of expected values (including the type) /// \brief The total number of expected values (including the type)
/// This is positive if exactly this number is expected, and negitive for at least N values /// This is positive if exactly this number is expected, and negitive for at least N values
/// ///
/// v = fabs(size_type*expected) /// v = fabs(size_type*expected)

View File

@ -83,6 +83,7 @@ class Timer {
} }
// LCOV_EXCL_START // LCOV_EXCL_START
/// This prints out a time string from a time
std::string make_time_str(double time) const { std::string make_time_str(double time) const {
auto print_it = [](double x, std::string unit) { auto print_it = [](double x, std::string unit) {
char buffer[50]; char buffer[50];

View File

@ -30,11 +30,14 @@ namespace CLI {
struct Validator { struct Validator {
/// This is the type name, if empty the type name will not be changed /// This is the type name, if empty the type name will not be changed
std::string tname; std::string tname;
std::function<std::string(const std::string &filename)> func;
/// This it the base function that is to be called.
/// Returns a string error message if validation fails.
std::function<std::string(const std::string &)> func;
/// This is the required operator for a validator - provided to help /// This is the required operator for a validator - provided to help
/// users (CLI11 uses the func directly) /// users (CLI11 uses the member `func` directly)
std::string operator()(const std::string &filename) const { return func(filename); }; std::string operator()(const std::string &str) const { return func(str); };
/// Combining validators is a new validator /// Combining validators is a new validator
Validator operator&(const Validator &other) const { Validator operator&(const Validator &other) const {
@ -165,6 +168,10 @@ const detail::NonexistentPathValidator NonexistentPath;
/// Produce a range (factory). Min and max are inclusive. /// Produce a range (factory). Min and max are inclusive.
struct Range : public Validator { struct Range : public Validator {
/// This produces a range with min and max inclusive.
///
/// Note that the constructor is templated, but the struct is not, so C++17 is not
/// needed to provide nice syntax for Range(a,b).
template <typename T> Range(T min, T max) { template <typename T> Range(T min, T max) {
std::stringstream out; std::stringstream out;
out << detail::type_name<T>() << " in [" << min << " - " << max << "]"; out << detail::type_name<T>() << " in [" << min << " - " << max << "]";