diff options
author | Remko Tronçon <git@el-tramo.be> | 2012-12-23 13:16:26 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2012-12-23 14:43:26 (GMT) |
commit | 491ddd570a752cf9bda85933bed0c6942e39b1f9 (patch) | |
tree | 10c25c1be8cc08d0497df1dccd56a10fbb30beee /3rdParty/Boost/src/boost/program_options | |
parent | da7d7a0ca71b80281aa9ff2526290b61ccb0cc60 (diff) | |
download | swift-491ddd570a752cf9bda85933bed0c6942e39b1f9.zip swift-491ddd570a752cf9bda85933bed0c6942e39b1f9.tar.bz2 |
Update Boost to 1.52.0.
Change-Id: I1e56bea2600bf2ed9c5b3aba8c4f9d2a0f350e77
Diffstat (limited to '3rdParty/Boost/src/boost/program_options')
10 files changed, 402 insertions, 157 deletions
diff --git a/3rdParty/Boost/src/boost/program_options/config.hpp b/3rdParty/Boost/src/boost/program_options/config.hpp index 0c69c14..8b70521 100644 --- a/3rdParty/Boost/src/boost/program_options/config.hpp +++ b/3rdParty/Boost/src/boost/program_options/config.hpp @@ -34,17 +34,14 @@ #endif // BOOST_VERSION /////////////////////////////////////////////////////////////////////////////// -// Windows DLL suport -#ifdef BOOST_HAS_DECLSPEC #if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_PROGRAM_OPTIONS_DYN_LINK) // export if this is our own source, otherwise import: #ifdef BOOST_PROGRAM_OPTIONS_SOURCE -# define BOOST_PROGRAM_OPTIONS_DECL __declspec(dllexport) +# define BOOST_PROGRAM_OPTIONS_DECL BOOST_SYMBOL_EXPORT #else -# define BOOST_PROGRAM_OPTIONS_DECL __declspec(dllimport) +# define BOOST_PROGRAM_OPTIONS_DECL BOOST_SYMBOL_IMPORT #endif // BOOST_PROGRAM_OPTIONS_SOURCE #endif // DYN_LINK -#endif // BOOST_HAS_DECLSPEC #ifndef BOOST_PROGRAM_OPTIONS_DECL #define BOOST_PROGRAM_OPTIONS_DECL diff --git a/3rdParty/Boost/src/boost/program_options/detail/cmdline.hpp b/3rdParty/Boost/src/boost/program_options/detail/cmdline.hpp index 7c43152..8e3bcc6 100644 --- a/3rdParty/Boost/src/boost/program_options/detail/cmdline.hpp +++ b/3rdParty/Boost/src/boost/program_options/detail/cmdline.hpp @@ -81,6 +81,18 @@ namespace boost { namespace program_options { namespace detail { cmdline(int argc, const char*const * argv); void style(int style); + + /** returns the canonical option prefix associated with the command_line_style + * In order of precedence: + * allow_long : allow_long + * allow_long_disguise : allow_long_disguise + * allow_dash_for_short : allow_short | allow_dash_for_short + * allow_slash_for_short: allow_short | allow_slash_for_short + * + * This is mainly used for the diagnostic messages in exceptions + */ + int get_canonical_option_prefix(); + void allow_unregistered(); void set_options_description(const options_description& desc); diff --git a/3rdParty/Boost/src/boost/program_options/detail/config_file.hpp b/3rdParty/Boost/src/boost/program_options/detail/config_file.hpp index 91caac7..4c2c15b 100644 --- a/3rdParty/Boost/src/boost/program_options/detail/config_file.hpp +++ b/3rdParty/Boost/src/boost/program_options/detail/config_file.hpp @@ -17,9 +17,7 @@ #include <boost/program_options/eof_iterator.hpp> #include <boost/detail/workaround.hpp> -#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3202)) #include <boost/program_options/detail/convert.hpp> -#endif #if BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042)) #include <istream> // std::getline diff --git a/3rdParty/Boost/src/boost/program_options/detail/parsers.hpp b/3rdParty/Boost/src/boost/program_options/detail/parsers.hpp index a1124b2..af240c6 100644 --- a/3rdParty/Boost/src/boost/program_options/detail/parsers.hpp +++ b/3rdParty/Boost/src/boost/program_options/detail/parsers.hpp @@ -100,7 +100,11 @@ namespace boost { namespace program_options { basic_parsed_options<charT> basic_command_line_parser<charT>::run() { - parsed_options result(m_desc); + // save the canonical prefixes which were used by this cmdline parser + // eventually inside the parsed results + // This will be handy to format recognisable options + // for diagnostic messages if everything blows up much later on + parsed_options result(m_desc, detail::cmdline::get_canonical_option_prefix()); result.options = detail::cmdline::run(); // Presense of parsed_options -> wparsed_options conversion diff --git a/3rdParty/Boost/src/boost/program_options/detail/value_semantic.hpp b/3rdParty/Boost/src/boost/program_options/detail/value_semantic.hpp index e4b15d7..814a3db 100644 --- a/3rdParty/Boost/src/boost/program_options/detail/value_semantic.hpp +++ b/3rdParty/Boost/src/boost/program_options/detail/value_semantic.hpp @@ -16,16 +16,17 @@ namespace boost { namespace program_options { std::string typed_value<T, charT>::name() const { + std::string const& var = (m_value_name.empty() ? arg : m_value_name); if (!m_implicit_value.empty() && !m_implicit_value_as_text.empty()) { - std::string msg = "[=arg(=" + m_implicit_value_as_text + ")]"; + std::string msg = "[=" + var + "(=" + m_implicit_value_as_text + ")]"; if (!m_default_value.empty() && !m_default_value_as_text.empty()) msg += " (=" + m_default_value_as_text + ")"; return msg; } else if (!m_default_value.empty() && !m_default_value_as_text.empty()) { - return arg + " (=" + m_default_value_as_text + ")"; + return var + " (=" + m_default_value_as_text + ")"; } else { - return arg; + return var; } } diff --git a/3rdParty/Boost/src/boost/program_options/errors.hpp b/3rdParty/Boost/src/boost/program_options/errors.hpp index ff6bc7f..addb8d6 100644 --- a/3rdParty/Boost/src/boost/program_options/errors.hpp +++ b/3rdParty/Boost/src/boost/program_options/errors.hpp @@ -12,6 +12,8 @@ #include <string> #include <stdexcept> #include <vector> +#include <map> + #if defined(BOOST_MSVC) # pragma warning (push) @@ -21,126 +23,338 @@ namespace boost { namespace program_options { + inline std::string strip_prefixes(const std::string& text) + { + return text.substr(text.find_last_of("-/") + 1); + } + /** Base class for all errors in the library. */ class BOOST_PROGRAM_OPTIONS_DECL error : public std::logic_error { public: error(const std::string& xwhat) : std::logic_error(xwhat) {} }; - class BOOST_PROGRAM_OPTIONS_DECL invalid_syntax : public error { + + /** Class thrown when there are too many positional options. + This is a programming error. + */ + class BOOST_PROGRAM_OPTIONS_DECL too_many_positional_options_error : public error { public: - enum kind_t { - long_not_allowed = 30, - long_adjacent_not_allowed, - short_adjacent_not_allowed, - empty_adjacent_parameter, - missing_parameter, - extra_parameter, - unrecognized_line - }; - - invalid_syntax(const std::string& tokens, kind_t kind); + too_many_positional_options_error() + : error("too many positional options have been specified on the command line") + {} + }; + + /** Class thrown when there are programming error related to style */ + class BOOST_PROGRAM_OPTIONS_DECL invalid_command_line_style : public error { + public: + invalid_command_line_style(const std::string& msg) + : error(msg) + {} + }; + + /** Class thrown if config file can not be read */ + class BOOST_PROGRAM_OPTIONS_DECL reading_file : public error { + public: + reading_file(const char* filename) + : error(std::string("can not read options configuration file '").append(filename).append("'")) + {} + }; + + + /** Base class for most exceptions in the library. + * + * Substitutes the values for the parameter name + * placeholders in the template to create the human + * readable error message + * + * Placeholders are surrounded by % signs: %example% + * Poor man's version of boost::format + * + * If a parameter name is absent, perform default substitutions + * instead so ugly placeholders are never left in-place. + * + * Options are displayed in "canonical" form + * This is the most unambiguous form of the + * *parsed* option name and would correspond to + * option_description::format_name() + * i.e. what is shown by print_usage() + * + * The "canonical" form depends on whether the option is + * specified in short or long form, using dashes or slashes + * or without a prefix (from a configuration file) + * + * */ + class BOOST_PROGRAM_OPTIONS_DECL error_with_option_name : public error { - // gcc says that throw specification on dtor is loosened - // without this line - ~invalid_syntax() throw() {} - - kind_t kind() const; - - const std::string& tokens() const; - protected: - /** Used to convert kind_t to a related error text */ - static std::string error_message(kind_t kind); + /** can be + * 0 = no prefix (config file options) + * allow_long + * allow_dash_for_short + * allow_slash_for_short + * allow_long_disguise */ + int m_option_style; - private: - // TODO: copy ctor might throw - std::string m_tokens; - kind_t m_kind; + /** substitutions + * from placeholders to values */ + std::map<std::string, std::string> m_substitutions; + typedef std::pair<std::string, std::string> string_pair; + std::map<std::string, string_pair > m_substitution_defaults; + + public: + /** template with placeholders */ + std::string m_error_template; + + error_with_option_name(const std::string& template_, + const std::string& option_name = "", + const std::string& original_token = "", + int option_style = 0); + + /** gcc says that throw specification on dtor is loosened + * without this line + * */ + ~error_with_option_name() throw() {} + + + //void dump() const + //{ + // std::cerr << "m_substitution_defaults:\n"; + // for (std::map<std::string, string_pair>::const_iterator iter = m_substitution_defaults.begin(); + // iter != m_substitution_defaults.end(); ++iter) + // std::cerr << "\t" << iter->first << ":" << iter->second.first << "=" << iter->second.second << "\n"; + // std::cerr << "m_substitutions:\n"; + // for (std::map<std::string, std::string>::const_iterator iter = m_substitutions.begin(); + // iter != m_substitutions.end(); ++iter) + // std::cerr << "\t" << iter->first << "=" << iter->second << "\n"; + // std::cerr << "m_error_template:\n"; + // std::cerr << "\t" << m_error_template << "\n"; + // std::cerr << "canonical_option_prefix:[" << get_canonical_option_prefix() << "]\n"; + // std::cerr << "canonical_option_name:[" << get_canonical_option_name() <<"]\n"; + // std::cerr << "what:[" << what() << "]\n"; + //} + + /** Substitute + * parameter_name->value to create the error message from + * the error template */ + void set_substitute(const std::string& parameter_name, const std::string& value) + { m_substitutions[parameter_name] = value; } + + /** If the parameter is missing, then make the + * from->to substitution instead */ + void set_substitute_default(const std::string& parameter_name, + const std::string& from, + const std::string& to) + { + m_substitution_defaults[parameter_name] = std::make_pair(from, to); + } + + + /** Add context to an exception */ + void add_context(const std::string& option_name, + const std::string& original_token, + int option_style) + { + set_option_name(option_name); + set_original_token(original_token); + set_prefix(option_style); + } + + void set_prefix(int option_style) + { m_option_style = option_style;} + + /** Overridden in error_with_no_option_name */ + virtual void set_option_name(const std::string& option_name) + { set_substitute("option", option_name);} + + std::string get_option_name() const throw() + { return get_canonical_option_name(); } + + void set_original_token(const std::string& original_token) + { set_substitute("original_token", original_token);} + + + /** Creates the error_message on the fly + * Currently a thin wrapper for substitute_placeholders() */ + virtual const char* what() const throw(); + + protected: + /** Used to hold the error text returned by what() */ + mutable std::string m_message; // For on-demand formatting in 'what' + + /** Makes all substitutions using the template */ + virtual void substitute_placeholders(const std::string& error_template) const; + + // helper function for substitute_placeholders + void replace_token(const std::string& from, const std::string& to) const; + + /** Construct option name in accordance with the appropriate + * prefix style: i.e. long dash or short slash etc */ + std::string get_canonical_option_name() const; + std::string get_canonical_option_prefix() const; + }; + + + /** Class thrown when there are several option values, but + user called a method which cannot return them all. */ + class BOOST_PROGRAM_OPTIONS_DECL multiple_values : public error_with_option_name { + public: + multiple_values() + : error_with_option_name("option '%canonical_option%' only takes a single argument"){} + + ~multiple_values() throw() {} + }; + + /** Class thrown when there are several occurrences of an + option, but user called a method which cannot return + them all. */ + class BOOST_PROGRAM_OPTIONS_DECL multiple_occurrences : public error_with_option_name { + public: + multiple_occurrences() + : error_with_option_name("option '%canonical_option%' cannot be specified more than once"){} + + ~multiple_occurrences() throw() {} + + }; + + /** Class thrown when a required/mandatory option is missing */ + class BOOST_PROGRAM_OPTIONS_DECL required_option : public error_with_option_name { + public: + // option name is constructed by the option_descriptor and never on the fly + required_option(const std::string& option_name) + : error_with_option_name("the option '%canonical_option%' is required but missing", "", option_name) + { + } + + ~required_option() throw() {} + }; + + /** Base class of unparsable options, + * when the desired option cannot be identified. + * + * + * It makes no sense to have an option name, when we can't match an option to the + * parameter + * + * Having this a part of the error_with_option_name hierachy makes error handling + * a lot easier, even if the name indicates some sort of conceptual dissonance! + * + * */ + class BOOST_PROGRAM_OPTIONS_DECL error_with_no_option_name : public error_with_option_name { + public: + error_with_no_option_name(const std::string& template_, + const std::string& original_token = "") + : error_with_option_name(template_, "", original_token) + { + } + + /** Does NOT set option name, because no option name makes sense */ + virtual void set_option_name(const std::string& option_name){} + + ~error_with_no_option_name() throw() {} }; + /** Class thrown when option name is not recognized. */ - class BOOST_PROGRAM_OPTIONS_DECL unknown_option : public error { + class BOOST_PROGRAM_OPTIONS_DECL unknown_option : public error_with_no_option_name { public: - unknown_option(const std::string& name) - : error(std::string("unknown option ").append(name)), - m_option_name(name) - {} + unknown_option(const std::string& original_token = "") + : error_with_no_option_name("unrecognised option '%canonical_option%'", original_token) + { + } - // gcc says that throw specification on dtor is loosened - // without this line ~unknown_option() throw() {} - - const std::string& get_option_name() const throw(); - - private: - std::string m_option_name; }; + + /** Class thrown when there's ambiguity amoung several possible options. */ - class BOOST_PROGRAM_OPTIONS_DECL ambiguous_option : public error { + class BOOST_PROGRAM_OPTIONS_DECL ambiguous_option : public error_with_no_option_name { public: - ambiguous_option(const std::string& name, - const std::vector<std::string>& xalternatives) - : error(std::string("ambiguous option ").append(name)) - , m_alternatives(xalternatives) - , m_option_name(name) + ambiguous_option(const std::vector<std::string>& xalternatives) + : error_with_no_option_name("option '%canonical_option%' is ambiguous"), + m_alternatives(xalternatives) {} ~ambiguous_option() throw() {} - - const std::string& get_option_name() const throw(); - - const std::vector<std::string>& alternatives() const throw(); + const std::vector<std::string>& alternatives() const throw() {return m_alternatives;} + + protected: + /** Makes all substitutions using the template */ + virtual void substitute_placeholders(const std::string& error_template) const; private: // TODO: copy ctor might throw std::vector<std::string> m_alternatives; - std::string m_option_name; }; - /** Class thrown when there are several option values, but - user called a method which cannot return them all. */ - class BOOST_PROGRAM_OPTIONS_DECL multiple_values : public error { + + /** Class thrown when there's syntax error either for command + * line or config file options. See derived children for + * concrete classes. */ + class BOOST_PROGRAM_OPTIONS_DECL invalid_syntax : public error_with_option_name { public: - multiple_values() - : error("multiple values") - , m_option_name() {} - - ~multiple_values() throw() {} - - void set_option_name(const std::string& option); - - const std::string& get_option_name() const throw(); - - private: - std::string m_option_name; // The name of the option which - // caused the exception. + enum kind_t { + long_not_allowed = 30, + long_adjacent_not_allowed, + short_adjacent_not_allowed, + empty_adjacent_parameter, + missing_parameter, + extra_parameter, + unrecognized_line + }; + + invalid_syntax(kind_t kind, + const std::string& option_name = "", + const std::string& original_token = "", + int option_style = 0): + error_with_option_name(get_template(kind), option_name, original_token, option_style), + m_kind(kind) + { + } + + ~invalid_syntax() throw() {} + + kind_t kind() const {return m_kind;} + + /** Convenience functions for backwards compatibility */ + virtual std::string tokens() const {return get_option_name(); } + protected: + /** Used to convert kind_t to a related error text */ + std::string get_template(kind_t kind); + kind_t m_kind; }; - /** Class thrown when there are several occurrences of an - option, but user called a method which cannot return - them all. */ - class BOOST_PROGRAM_OPTIONS_DECL multiple_occurrences : public error { + class BOOST_PROGRAM_OPTIONS_DECL invalid_config_file_syntax : public invalid_syntax { public: - multiple_occurrences() - : error("multiple occurrences") - , m_option_name() {} - - ~multiple_occurrences() throw() {} - - void set_option_name(const std::string& option); - - const std::string& get_option_name() const throw(); + invalid_config_file_syntax(const std::string& invalid_line, kind_t kind): + invalid_syntax(kind) + { + m_substitutions["invalid_line"] = invalid_line; + } + + ~invalid_config_file_syntax() throw() {} + + /** Convenience functions for backwards compatibility */ + virtual std::string tokens() const {return m_substitutions.find("invalid_line")->second; } + }; + - private: - std::string m_option_name; // The name of the option which - // caused the exception. + /** Class thrown when there are syntax errors in given command line */ + class BOOST_PROGRAM_OPTIONS_DECL invalid_command_line_syntax : public invalid_syntax { + public: + invalid_command_line_syntax(kind_t kind, + const std::string& option_name = "", + const std::string& original_token = "", + int option_style = 0): + invalid_syntax(kind, option_name, original_token, option_style) {} + ~invalid_command_line_syntax() throw() {} }; + /** Class thrown when value of option is incorrect. */ - class BOOST_PROGRAM_OPTIONS_DECL validation_error : public error { + class BOOST_PROGRAM_OPTIONS_DECL validation_error : public error_with_option_name { public: enum kind_t { multiple_values_not_allowed = 30, @@ -150,32 +364,24 @@ namespace boost { namespace program_options { invalid_option }; + public: validation_error(kind_t kind, - const std::string& option_value = "", - const std::string& option_name = ""); - + const std::string& option_name = "", + const std::string& original_token = "", + int option_style = 0): + error_with_option_name(get_template(kind), option_name, original_token, option_style) + { + } + ~validation_error() throw() {} - void set_option_name(const std::string& option); - - const std::string& get_option_name() const throw(); - - const char* what() const throw(); - protected: /** Used to convert kind_t to a related error text */ - static std::string error_message(kind_t kind); - - private: + std::string get_template(kind_t kind); kind_t m_kind; - std::string m_option_name; // The name of the option which - // caused the exception. - std::string m_option_value; // Optional: value of the option m_options_name - mutable std::string m_message; // For on-demand formatting in 'what' - }; - /** Class thrown if there is an invalid option value givenn */ + /** Class thrown if there is an invalid option value given */ class BOOST_PROGRAM_OPTIONS_DECL invalid_option_value : public validation_error { @@ -186,54 +392,20 @@ namespace boost { namespace program_options { #endif }; - /** Class thrown when there are too many positional options. - This is a programming error. - */ - class BOOST_PROGRAM_OPTIONS_DECL too_many_positional_options_error : public error { + /** Class thrown if there is an invalid bool value given */ + class BOOST_PROGRAM_OPTIONS_DECL invalid_bool_value + : public validation_error + { public: - too_many_positional_options_error() - : error("too many positional options") - {} + invalid_bool_value(const std::string& value); }; - /** Class thrown when there are syntax errors in given command line */ - class BOOST_PROGRAM_OPTIONS_DECL invalid_command_line_syntax : public invalid_syntax { - public: - invalid_command_line_syntax(const std::string& tokens, kind_t kind); - }; - /** Class thrown when there are programming error related to style */ - class BOOST_PROGRAM_OPTIONS_DECL invalid_command_line_style : public error { - public: - invalid_command_line_style(const std::string& msg) - : error(msg) - {} - }; - /** Class thrown if config file can not be read */ - class BOOST_PROGRAM_OPTIONS_DECL reading_file : public error { - public: - reading_file(const char* filename) - : error(std::string("can not read file ").append(filename)) - {} - }; + + - /** Class thrown when a required/mandatory option is missing */ - class BOOST_PROGRAM_OPTIONS_DECL required_option : public error { - public: - required_option(const std::string& name) - : error(std::string("missing required option ").append(name)) - , m_option_name(name) - {} - - ~required_option() throw() {} - const std::string& get_option_name() const throw(); - - private: - std::string m_option_name; // The name of the option which - // caused the exception. - }; }} #if defined(BOOST_MSVC) diff --git a/3rdParty/Boost/src/boost/program_options/options_description.hpp b/3rdParty/Boost/src/boost/program_options/options_description.hpp index eff1f90..62530b2 100644 --- a/3rdParty/Boost/src/boost/program_options/options_description.hpp +++ b/3rdParty/Boost/src/boost/program_options/options_description.hpp @@ -102,6 +102,16 @@ namespace program_options { */ const std::string& key(const std::string& option) const; + + /** Returns the canonical name for the option description to enable the user to + recognised a matching option. + 1) For short options ('-', '/'), returns the short name prefixed. + 2) For long options ('--' / '-') returns the long name prefixed + 3) All other cases, returns the long name (if present) or the short name, + unprefixed. + */ + std::string canonical_display_name(int canonical_option_style = 0) const; + const std::string& long_name() const; /// Explanation of this option diff --git a/3rdParty/Boost/src/boost/program_options/parsers.hpp b/3rdParty/Boost/src/boost/program_options/parsers.hpp index c57b971..96f38f2 100644 --- a/3rdParty/Boost/src/boost/program_options/parsers.hpp +++ b/3rdParty/Boost/src/boost/program_options/parsers.hpp @@ -36,8 +36,8 @@ namespace boost { namespace program_options { template<class charT> class basic_parsed_options { public: - explicit basic_parsed_options(const options_description* xdescription) - : description(xdescription) {} + explicit basic_parsed_options(const options_description* xdescription, int options_prefix = 0) + : description(xdescription), m_options_prefix(options_prefix) {} /** Options found in the source. */ std::vector< basic_option<charT> > options; /** Options description that was used for parsing. @@ -46,6 +46,17 @@ namespace boost { namespace program_options { up to the caller. Can be NULL. */ const options_description* description; + + /** Mainly used for the diagnostic messages in exceptions. + * The canonical option prefix for the parser which generated these results, + * depending on the settings for basic_command_line_parser::style() or + * cmdline::style(). In order of precedence of command_line_style enums: + * allow_long + * allow_long_disguise + * allow_dash_for_short + * allow_slash_for_short + */ + int m_options_prefix; }; /** Specialization of basic_parsed_options which: @@ -64,6 +75,17 @@ namespace boost { namespace program_options { /** Stores UTF8 encoded options that were passed to constructor, to avoid reverse conversion in some cases. */ basic_parsed_options<char> utf8_encoded_options; + + /** Mainly used for the diagnostic messages in exceptions. + * The canonical option prefix for the parser which generated these results, + * depending on the settings for basic_command_line_parser::style() or + * cmdline::style(). In order of precedence of command_line_style enums: + * allow_long + * allow_long_disguise + * allow_dash_for_short + * allow_slash_for_short + */ + int m_options_prefix; }; typedef basic_parsed_options<char> parsed_options; @@ -260,6 +282,10 @@ namespace boost { namespace program_options { }} +#if defined(BOOST_MSVC) +# pragma warning (pop) +#endif + #undef DECL #include "boost/program_options/detail/parsers.hpp" diff --git a/3rdParty/Boost/src/boost/program_options/value_semantic.hpp b/3rdParty/Boost/src/boost/program_options/value_semantic.hpp index 033009e..081e997 100644 --- a/3rdParty/Boost/src/boost/program_options/value_semantic.hpp +++ b/3rdParty/Boost/src/boost/program_options/value_semantic.hpp @@ -227,6 +227,13 @@ namespace boost { namespace program_options { return this; } + /** Specifies the name used to to the value in help message. */ + typed_value* value_name(const std::string& name) + { + m_value_name = name; + return this; + } + /** Specifies an implicit value, which will be used if the option is given, but without an adjacent value. Using this implies that an explicit value is optional, but if @@ -261,13 +268,21 @@ namespace boost { namespace program_options { return this; } - /** Specifies that the value can span multiple tokens. */ + /** Specifies that the value can span multiple tokens. + */ typed_value* multitoken() { m_multitoken = true; return this; } + /** Specifies that no tokens may be provided as the value of + this option, which means that only presense of the option + is significant. For such option to be useful, either the + 'validate' function should be specialized, or the + 'implicit_value' method should be also used. In most + cases, you can use the 'bool_switch' function instead of + using this method. */ typed_value* zero_tokens() { m_zero_tokens = true; @@ -346,6 +361,7 @@ namespace boost { namespace program_options { // Default value is stored as boost::any and not // as boost::optional to avoid unnecessary instantiations. + std::string m_value_name; boost::any m_default_value; std::string m_default_value_as_text; boost::any m_implicit_value; diff --git a/3rdParty/Boost/src/boost/program_options/variables_map.hpp b/3rdParty/Boost/src/boost/program_options/variables_map.hpp index 9621e05..be0a4b6 100644 --- a/3rdParty/Boost/src/boost/program_options/variables_map.hpp +++ b/3rdParty/Boost/src/boost/program_options/variables_map.hpp @@ -153,6 +153,9 @@ namespace boost { namespace program_options { // Resolve conflict between inherited operators. const variable_value& operator[](const std::string& name) const { return abstract_variables_map::operator[](name); } + + // Override to clear some extra fields. + void clear(); void notify(); @@ -171,8 +174,10 @@ namespace boost { namespace program_options { bool utf8); /** Names of required options, filled by parser which has - access to options_description. */ - std::set<std::string> m_required; + access to options_description. + The map values are the "canonical" names for each corresponding option. + This is useful in creating diagnostic messages when the option is absent. */ + std::map<std::string, std::string> m_required; }; @@ -208,4 +213,8 @@ namespace boost { namespace program_options { }} +#if defined(BOOST_MSVC) +# pragma warning (pop) +#endif + #endif |