writing parser
This commit is contained in:
parent
8a86fbc32f
commit
37122edba1
@ -91,6 +91,7 @@ Options::parse(int& argc, char**& argv)
|
||||
|
||||
if (iter == m_short.end())
|
||||
{
|
||||
throw option_not_exists_exception(name);
|
||||
//argument not found
|
||||
}
|
||||
|
||||
@ -111,6 +112,7 @@ Options::parse(int& argc, char**& argv)
|
||||
else
|
||||
{
|
||||
//error
|
||||
throw option_requires_argument_exception(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -123,6 +125,7 @@ Options::parse(int& argc, char**& argv)
|
||||
|
||||
if (iter == m_long.end())
|
||||
{
|
||||
throw option_not_exists_exception(name);
|
||||
}
|
||||
|
||||
auto opt = iter->second;
|
||||
|
||||
@ -98,6 +98,24 @@ namespace cxxopts
|
||||
}
|
||||
};
|
||||
|
||||
class option_not_exists_exception : public OptionParseException
|
||||
{
|
||||
public:
|
||||
option_not_exists_exception(const std::string& option)
|
||||
: OptionParseException(u8"Option ‘" + option + u8"’ does not exist")
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class option_requires_argument_exception : public OptionParseException
|
||||
{
|
||||
public:
|
||||
option_requires_argument_exception(const std::string& option)
|
||||
: OptionParseException(u8"Option ‘" + option + u8"’ requires an argument")
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class OptionAdder;
|
||||
|
||||
class OptionDetails
|
||||
|
||||
Loading…
Reference in New Issue
Block a user