Commit 42c1fe96 authored by Max Kellermann's avatar Max Kellermann

util/OptionParser: add "noexcept"

parent 465b154f
...@@ -22,7 +22,8 @@ ...@@ -22,7 +22,8 @@
#include <string.h> #include <string.h>
bool OptionParser::CheckOption(const OptionDef &opt) bool
OptionParser::CheckOption(const OptionDef &opt) const noexcept
{ {
assert(option != nullptr); assert(option != nullptr);
...@@ -35,7 +36,8 @@ bool OptionParser::CheckOption(const OptionDef &opt) ...@@ -35,7 +36,8 @@ bool OptionParser::CheckOption(const OptionDef &opt)
option[1] == '\0'; option[1] == '\0';
} }
bool OptionParser::ParseNext() bool
OptionParser::ParseNext() noexcept
{ {
assert(HasEntries()); assert(HasEntries());
char *arg = *argv; char *arg = *argv;
......
...@@ -39,18 +39,18 @@ public: ...@@ -39,18 +39,18 @@ public:
/** /**
* Constructs #OptionParser. * Constructs #OptionParser.
*/ */
OptionParser(int _argc, char **_argv) OptionParser(int _argc, char **_argv) noexcept
:argc(_argc - 1), argv(_argv + 1) {} :argc(_argc - 1), argv(_argv + 1) {}
/** /**
* Checks if there are command line entries to process. * Checks if there are command line entries to process.
*/ */
bool HasEntries() const { return argc > 0; } bool HasEntries() const noexcept { return argc > 0; }
/** /**
* Gets the last parsed option. * Gets the last parsed option.
*/ */
char *GetOption() { char *GetOption() noexcept {
assert(option_raw != nullptr); assert(option_raw != nullptr);
return option_raw; return option_raw;
} }
...@@ -58,13 +58,14 @@ public: ...@@ -58,13 +58,14 @@ public:
/** /**
* Checks if current option is a specified option. * Checks if current option is a specified option.
*/ */
bool CheckOption(const OptionDef& opt); bool CheckOption(const OptionDef &opt) const noexcept;
/** /**
* Checks if current option is a specified option * Checks if current option is a specified option
* or specified alternative option. * or specified alternative option.
*/ */
bool CheckOption(const OptionDef& opt, const OptionDef &alt_opt) { bool CheckOption(const OptionDef &opt,
const OptionDef &alt_opt) const noexcept {
return CheckOption(opt) || CheckOption(alt_opt); return CheckOption(opt) || CheckOption(alt_opt);
} }
...@@ -74,12 +75,12 @@ public: ...@@ -74,12 +75,12 @@ public:
* Regardless of result, advances current position to the next * Regardless of result, advances current position to the next
* command line entry. * command line entry.
*/ */
bool ParseNext(); bool ParseNext() noexcept;
/** /**
* Checks if specified string is a command line option. * Checks if specified string is a command line option.
*/ */
static bool IsOption(const char *s) { static bool IsOption(const char *s) noexcept {
assert(s != nullptr); assert(s != nullptr);
return s[0] == '-'; return s[0] == '-';
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment