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::invalid_syntax Class Reference

Class thrown when there's syntax error either for command line or config file options. More...

#include <errors.hpp>

Inheritance diagram for boost::program_options::invalid_syntax:
Collaboration diagram for boost::program_options::invalid_syntax:

Public Types

enum  kind_t {
  long_not_allowed = 30,
  long_adjacent_not_allowed,
  short_adjacent_not_allowed,
  empty_adjacent_parameter,
  missing_parameter,
  extra_parameter,
  unrecognized_line
}
 

Public Member Functions

 invalid_syntax (kind_t kind, const std::string &option_name="", const std::string &original_token="", int option_style=0)
 
 ~invalid_syntax () throw ()
 
kind_t kind () const
 
virtual std::string tokens () const
 Convenience functions for backwards compatibility. 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

std::string get_template (kind_t kind)
 Used to convert kind_t to a related error text. More...
 
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

kind_t m_kind
 
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

Class thrown when there's syntax error either for command line or config file options.

See derived children for concrete classes.

Member Typedef Documentation

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

Member Enumeration Documentation

Enumerator
long_not_allowed 
long_adjacent_not_allowed 
short_adjacent_not_allowed 
empty_adjacent_parameter 
missing_parameter 
extra_parameter 
unrecognized_line 

Constructor & Destructor Documentation

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

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

Add context to an exception.

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

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
protectedinherited
std::string boost::program_options::error_with_option_name::get_option_name ( ) const
throw (
)
inlineinherited
std::string boost::program_options::invalid_syntax::get_template ( kind_t  kind)
protected

Used to convert kind_t to a related error text.

kind_t boost::program_options::invalid_syntax::kind ( ) const
inline
void boost::program_options::error_with_option_name::replace_token ( const std::string &  from,
const std::string &  to 
) const
protectedinherited
virtual void boost::program_options::error_with_option_name::set_option_name ( const std::string &  option_name)
inlinevirtualinherited
void boost::program_options::error_with_option_name::set_original_token ( const std::string &  original_token)
inlineinherited
void boost::program_options::error_with_option_name::set_prefix ( int  option_style)
inlineinherited
void boost::program_options::error_with_option_name::set_substitute ( const std::string &  parameter_name,
const std::string &  value 
)
inlineinherited

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

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
protectedvirtualinherited

Makes all substitutions using the template.

Reimplemented in boost::program_options::ambiguous_option.

virtual std::string boost::program_options::invalid_syntax::tokens ( ) const
inlinevirtual

Convenience functions for backwards compatibility.

Reimplemented in boost::program_options::invalid_config_file_syntax.

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

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
inherited

template with placeholders

kind_t boost::program_options::invalid_syntax::m_kind
protected
std::string boost::program_options::error_with_option_name::m_message
mutableprotectedinherited

Used to hold the error text returned by what()

int boost::program_options::error_with_option_name::m_option_style
protectedinherited

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
protectedinherited
std::map<std::string, std::string> boost::program_options::error_with_option_name::m_substitutions
protectedinherited

substitutions from placeholders to values


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