diff --git a/programs/cleos/CLI11.hpp b/programs/cleos/CLI11.hpp index 8f958076a81..68244d3864d 100644 --- a/programs/cleos/CLI11.hpp +++ b/programs/cleos/CLI11.hpp @@ -1,11 +1,11 @@ #pragma once -// CLI11: Version 1.9.0 +// CLI11: Version 1.9.1 // Originally designed by Henry Schreiner // https://github.com/CLIUtils/CLI11 // // This is a standalone header file generated by MakeSingleHeader.py in CLI11/scripts -// from: v1.9.0 +// from: v1.9.1 // // From LICENSE: // @@ -62,18 +62,18 @@ #include -// Verbatim copy from CLI/Version.hpp: +// Verbatim copy from Version.hpp: #define CLI11_VERSION_MAJOR 1 #define CLI11_VERSION_MINOR 9 -#define CLI11_VERSION_PATCH 0 -#define CLI11_VERSION "1.9.0" +#define CLI11_VERSION_PATCH 1 +#define CLI11_VERSION "1.9.1" -// Verbatim copy from CLI/Macros.hpp: +// Verbatim copy from Macros.hpp: // The following version macro is very similar to the one in PyBind11 @@ -112,7 +112,7 @@ -// Verbatim copy from CLI/Validators.hpp: +// Verbatim copy from Validators.hpp: // C standard library @@ -125,7 +125,14 @@ #else #include #if defined __cpp_lib_filesystem && __cpp_lib_filesystem >= 201703 +#if defined _GLIBCXX_RELEASE && _GLIBCXX_RELEASE >= 9 #define CLI11_HAS_FILESYSTEM 1 +#elif defined(__GLIBCXX__) +// if we are using gcc and Version <9 default to no filesystem +#define CLI11_HAS_FILESYSTEM 0 +#else +#define CLI11_HAS_FILESYSTEM 1 +#endif #else #define CLI11_HAS_FILESYSTEM 0 #endif @@ -134,7 +141,7 @@ #endif #if defined CLI11_HAS_FILESYSTEM && CLI11_HAS_FILESYSTEM > 0 -#include // NOLINT(build/include) +#include // NOLINT(build/include) #else #include #include @@ -142,15 +149,15 @@ -// From CLI/Version.hpp: +// From Version.hpp: -// From CLI/Macros.hpp: +// From Macros.hpp: -// From CLI/StringTools.hpp: +// From StringTools.hpp: namespace CLI { @@ -165,7 +172,7 @@ std::ostream &operator<<(std::ostream &in, const T &item) { return in << static_cast::type>(item); } -} // namespace enums +} // namespace enums /// Export to CLI namespace using enums::operator<<; @@ -179,9 +186,9 @@ constexpr int expected_max_vector_size{1 << 29}; inline std::vector split(const std::string &s, char delim) { std::vector elems; // Check to see if empty string, give consistent result - if(s.empty()) + if(s.empty()) { elems.emplace_back(); - else { + } else { std::stringstream ss; ss.str(s); std::string item; @@ -401,8 +408,9 @@ inline std::ptrdiff_t find_member(std::string name, it = std::find_if(std::begin(names), std::end(names), [&name](std::string local_name) { return detail::remove_underscore(local_name) == name; }); - } else + } else { it = std::find(std::begin(names), std::end(names), name); + } return (it != std::end(names)) ? (it - std::begin(names)) : (-1); } @@ -434,7 +442,7 @@ inline std::vector split_up(std::string str, char delimiter = '\0') if(delims.find_first_of(str[0]) != std::string::npos) { keyChar = str[0]; auto end = str.find_first_of(keyChar, 1); - while((end != std::string::npos) && (str[end - 1] == '\\')) { // deal with escaped quotes + while((end != std::string::npos) && (str[end - 1] == '\\')) { // deal with escaped quotes end = str.find_first_of(keyChar, end + 1); embeddedQuote = true; } @@ -492,7 +500,7 @@ inline std::size_t escape_detect(std::string &str, std::size_t offset) { auto astart = str.find_last_of("-/ \"\'`", offset - 1); if(astart != std::string::npos) { if(str[astart] == ((str[offset] == '=') ? '-' : '/')) - str[offset] = ' '; // interpret this as a space so the split_up works properly + str[offset] = ' '; // interpret this as a space so the split_up works properly } } return offset + 1; @@ -510,11 +518,11 @@ inline std::string &add_quotes_if_needed(std::string &str) { return str; } -} // namespace detail +} // namespace detail -} // namespace CLI +} // namespace CLI -// From CLI/Error.hpp: +// From Error.hpp: namespace CLI { @@ -747,11 +755,11 @@ class RequiredError : public ParseError { class ArgumentMismatch : public ParseError { CLI11_ERROR_DEF(ParseError, ArgumentMismatch) CLI11_ERROR_SIMPLE(ArgumentMismatch) - ArgumentMismatch(std::string name, int expected, std::size_t recieved) + ArgumentMismatch(std::string name, int expected, std::size_t received) : ArgumentMismatch(expected > 0 ? ("Expected exactly " + std::to_string(expected) + " arguments to " + name + - ", got " + std::to_string(recieved)) + ", got " + std::to_string(received)) : ("Expected at least " + std::to_string(-expected) + " arguments to " + name + - ", got " + std::to_string(recieved)), + ", got " + std::to_string(received)), ExitCodes::ArgumentMismatch) {} static ArgumentMismatch AtLeast(std::string name, int num, std::size_t received) { @@ -838,9 +846,9 @@ class OptionNotFound : public Error { /// @} -} // namespace CLI +} // namespace CLI -// From CLI/TypeTools.hpp: +// From TypeTools.hpp: namespace CLI { @@ -854,7 +862,7 @@ enum class enabler {}; /// An instance to use in EnableIf constexpr enabler dummy = {}; -} // namespace detail +} // namespace detail /// A copy of enable_if_t from C++14, compatible with C++11. /// @@ -1049,15 +1057,24 @@ template class is_tuple_like { }; /// Convert an object to a string (directly forward if this can become a string) -template ::value, detail::enabler> = detail::dummy> +template ::value, detail::enabler> = detail::dummy> auto to_string(T &&value) -> decltype(std::forward(value)) { return std::forward(value); } +/// Construct a string from the object +template ::value && !std::is_convertible::value, + detail::enabler> = detail::dummy> +std::string to_string(const T &value) { + return std::string(value); +} + /// Convert an object to a string (streaming must be supported for that type) template ::value && is_ostreamable::value, detail::enabler> = - detail::dummy> + enable_if_t::value && !std::is_constructible::value && + is_ostreamable::value, + detail::enabler> = detail::dummy> std::string to_string(T &&value) { std::stringstream stream; stream << value; @@ -1379,7 +1396,7 @@ inline std::string type_name() { // Lexical cast /// Convert a flag into an integer value typically binary flags -inline int64_t to_flag_value(std::string val) { +inline std::int64_t to_flag_value(std::string val) { static const std::string trueString("true"); static const std::string falseString("false"); if(val == trueString) { @@ -1389,10 +1406,10 @@ inline int64_t to_flag_value(std::string val) { return -1; } val = detail::to_lower(val); - int64_t ret; + std::int64_t ret; if(val.size() == 1) { if(val[0] >= '1' && val[0] <= '9') { - return (static_cast(val[0]) - '0'); + return (static_cast(val[0]) - '0'); } switch(val[0]) { case '0': @@ -1442,7 +1459,7 @@ template ::value == object_category::unsigned_integral, detail::enabler> = detail::dummy> bool lexical_cast(const std::string &input, T &output) { if(!input.empty() && input.front() == '-') - return false; // std::stoull happily converts negative values to junk without any errors. + return false; // std::stoull happily converts negative values to junk without any errors. try { std::size_t n = 0; @@ -1622,7 +1639,7 @@ bool lexical_assign(const std::string &input, T &output) { XC val{}; bool parse_result = input.empty() ? true : lexical_cast(input, val); if(parse_result) { - output = T(val); // use () form of constructor to allow some implicit conversions + output = T(val); // use () form of constructor to allow some implicit conversions } return parse_result; } @@ -1803,7 +1820,7 @@ bool lexical_conversion(const std::vector &strings, T &output) { template ::value && std::is_unsigned::value, detail::enabler> = detail::dummy> void sum_flag_vector(const std::vector &flags, T &output) { - int64_t count{0}; + std::int64_t count{0}; for(auto &flag : flags) { count += detail::to_flag_value(flag); } @@ -1818,17 +1835,17 @@ void sum_flag_vector(const std::vector &flags, T &output) { template ::value && std::is_signed::value, detail::enabler> = detail::dummy> void sum_flag_vector(const std::vector &flags, T &output) { - int64_t count{0}; + std::int64_t count{0}; for(auto &flag : flags) { count += detail::to_flag_value(flag); } output = static_cast(count); } -} // namespace detail -} // namespace CLI +} // namespace detail +} // namespace CLI -// From CLI/Split.hpp: +// From Split.hpp: namespace CLI { namespace detail { @@ -1950,10 +1967,10 @@ get_names(const std::vector &input) { short_names, long_names, pos_name); } -} // namespace detail -} // namespace CLI +} // namespace detail +} // namespace CLI -// From CLI/ConfigFwd.hpp: +// From ConfigFwd.hpp: namespace CLI { @@ -2068,9 +2085,9 @@ class ConfigTOML : public ConfigINI { valueDelimiter = '='; } }; -} // namespace CLI +} // namespace CLI -// From CLI/Validators.hpp: +// From Validators.hpp: namespace CLI { @@ -2129,14 +2146,14 @@ class Validator { } } return retstring; - }; + } /// This is the required operator for a Validator - provided to help /// users (CLI11 uses the member `func` directly) std::string operator()(const std::string &str) const { std::string value = str; return (active_) ? func_(value) : std::string{}; - }; + } /// Specify the type string Validator &description(std::string validator_desc) { @@ -2190,13 +2207,13 @@ class Validator { Validator &application_index(int app_index) { application_index_ = app_index; return *this; - }; + } /// Specify the application index of a validator Validator application_index(int app_index) const { Validator newval(*this); newval.application_index_ = app_index; return newval; - }; + } /// Get the current value of the application index int get_application_index() const { return application_index_; } /// Get a boolean if the validator is active @@ -2292,7 +2309,7 @@ class Validator { return std::string(1, '(') + f1 + ')' + merger + '(' + f2 + ')'; }; } -}; // namespace CLI +}; // namespace CLI /// Class wrapping some of the accessors of Validator class CustomValidator : public Validator { @@ -2304,7 +2321,7 @@ class CustomValidator : public Validator { namespace detail { /// CLI enumeration of different file types -enum class path_type { nonexistant, file, directory }; +enum class path_type { nonexistent, file, directory }; #if defined CLI11_HAS_FILESYSTEM && CLI11_HAS_FILESYSTEM > 0 /// get the type of the path from a file name @@ -2312,12 +2329,12 @@ inline path_type check_path(const char *file) noexcept { std::error_code ec; auto stat = std::filesystem::status(file, ec); if(ec) { - return path_type::nonexistant; + return path_type::nonexistent; } switch(stat.type()) { case std::filesystem::file_type::none: case std::filesystem::file_type::not_found: - return path_type::nonexistant; + return path_type::nonexistent; case std::filesystem::file_type::directory: return path_type::directory; case std::filesystem::file_type::symlink: @@ -2345,7 +2362,7 @@ inline path_type check_path(const char *file) noexcept { return ((buffer.st_mode & S_IFDIR) != 0) ? path_type::directory : path_type::file; } #endif - return path_type::nonexistant; + return path_type::nonexistent; } #endif /// Check for an existing file (returns error message if check fails) @@ -2354,7 +2371,7 @@ class ExistingFileValidator : public Validator { ExistingFileValidator() : Validator("FILE") { func_ = [](std::string &filename) { auto path_result = check_path(filename.c_str()); - if(path_result == path_type::nonexistant) { + if(path_result == path_type::nonexistent) { return "File does not exist: " + filename; } if(path_result == path_type::directory) { @@ -2371,7 +2388,7 @@ class ExistingDirectoryValidator : public Validator { ExistingDirectoryValidator() : Validator("DIR") { func_ = [](std::string &filename) { auto path_result = check_path(filename.c_str()); - if(path_result == path_type::nonexistant) { + if(path_result == path_type::nonexistent) { return "Directory does not exist: " + filename; } if(path_result == path_type::file) { @@ -2388,7 +2405,7 @@ class ExistingPathValidator : public Validator { ExistingPathValidator() : Validator("PATH(existing)") { func_ = [](std::string &filename) { auto path_result = check_path(filename.c_str()); - if(path_result == path_type::nonexistant) { + if(path_result == path_type::nonexistent) { return "Path does not exist: " + filename; } return std::string(); @@ -2402,7 +2419,7 @@ class NonexistentPathValidator : public Validator { NonexistentPathValidator() : Validator("PATH(non-existing)") { func_ = [](std::string &filename) { auto path_result = check_path(filename.c_str()); - if(path_result != path_type::nonexistant) { + if(path_result != path_type::nonexistent) { return "Path already exists: " + filename; } return std::string(); @@ -2481,7 +2498,7 @@ class Number : public Validator { } }; -} // namespace detail +} // namespace detail // Static is not needed here, because global const implies static. @@ -2583,7 +2600,7 @@ typename std::remove_reference::type &smart_deref(T &value) { /// Generate a string representation of a set template std::string generate_set(const T &set) { using element_t = typename detail::element_type::type; - using iteration_type_t = typename detail::pair_adaptor::value_type; // the type of the object pair + using iteration_type_t = typename detail::pair_adaptor::value_type; // the type of the object pair std::string out(1, '{'); out.append(detail::join( detail::smart_deref(set), @@ -2596,7 +2613,7 @@ template std::string generate_set(const T &set) { /// Generate a string representation of a map template std::string generate_map(const T &map, bool key_only = false) { using element_t = typename detail::element_type::type; - using iteration_type_t = typename detail::pair_adaptor::value_type; // the type of the object pair + using iteration_type_t = typename detail::pair_adaptor::value_type; // the type of the object pair std::string out(1, '{'); out.append(detail::join( detail::smart_deref(map), @@ -2707,7 +2724,7 @@ typename std::enable_if::value, bool>::type checked_mu return true; } -} // namespace detail +} // namespace detail /// Verify items are in a set class IsMember : public Validator { public: @@ -2727,11 +2744,11 @@ class IsMember : public Validator { // Get the type of the contained item - requires a container have ::value_type // if the type does not have first_type and second_type, these are both value_type - using element_t = typename detail::element_type::type; // Removes (smart) pointers if needed - using item_t = typename detail::pair_adaptor::first_type; // Is value_type if not a map + using element_t = typename detail::element_type::type; // Removes (smart) pointers if needed + using item_t = typename detail::pair_adaptor::first_type; // Is value_type if not a map - using local_item_t = typename IsMemberType::type; // This will convert bad types to good ones - // (const char * to std::string) + using local_item_t = typename IsMemberType::type; // This will convert bad types to good ones + // (const char * to std::string) // Make a local copy of the filter function, using a std::function if not one already std::function filter_fn = filter_function; @@ -2744,7 +2761,7 @@ class IsMember : public Validator { func_ = [set, filter_fn](std::string &input) { local_item_t b; if(!detail::lexical_cast(input, b)) { - throw ValidationError(input); // name is added later + throw ValidationError(input); // name is added later } if(filter_fn) { b = filter_fn(b); @@ -2800,10 +2817,10 @@ class Transformer : public Validator { "mapping must produce value pairs"); // Get the type of the contained item - requires a container have ::value_type // if the type does not have first_type and second_type, these are both value_type - using element_t = typename detail::element_type::type; // Removes (smart) pointers if needed - using item_t = typename detail::pair_adaptor::first_type; // Is value_type if not a map - using local_item_t = typename IsMemberType::type; // This will convert bad types to good ones - // (const char * to std::string) + using element_t = typename detail::element_type::type; // Removes (smart) pointers if needed + using item_t = typename detail::pair_adaptor::first_type; // Is value_type if not a map + using local_item_t = typename IsMemberType::type; // Will convert bad types to good ones + // (const char * to std::string) // Make a local copy of the filter function, using a std::function if not one already std::function filter_fn = filter_function; @@ -2858,12 +2875,11 @@ class CheckedTransformer : public Validator { "mapping must produce value pairs"); // Get the type of the contained item - requires a container have ::value_type // if the type does not have first_type and second_type, these are both value_type - using element_t = typename detail::element_type::type; // Removes (smart) pointers if needed - using item_t = typename detail::pair_adaptor::first_type; // Is value_type if not a map - using local_item_t = typename IsMemberType::type; // This will convert bad types to good ones - // (const char * to std::string) - using iteration_type_t = typename detail::pair_adaptor::value_type; // the type of the object pair // - // the type of the object pair + using element_t = typename detail::element_type::type; // Removes (smart) pointers if needed + using item_t = typename detail::pair_adaptor::first_type; // Is value_type if not a map + using local_item_t = typename IsMemberType::type; // Will convert bad types to good ones + // (const char * to std::string) + using iteration_type_t = typename detail::pair_adaptor::value_type; // the type of the object pair // Make a local copy of the filter function, using a std::function if not one already std::function filter_fn = filter_function; @@ -3071,7 +3087,7 @@ class AsNumberWithUnit : public Validator { /// "2 EiB" => 2^61 // Units up to exibyte are supported class AsSizeValue : public AsNumberWithUnit { public: - using result_t = uint64_t; + using result_t = std::uint64_t; /// If kb_is_1000 is true, /// interpret 'kb', 'k' as 1000 and 'kib', 'ki' as 1024 @@ -3147,12 +3163,12 @@ inline std::pair split_program_name(std::string comman return vals; } -} // namespace detail +} // namespace detail /// @} -} // namespace CLI +} // namespace CLI -// From CLI/FormatterFwd.hpp: +// From FormatterFwd.hpp: namespace CLI { @@ -3165,9 +3181,9 @@ class App; /// the second argument. enum class AppFormatMode { - Normal, //< The normal, detailed help - All, //< A fully expanded help - Sub, //< Used when printed as part of expanded subcommand + Normal, ///< The normal, detailed help + All, ///< A fully expanded help + Sub, ///< Used when printed as part of expanded subcommand }; /// This is the minimum requirements to run a formatter. @@ -3196,7 +3212,7 @@ class FormatterBase { FormatterBase(FormatterBase &&) = default; /// Adding a destructor in this form to work around bug in GCC 4.7 - virtual ~FormatterBase() noexcept {} // NOLINT(modernize-use-equals-default) + virtual ~FormatterBase() noexcept {} // NOLINT(modernize-use-equals-default) /// This is the key method that puts together help virtual std::string make_help(const App *, std::string, AppFormatMode) const = 0; @@ -3241,7 +3257,7 @@ class FormatterLambda final : public FormatterBase { explicit FormatterLambda(funct_t funct) : lambda_(std::move(funct)) {} /// Adding a destructor (mostly to make GCC 4.7 happy) - ~FormatterLambda() noexcept override {} // NOLINT(modernize-use-equals-default) + ~FormatterLambda() noexcept override {} // NOLINT(modernize-use-equals-default) /// This will simply call the lambda function std::string make_help(const App *app, std::string name, AppFormatMode mode) const override { @@ -3318,9 +3334,9 @@ class Formatter : public FormatterBase { ///@} }; -} // namespace CLI +} // namespace CLI -// From CLI/Option.hpp: +// From Option.hpp: namespace CLI { @@ -3334,11 +3350,11 @@ class App; using Option_p = std::unique_ptr