Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/jarro2783/cxxopts.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEyal Rozenberg <eyalroz1@gmx.com>2022-07-12 23:49:04 +0300
committerGitHub <noreply@github.com>2022-07-12 23:49:04 +0300
commit9cd015ac3765220030f4db1a78b6ec98dfa58439 (patch)
treefd2f6442cf64612d3da1e132f922c1cef577549e
parent628dc9202b4a0f0d8eb1fae357a452d85278a73b (diff)
Regards #340, #345: Removed unnecessary indentation of exceptions namespace + added end-of-namespace comment (#351)
-rw-r--r--include/cxxopts.hpp246
1 files changed, 124 insertions, 122 deletions
diff --git a/include/cxxopts.hpp b/include/cxxopts.hpp
index 47693ed..4e18ec1 100644
--- a/include/cxxopts.hpp
+++ b/include/cxxopts.hpp
@@ -371,154 +371,156 @@ class Value : public std::enable_shared_from_this<Value>
#pragma GCC diagnostic pop
#endif
namespace exceptions {
- class exception : public std::exception
- {
- public:
- explicit exception(std::string message)
- : m_message(std::move(message))
- {
- }
- CXXOPTS_NODISCARD
- const char*
- what() const noexcept override
- {
- return m_message.c_str();
- }
-
- private:
- std::string m_message;
- };
+class exception : public std::exception
+{
+ public:
+ explicit exception(std::string message)
+ : m_message(std::move(message))
+ {
+ }
- class specification : public exception
+ CXXOPTS_NODISCARD
+ const char*
+ what() const noexcept override
{
- public:
+ return m_message.c_str();
+ }
- explicit specification(const std::string& message)
- : exception(message)
- {
- }
- };
+ private:
+ std::string m_message;
+};
- class parsing : public exception
- {
- public:
- explicit parsing(const std::string& message)
- : exception(message)
- {
- }
- };
+class specification : public exception
+{
+ public:
- class option_already_exists : public specification
+ explicit specification(const std::string& message)
+ : exception(message)
{
- public:
- explicit option_already_exists(const std::string& option)
- : specification("Option " + LQUOTE + option + RQUOTE + " already exists")
- {
- }
- };
+ }
+};
- class invalid_option_format : public specification
+class parsing : public exception
+{
+ public:
+ explicit parsing(const std::string& message)
+ : exception(message)
{
- public:
- explicit invalid_option_format(const std::string& format)
- : specification("Invalid option format " + LQUOTE + format + RQUOTE)
- {
- }
- };
+ }
+};
- class invalid_option_syntax : public parsing {
- public:
- explicit invalid_option_syntax(const std::string& text)
- : parsing("Argument " + LQUOTE + text + RQUOTE +
- " starts with a - but has incorrect syntax")
- {
- }
- };
+class option_already_exists : public specification
+{
+ public:
+ explicit option_already_exists(const std::string& option)
+ : specification("Option " + LQUOTE + option + RQUOTE + " already exists")
+ {
+ }
+};
- class no_such_option : public parsing
+class invalid_option_format : public specification
+{
+ public:
+ explicit invalid_option_format(const std::string& format)
+ : specification("Invalid option format " + LQUOTE + format + RQUOTE)
{
- public:
- explicit no_such_option(const std::string& option)
- : parsing("Option " + LQUOTE + option + RQUOTE + " does not exist")
- {
- }
- };
+ }
+};
- class missing_argument : public parsing
+class invalid_option_syntax : public parsing {
+ public:
+ explicit invalid_option_syntax(const std::string& text)
+ : parsing("Argument " + LQUOTE + text + RQUOTE +
+ " starts with a - but has incorrect syntax")
{
- public:
- explicit missing_argument(const std::string& option)
- : parsing(
- "Option " + LQUOTE + option + RQUOTE + " is missing an argument"
- )
- {
- }
- };
+ }
+};
- class option_requires_argument : public parsing
+class no_such_option : public parsing
+{
+ public:
+ explicit no_such_option(const std::string& option)
+ : parsing("Option " + LQUOTE + option + RQUOTE + " does not exist")
{
- public:
- explicit option_requires_argument(const std::string& option)
- : parsing(
- "Option " + LQUOTE + option + RQUOTE + " requires an argument"
- )
- {
- }
- };
+ }
+};
- class gratuitous_argument_for_option : public parsing
+class missing_argument : public parsing
+{
+ public:
+ explicit missing_argument(const std::string& option)
+ : parsing(
+ "Option " + LQUOTE + option + RQUOTE + " is missing an argument"
+ )
{
- public:
- gratuitous_argument_for_option
- (
- const std::string& option,
- const std::string& arg
+ }
+};
+
+class option_requires_argument : public parsing
+{
+ public:
+ explicit option_requires_argument(const std::string& option)
+ : parsing(
+ "Option " + LQUOTE + option + RQUOTE + " requires an argument"
)
- : parsing(
- "Option " + LQUOTE + option + RQUOTE +
- " does not take an argument, but argument " +
- LQUOTE + arg + RQUOTE + " given"
- )
- {
- }
- };
+ {
+ }
+};
- class requested_option_not_present : public parsing
+class gratuitous_argument_for_option : public parsing
+{
+ public:
+ gratuitous_argument_for_option
+ (
+ const std::string& option,
+ const std::string& arg
+ )
+ : parsing(
+ "Option " + LQUOTE + option + RQUOTE +
+ " does not take an argument, but argument " +
+ LQUOTE + arg + RQUOTE + " given"
+ )
{
- public:
- explicit requested_option_not_present(const std::string& option)
- : parsing("Option " + LQUOTE + option + RQUOTE + " not present")
- {
- }
- };
+ }
+};
- class option_has_no_value : public exception
+class requested_option_not_present : public parsing
+{
+ public:
+ explicit requested_option_not_present(const std::string& option)
+ : parsing("Option " + LQUOTE + option + RQUOTE + " not present")
{
- public:
- explicit option_has_no_value(const std::string& option)
- : exception(
- !option.empty() ?
- ("Option " + LQUOTE + option + RQUOTE + " has no value") :
- "Option has no value")
- {
- }
- };
+ }
+};
- class incorrect_argument_type : public parsing
+class option_has_no_value : public exception
+{
+ public:
+ explicit option_has_no_value(const std::string& option)
+ : exception(
+ !option.empty() ?
+ ("Option " + LQUOTE + option + RQUOTE + " has no value") :
+ "Option has no value")
{
- public:
- explicit incorrect_argument_type
- (
- const std::string& arg
+ }
+};
+
+class incorrect_argument_type : public parsing
+{
+ public:
+ explicit incorrect_argument_type
+ (
+ const std::string& arg
+ )
+ : parsing(
+ "Argument " + LQUOTE + arg + RQUOTE + " failed to parse"
)
- : parsing(
- "Argument " + LQUOTE + arg + RQUOTE + " failed to parse"
- )
- {
- }
- };
-}
+ {
+ }
+};
+
+} // namespace exceptions
template <typename T>
void throw_or_mimic(const std::string& text)