class error_with_option_name
Declaration
class error_with_option_name : public error { /* full declaration omitted */ };Description
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)
Declared at: libs/pika/program_options/include/pika/program_options/errors.hpp:103
Inherits from: error
Member Variables
- protected int m_option_style
- can be 0 = no prefix (config file options) allow_long allow_dash_for_short allow_slash_for_short allow_long_disguise
- protected std::map<std::string, std::string> m_substitutions
- substitutions from placeholders to values
- protected std::map<std::string, string_pair> m_substitution_defaults
- public std::string m_error_template
- template with placeholders
- protected std::string m_message
- Used to hold the error text returned by what()
Method Overview
- public void add_context(const std::string & option_name, const std::string & original_token, int option_style)
- public error_with_option_name(const std::string & template_, const std::string & option_name = "", const std::string & original_token = "", int option_style = 0)
- protected std::string get_canonical_option_name() const
- protected std::string get_canonical_option_prefix() const
- public std::string get_option_name() const
- protected void replace_token(const std::string & from, const std::string & to) const
- public virtual void set_option_name(const std::string & option_name)
- public void set_original_token(const std::string & original_token)
- public void set_prefix(int option_style)
- public void set_substitute(const std::string & parameter_name, const std::string & value)
- public void set_substitute_default(const std::string & parameter_name, const std::string & from, const std::string & to)
- protected virtual void substitute_placeholders(const std::string & error_template) const
- public const char * what() const noexcept
- public ~error_with_option_name() noexcept
Inherited from error:
Methods
void add_context(
const std::string& option_name,
const std::string& original_token,
int option_style)
void add_context(
const std::string& option_name,
const std::string& original_token,
int option_style)Description
Add context to an exception
Declared at: libs/pika/program_options/include/pika/program_options/errors.hpp:152
Parameters
- const std::string& option_name
- const std::string& original_token
- int option_style
error_with_option_name(
const std::string& template_,
const std::string& option_name = "",
const std::string& original_token = "",
int option_style = 0)
error_with_option_name(
const std::string& template_,
const std::string& option_name = "",
const std::string& original_token = "",
int option_style = 0)Declared at: libs/pika/program_options/include/pika/program_options/errors.hpp:124
Parameters
- const std::string& template_
- const std::string& option_name = ""
- const std::string& original_token = ""
- int option_style = 0
std::string get_canonical_option_name() const
std::string get_canonical_option_name() constDescription
Construct option name in accordance with the appropriate prefix style: i.e. long dash or short slash etc
Declared at: libs/pika/program_options/include/pika/program_options/errors.hpp:200
std::string get_canonical_option_prefix() const
std::string get_canonical_option_prefix() constDeclared at: libs/pika/program_options/include/pika/program_options/errors.hpp:201
std::string get_option_name() const
std::string get_option_name() constDeclared at: libs/pika/program_options/include/pika/program_options/errors.hpp:172
void replace_token(const std::string& from,
const std::string& to) const
void replace_token(const std::string& from,
const std::string& to) constDeclared at: libs/pika/program_options/include/pika/program_options/errors.hpp:195
Parameters
- const std::string& from
- const std::string& to
virtual void set_option_name(
const std::string& option_name)
virtual void set_option_name(
const std::string& option_name)Description
Overridden in error_with_no_option_name
Declared at: libs/pika/program_options/include/pika/program_options/errors.hpp:167
Parameters
- const std::string& option_name
void set_original_token(
const std::string& original_token)
void set_original_token(
const std::string& original_token)Declared at: libs/pika/program_options/include/pika/program_options/errors.hpp:177
Parameters
- const std::string& original_token
void set_prefix(int option_style)
void set_prefix(int option_style)Declared at: libs/pika/program_options/include/pika/program_options/errors.hpp:161
Parameters
- int option_style
void set_substitute(
const std::string& parameter_name,
const std::string& value)
void set_substitute(
const std::string& parameter_name,
const std::string& value)Description
Substitute parameter_name->value to create the error message from the error template
Declared at: libs/pika/program_options/include/pika/program_options/errors.hpp:136
Parameters
- const std::string& parameter_name
- const std::string& value
void set_substitute_default(
const std::string& parameter_name,
const std::string& from,
const std::string& to)
void set_substitute_default(
const std::string& parameter_name,
const std::string& from,
const std::string& to)Description
If the parameter is missing, then make the from->to substitution instead
Declared at: libs/pika/program_options/include/pika/program_options/errors.hpp:144
Parameters
- const std::string& parameter_name
- const std::string& from
- const std::string& to
virtual void substitute_placeholders(
const std::string& error_template) const
virtual void substitute_placeholders(
const std::string& error_template) constDescription
Makes all substitutions using the template
Declared at: libs/pika/program_options/include/pika/program_options/errors.hpp:191
Parameters
- const std::string& error_template
const char* what() const noexcept
const char* what() const noexceptDescription
Creates the error_message on the fly Currently a thin wrapper for substitute_placeholders()
Declared at: libs/pika/program_options/include/pika/program_options/errors.hpp:184
~error_with_option_name() noexcept
~error_with_option_name() noexceptDescription
gcc says that throw specification on dtor is loosened without this line
Declared at: libs/pika/program_options/include/pika/program_options/errors.hpp:131