Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::program_options::error_with_option_name Class Reference

Base class for most exceptions in the library. More...

#include <errors.hpp>

Inheritance diagram for boost::program_options::error_with_option_name:
Collaboration diagram for boost::program_options::error_with_option_name:

Public Member Functions

 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 () throw ()
 gcc says that throw specification on dtor is loosened without this line More...
 
void set_substitute (const std::string &parameter_name, const std::string &value)
 Substitute parameter_name->value to create the error message from the error template. More...
 
void set_substitute_default (const std::string &parameter_name, const std::string &from, const std::string &to)
 If the parameter is missing, then make the from->to substitution instead. More...
 
void add_context (const std::string &option_name, const std::string &original_token, int option_style)
 Add context to an exception. More...
 
void set_prefix (int option_style)
 
virtual void set_option_name (const std::string &option_name)
 Overridden in error_with_no_option_name. More...
 
std::string get_option_name () const throw ()
 
void set_original_token (const std::string &original_token)
 
virtual const char * what () const throw ()
 Creates the error_message on the fly Currently a thin wrapper for substitute_placeholders() More...
 

Public Attributes

std::string m_error_template
 template with placeholders More...
 

Protected Types

typedef std::pair< std::string,
std::string > 
string_pair
 

Protected Member Functions

virtual void substitute_placeholders (const std::string &error_template) const
 Makes all substitutions using the template. More...
 
void replace_token (const std::string &from, const std::string &to) const
 
std::string get_canonical_option_name () const
 Construct option name in accordance with the appropriate prefix style: i.e. More...
 
std::string get_canonical_option_prefix () const
 

Protected Attributes

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 More...
 
std::map< std::string,
std::string > 
m_substitutions
 substitutions from placeholders to values More...
 
std::map< std::string,
string_pair
m_substitution_defaults
 
std::string m_message
 Used to hold the error text returned by what() More...
 

Detailed 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)

Member Typedef Documentation

typedef std::pair<std::string, std::string> boost::program_options::error_with_option_name::string_pair
protected

Constructor & Destructor Documentation

boost::program_options::error_with_option_name::error_with_option_name ( const std::string &  template_,
const std::string &  option_name = "",
const std::string &  original_token = "",
int  option_style = 0 
)
boost::program_options::error_with_option_name::~error_with_option_name ( )
throw (
)
inline

gcc says that throw specification on dtor is loosened without this line

Member Function Documentation

void boost::program_options::error_with_option_name::add_context ( const std::string &  option_name,
const std::string &  original_token,
int  option_style 
)
inline

Add context to an exception.

std::string boost::program_options::error_with_option_name::get_canonical_option_name ( ) const
protected

Construct option name in accordance with the appropriate prefix style: i.e.

long dash or short slash etc

std::string boost::program_options::error_with_option_name::get_canonical_option_prefix ( ) const
protected
std::string boost::program_options::error_with_option_name::get_option_name ( ) const
throw (
)
inline
void boost::program_options::error_with_option_name::replace_token ( const std::string &  from,
const std::string &  to 
) const
protected
virtual void boost::program_options::error_with_option_name::set_option_name ( const std::string &  option_name)
inlinevirtual
void boost::program_options::error_with_option_name::set_original_token ( const std::string &  original_token)
inline
void boost::program_options::error_with_option_name::set_prefix ( int  option_style)
inline
void boost::program_options::error_with_option_name::set_substitute ( const std::string &  parameter_name,
const std::string &  value 
)
inline

Substitute parameter_name->value to create the error message from the error template.

References boost::program_options::value().

void boost::program_options::error_with_option_name::set_substitute_default ( const std::string &  parameter_name,
const std::string &  from,
const std::string &  to 
)
inline

If the parameter is missing, then make the from->to substitution instead.

References boost::xpressive::make_pair.

virtual void boost::program_options::error_with_option_name::substitute_placeholders ( const std::string &  error_template) const
protectedvirtual

Makes all substitutions using the template.

Reimplemented in boost::program_options::ambiguous_option.

virtual const char* boost::program_options::error_with_option_name::what ( ) const
throw (
)
virtual

Creates the error_message on the fly Currently a thin wrapper for substitute_placeholders()

Member Data Documentation

std::string boost::program_options::error_with_option_name::m_error_template

template with placeholders

std::string boost::program_options::error_with_option_name::m_message
mutableprotected

Used to hold the error text returned by what()

int boost::program_options::error_with_option_name::m_option_style
protected

can be 0 = no prefix (config file options) allow_long allow_dash_for_short allow_slash_for_short allow_long_disguise

std::map<std::string, string_pair > boost::program_options::error_with_option_name::m_substitution_defaults
protected
std::map<std::string, std::string> boost::program_options::error_with_option_name::m_substitutions
protected

substitutions from placeholders to values


The documentation for this class was generated from the following file: