cfgfile 0.2.11
Loading...
Searching...
No Matches
exceptions.hpp
Go to the documentation of this file.
1
31#ifndef CFGFILE__EXCEPTIONS_HPP__INCLUDED
32#define CFGFILE__EXCEPTIONS_HPP__INCLUDED
33
34// C++ include.
35#include <stdexcept>
36
37// cfgfile include.
38#include "types.hpp"
39
40
41namespace cfgfile {
42
43//
44// exception_t
45//
46
48template< typename Trait = string_trait_t >
49class exception_t final
50 : public std::logic_error
51{
52public:
54 explicit exception_t( typename Trait::string_t what )
55 : std::logic_error( "Please use desc() method of the exception." )
56 , m_what( std::move( what ) )
57 {
58 }
59
60 ~exception_t() noexcept
61 {
62 }
63
65 const typename Trait::string_t & desc() const noexcept
66 {
67 return m_what;
68 }
69
70private:
72 typename Trait::string_t m_what;
73}; // class exception_t
74
75
76#ifndef CFGFILE_DISABLE_STL
77
78//
79// exception_t< string_trait_t >
80//
81
82template<>
84 : public std::logic_error
85{
86public:
89 : std::logic_error( what )
90 , m_what( std::move( what ) )
91 {
92 }
93
94 ~exception_t() noexcept
95 {
96 }
97
99 const string_trait_t::string_t & desc() const noexcept
100 {
101 return m_what;
102 }
103
104private:
107}; // class exception_t< string_trait_t >
108
109#endif // CFGFILE_DISABLE_STL
110
111} /* namespace cfgfile */
112
113#endif // CFGFILE__EXCEPTIONS_HPP__INCLUDED
~exception_t() noexcept
Definition exceptions.hpp:94
const string_trait_t::string_t & desc() const noexcept
Definition exceptions.hpp:99
exception_t(string_trait_t::string_t what)
Construct exception.
Definition exceptions.hpp:88
Exception in the library.
Definition exceptions.hpp:51
const Trait::string_t & desc() const noexcept
Definition exceptions.hpp:65
exception_t(typename Trait::string_t what)
Construct exception.
Definition exceptions.hpp:54
~exception_t() noexcept
Definition exceptions.hpp:60
Definition const.hpp:38
Trait for std::string support.
Definition types.hpp:170
std::string string_t
String type.
Definition types.hpp:172