chsvlib
chsv helper source code
ChsvCodeExceptionTempl< errc > Struct Template Reference

A template defining classes depending on the specified chsvlib error code. . More...

#include <chsvexception.h>

Inheritance diagram for ChsvCodeExceptionTempl< errc >:
Collaboration diagram for ChsvCodeExceptionTempl< errc >:

Classes

struct  noformat
 A type used to overload protected formatting methods in order to turn off the Printf formatting. More...
 

Public Types

typedef chsverror_t code_t
 A type alias for an error code type.
 
- Public Types inherited from Exception
enum  vararg_tag_t { vararg_tag }
 

Public Member Functions

 ChsvCodeExceptionTempl () noexcept
 
template<class char_t >
 ChsvCodeExceptionTempl (Exception::vararg_tag_t, const char_t *restrict pszUserDescription, std::va_list ap) noexcept
 Constructs an exception object of the specified (by class template parameter) type. The description, the constructed object is associated with, is constructed as specified using the format string and additional parameters, as specified by the Chusov::String::Printf function. Also, the <DESCRIPTION> tag can be specified in the format string to be changed by the string returned by the Chusov::ChsvErrorDescriptionW function for the error code. . More...
 
template<class char_t , class ... DescriptionFormatParams>
 ChsvCodeExceptionTempl (const char_t *restrict pszUserDescription, DescriptionFormatParams ... formatting_params) noexcept
 Constructs an exception object of the specified (by the class template parameter) type. The description, the constructed object is associated with, is constructed as specified using the format string and additional parameters, as specified by the Chusov::String::Printf function. Also, the <DESCRIPTION> tag can be specified in the format string to be changed by the string returned by the Chusov::ChsvErrorDescriptionW function for the error code. . More...
 
template<class char_t , class traits_t , class alloc_t >
 ChsvCodeExceptionTempl (const std::basic_string< char_t, traits_t, alloc_t > &strDescription) noexcept
 Constructs an exception object with the description copied directly from a value of std::basic_string object, without any formatting. If the string is empty, the constructed exception description is a value returned by the Chusov::ChsvErrorDescriptionW function. . More...
 
 ChsvCodeExceptionTempl (const ChsvCodeExceptionTempl &)=default
 A standard copy constructor.
 
 ChsvCodeExceptionTempl (ChsvCodeExceptionTempl &&rr)=default
 A standard move constructor.
 
- Public Member Functions inherited from ExceptionWithGenericCode< code_t, class >
template<class char_t , class fn_t , class = decltype(std::declval<fn_t&&>()(std::declval<code_t>()))>
 ExceptionWithGenericCode (code_t nCode, fn_t &&GetDescription, Exception::vararg_tag_t, const char_t *restrict lpszDescriptionFormat, std::va_list ap) noexcept
 Constructs an exception object by a specified error code, a functor, mapping the code to a description text, a format string and parameters for the formatting as specified by the Chusov::String::Printf function. . More...
 
template<class char_t >
 ExceptionWithGenericCode (code_t nCode, Exception::vararg_tag_t, const char_t *restrict lpszDescriptionFormat, std::va_list ap) noexcept
 Constructs an exception object by a specified error code, a format string and Printf formatting parameters. . More...
 
template<class char_t , class fn_t , class = decltype(std::declval<fn_t>()(code_t())), class ... DescriptionFormatParams>
 ExceptionWithGenericCode (code_t nCode, fn_t &&GetDescription, const char_t *restrict lpszDescriptionFormat, DescriptionFormatParams ... formatting_params) noexcept
 Constructs an exception object by a specified error code, a functor, mapping the code to a description text, a format string and parameters for the formatting as specified by the Chusov::String::Printf function. . More...
 
template<class char_t , class ... DescriptionFormatParams>
 ExceptionWithGenericCode (code_t nCode, const char_t *restrict lpszDescriptionFormat, DescriptionFormatParams ... formatting_params) noexcept
 Constructs an exception object with a specified error code, a format string and parameters for the formatting as specified by the Chusov::String::Printf function. . More...
 
template<class char_t , class ... DescriptionFormatParams>
 ExceptionWithGenericCode (code_t nCode, std::nullptr_t, const char_t *restrict lpszDescriptionFormat, DescriptionFormatParams ... formatting_params) noexcept
 Constructs an exception object with a specified error code, a format string and parameters for the formatting as specified by the Chusov::String::Printf function. . More...
 
template<class fn_t , class = decltype(std::declval<fn_t&&>()(std::declval<code_t>()))>
 ExceptionWithGenericCode (code_t nCode, fn_t &&GetDescription) noexcept
 Constructs an exception object by a specified error code and a functor, mapping the code to a textual description. More...
 
 ExceptionWithGenericCode (code_t nCode) noexcept
 Constructs an exception object with the specified error code. . More...
 
template<class fn_t , class char_t , class traits_t , class alloc_t , class = decltype(std::declval<fn_t>()(code_t()))>
 ExceptionWithGenericCode (code_t nCode, fn_t &&GetDescription, const std::basic_string< char_t, traits_t, alloc_t > &strDescriptionFormat) noexcept
 Constructs an exception object by a specified error code, and an std::basic_string string object. . More...
 
template<class char_t , class traits_t , class alloc_t >
 ExceptionWithGenericCode (code_t nCode, const std::basic_string< char_t, traits_t, alloc_t > &strDescriptionFormat) noexcept
 Constructs an exception object by a specified error code, and a description provided by an std::basic_string object. . More...
 
template<class char_t , class traits_t , class alloc_t >
 ExceptionWithGenericCode (code_t nCode, std::nullptr_t, const std::basic_string< char_t, traits_t, alloc_t > &strDescriptionFormat) noexcept
 Constructs an exception object by a specified error code, and a description provided by an std::basic_string object. . More...
 
 ExceptionWithGenericCode (const ExceptionWithGenericCode &refRight)=default
 Default copy constructor.
 
 ExceptionWithGenericCode (ExceptionWithGenericCode &&refRight)=default
 Default move constructor.
 
code_t Code () const noexcept
 Returns an error code, the exception object is bound with.
 
- Public Member Functions inherited from Exception
 Exception ()=default
 Construct a default exception object without specified description. The default description is a valid but unspecified C string.
 
template<class ... DescriptionFormatParams>
 Exception (const char *restrict lpszDescriptionFormat, DescriptionFormatParams ... formatting_params) noexcept
 Constructs an exception object with an optional description, specified by Chusov::String::PrintfA formatting rules. More...
 
template<class ... DescriptionFormatParams>
 Exception (const wchar_t *restrict lpszDescriptionFormat, DescriptionFormatParams ... formatting_params) noexcept
 Constructs an exception object with an optional description, specified by Chusov::String::PrintfW formatting rules. More...
 
 Exception (vararg_tag_t, const char *restrict lpszDescriptionFormat, std::va_list ap) noexcept
 Constructs an exception object with an optional description, specified by Chusov::String::PrintfA formatting rules. More...
 
 Exception (vararg_tag_t, const wchar_t *restrict lpszDescriptionFormat, std::va_list ap) noexcept
 Constructs an exception object with an optional description, specified by Chusov::String::PrintfW formatting rules. More...
 
template<class traits_t , class alloc_t >
 Exception (const std::basic_string< char, traits_t, alloc_t > &strDescription) noexcept
 Constructs an exception based on a textual description, represented as a multi-byte std::basic_string object. More...
 
template<class traits_t , class alloc_t >
 Exception (const std::basic_string< wchar_t, traits_t, alloc_t > &strDescription) noexcept
 Constructs an exception based on a textual description, represented as a wide std::basic_string object. More...
 
 Exception (const Exception &refRight)=default
 Standard copy constructor.
 
 Exception (Exception &&ex)=default
 Standard move constructor.
 
template<class StdExcept , class = std::enable_if_t<Implementation::is_std_except<StdExcept>::value>>
 Exception (StdExcept &&ex) noexcept
 
virtual ~Exception () noexcept
 A default destructor.
 
Exceptionoperator= (const Exception &)=default
 Standard copy assignment operator.
 
Exceptionoperator= (Exception &&)=default
 Standard move assignment operator.
 
virtual const char * what () const noexcept
 Returns a description, corresponding to the exception, represented as a multi-byte string constructed using the current locale.
 
virtual const wchar_t * What () const noexcept
 Returns a description, corresponding to the exception, represented as a wide string.
 

Static Public Member Functions

template<class char_t >
static const char_t * get_description (code_t nErr) noexcept
 A unary function wrapped around the Chusov::ChsvErrorDescription function in order for the latter to be provided as a function object mapping an integral error code to a string description to replace <DESCRIPTION> tags during by-tag formatting of an exception description. More...
 

Protected Types

enum class  DoNotConstruct { DO_NOT_CONSTRUCT }
 A type of the parameter of the protected ChsvCodeExceptionTempl(DoNotConstruct) constructor.
 

Protected Member Functions

template<class char_t >
void SetDescription (noformat, const char_t *pszDescription) noexcept
 Sets a new description for the class object. The description is bound to the exception without any formatting. More...
 
template<class char_t >
void SetDescription (const Chusov::String::TAG_DESCRIPTION_PARAM< char_t > *restrict pTags, std::size_t cTags, Exception::vararg_tag_t, const char_t *restrict pszDescriptionFormat, std::va_list ap) noexcept
 Sets a new description for the class object. The description is specified by Printf formatting sequences and by tags. More...
 
template<class char_t , class ... DescriptionFormatParams>
void SetDescription (const Chusov::String::TAG_DESCRIPTION_PARAM< char_t > *restrict pTags, std::size_t cTags, const char_t *restrict pszDescriptionFormat, DescriptionFormatParams ... formatting_params) noexcept
 Sets a new description for the class object. The description is specified by Printf formatting sequences and by tags. More...
 
template<class char_t >
auto SetDescription (Exception::vararg_tag_t, const char_t *restrict pszDescriptionFormat, std::va_list ap) noexcept -> std::enable_if_t< std::is_integral< char_t >::value >
 Sets a result of the Printf formatting as a new description for the exception object. More...
 
template<class char_t , class ... DescriptionFormatParams>
auto SetDescription (const char_t *restrict pszDescriptionFormat, DescriptionFormatParams ... formatting_params) noexcept -> std::enable_if_t< std::is_integral< char_t >::value >
 Sets a result of the Printf formatting as a new description for the exception object. More...
 
void SetDescription ()
 Sets the default description for the exception object stating that textual definition, which is returned by what method is unspecified.
 
 ChsvCodeExceptionTempl (DoNotConstruct)
 A constructor that does not do anything except for calling default constructors for the parent class. It is used to avoid unnecessary operations performed by the default constructor, and to let the inheritors of the class instance to call the ExceptionWithGenericCode::SetCodeAndDescription method to construct the description. .
 
- Protected Member Functions inherited from ExceptionWithGenericCode< code_t, class >
 ExceptionWithGenericCode ()=default
 A default protected constructor of the exception object.
 
template<class char_t >
auto SetCodeAndDescription (code_t nCode, const char_t *lpszDescription) noexcept -> std::enable_if_t< std::is_integral< char_t >::value >
 Sets a new error code and description without any formatting. More...
 
template<class char_t , class fn_t , class = decltype(std::declval<fn_t&&>()(std::declval<code_t>()))>
auto SetCodeAndDescription (code_t nCode, fn_t &&GetDescription, const String::TAG_DESCRIPTION_PARAM< char_t > *restrict pTags, std::size_t cTags, noprintf, const char_t *restrict lpszDescriptionFormat) noexcept -> std::enable_if_t< std::is_integral< char_t >::value, decltype(void(std::declval< fn_t && >()(std::declval< code_t >())))>
 Sets a new exception description, according to the specified error code, formatting rules and a functor object mapping the error code to its default string description. . More...
 
template<class char_t , class fn_t , class = decltype(std::declval<fn_t&&>()(std::declval<code_t>()))>
auto SetCodeAndDescription (code_t nCode, fn_t &&GetDescription, const String::TAG_DESCRIPTION_PARAM< char_t > *restrict pTags, std::size_t cTags, Exception::vararg_tag_t, const char_t *restrict lpszDescriptionFormat, std::va_list ap) noexcept -> std::enable_if_t< std::is_integral< char_t >::value, decltype(void(std::declval< fn_t && >()(std::declval< code_t >())))>
 Sets a new exception description, according to the specified error code, formatting rules (with custom tags), variadic list of parameters and a function object mapping the error code to its default string description. . More...
 
template<class char_t , class fn_t , class = decltype(std::declval<fn_t&&>()(std::declval<code_t>()))>
auto SetCodeAndDescription (code_t nCode, fn_t &&GetDescription, Exception::vararg_tag_t, const char_t *restrict lpszDescriptionFormat, std::va_list ap) noexcept -> std::enable_if_t< std::is_integral< char_t >::value, decltype(void(std::declval< fn_t && >()(std::declval< code_t >())))>
 Sets a new exception description, according to the specified error code, formatting rules (without tag customization), variadic list of parameters and a function object mapping the error code to its default string description. More...
 
template<class char_t >
auto SetCodeAndDescription (code_t nCode, Exception::vararg_tag_t, const char_t *restrict lpszDescriptionFormat, std::va_list ap) noexcept -> std::enable_if_t< std::is_integral< char_t >::value >
 Sets a new exception description, according to the specified error code, formatting rules (without tag customization), variadic list of parameters and a function object mapping the error code to its default string description. More...
 
template<class char_t , class fn_t , class ... DescriptionFormatParams>
auto SetCodeAndDescription (code_t nCode, fn_t &&GetDescription, const String::TAG_DESCRIPTION_PARAM< char_t > *restrict pTags, std::size_t cTags, const char_t *restrict lpszDescriptionFormat, DescriptionFormatParams ... formatting_params) noexcept -> std::enable_if_t< std::is_integral< char_t >::value &&Chusov::String::is_valid_printf_type_set_v< DescriptionFormatParams... >, decltype(void(std::declval< fn_t && >()(std::declval< code_t >())))>
 Sets a new exception description, according to the specified error code, formatting rules (with custom tags), formatting parameter pack and a functor object mapping the error code to its default string description. . More...
 
template<class char_t , class fn_t , class ... DescriptionFormatParams>
auto SetCodeAndDescription (code_t nCode, fn_t &&GetDescription, const char_t *restrict lpszDescriptionFormat, DescriptionFormatParams ... formatting_params) noexcept -> std::enable_if_t< std::is_integral< char_t >::value &&Chusov::String::is_valid_printf_type_set_v< DescriptionFormatParams... >, decltype(void(std::declval< fn_t && >()(std::declval< code_t >())))>
 Sets a new exception description, according to the specified error code, formatting rules (without tag customization), formatting parameter pack and a functor object mapping the error code to its default string description. More...
 
template<class char_t , class ... DescriptionFormatParams>
auto SetCodeAndDescription (code_t nCode, const char_t *restrict lpszDescriptionFormat, DescriptionFormatParams ... formatting_params) noexcept -> std::enable_if_t< Chusov::String::is_valid_printf_type_set_v< DescriptionFormatParams... >>
 Sets a new exception description, according to the specified error code, formatting rules (without tag customization), variadic list of parameters and a function object mapping the error code to its default string description. More...
 
- Protected Member Functions inherited from Exception
void SetWhat (wchar_t *lpszOwnedWhat) noexcept
 
void SetWhat (char *lpszOwnedWhat) noexcept
 

Additional Inherited Members

- Static Protected Member Functions inherited from ExceptionWithGenericCode< code_t, class >
template<class char_t >
static const char_t * GetDefaultDescription (code_t) noexcept
 A default function object as a stub for methods that do not specify user-defined functors. It maps any integral code to a NULL description. More...
 

Detailed Description

template<chsverror_t errc>
struct Chusov::Exceptions::ChsvCodeExceptionTempl< errc >

A template defining classes depending on the specified chsvlib error code. .

Template Parameters
errcis a constant numeric value of an error code, the generated class instance is to be associated with. See Error handling for existing error codes.

There are aliases for the template instantiations given for the existing chsvlib error codes. See predefined exceptions.

Public constructors of the class always generate descriptions for the error code, either user-defined or the one generated by a call to the Chusov::ChsvErrorDescriptionW function.

User-defined strings may specify <CODE> and <DESCRIPTION> tags which are replaced by a numeric value of the error code and by its corresponding description respectively.

See also
ChsvExceptionByChsvCode(chsverror_t nCode, const char* restrict pszDescription, DescriptionFormatParams ... formatting_params);
ChsvExceptionByChsvCode(chsverror_t nCode, const wchar_t* restrict pszDescription, DescriptionFormatParams... formatting_params);
Chusov::Exceptions::ChsvExceptionByChsvCode(chsverror_t nCode);
Chusov::Exceptions::ChsvExceptionByChsvCode().

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