Main Page
Related Pages
Modules
Classes
All
Classes
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
error.hpp
1
// The MIT License (MIT)
2
3
// Copyright (c) 2012-2014 Danny Y., Rapptz
4
5
// Permission is hereby granted, free of charge, to any person obtaining a copy of
6
// this software and associated documentation files (the "Software"), to deal in
7
// the Software without restriction, including without limitation the rights to
8
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
// the Software, and to permit persons to whom the Software is furnished to do so,
10
// subject to the following conditions:
11
12
// The above copyright notice and this permission notice shall be included in all
13
// copies or substantial portions of the Software.
14
15
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22
#ifndef GEARS_OPTPARSE_ERROR_HPP
23
#define GEARS_OPTPARSE_ERROR_HPP
24
25
#include <string>
26
#include <stdexcept>
27
28
namespace
gears {
29
namespace
optparse {
40
class
error
:
public
std::runtime_error {
41
public
:
42
std::string program_name;
43
std::string option_name;
44
std::string error_string;
55
error
(
const
std::string& name,
const
std::string& str,
const
std::string& op):
56
std::runtime_error(name +
": error: "
+ str), program_name(name), option_name(op), error_string(str) {}
57
};
58
63
class
unrecognised_option
:
public
error
{
64
public
:
73
unrecognised_option
(
const
std::string& name,
const
std::string& op):
74
error
(name,
"unrecognised option '"
+ op +
'\''
, op) {}
75
};
76
81
class
missing_required_option
:
public
error
{
82
public
:
91
missing_required_option
(
const
std::string& name,
const
std::string& op):
92
error
(name,
"missing required option '"
+ op +
'\''
, op) {}
93
};
94
99
class
missing_required_value
:
public
error
{
100
public
:
114
missing_required_value
(
const
std::string& name,
const
std::string& op,
size_t
nargs):
115
error
(name, nargs == 1 ?
116
"option '"
+ op +
"' requires an argument"
:
117
"option '"
+ op +
"' requires "
+ std::to_string(nargs) +
" arguments"
, op) {}
118
};
119
124
class
option_takes_no_value
:
public
error
{
125
public
:
134
option_takes_no_value
(
const
std::string& name,
const
std::string& op):
135
error
(name,
"option '"
+ op +
"' does not take a value"
, op) {}
136
};
137
}
// optparse
138
}
// gears
139
140
#endif // GEARS_OPTPARSE_ERROR_HPP
Copyright © Danny Y. Documentation generated by
Doxygen