Commit 6ecfdc74 authored by Dominik Charousset's avatar Dominik Charousset

Prefer 'invalid' over 'illegal' in enum constants

parent 8ccf92c9
...@@ -77,6 +77,11 @@ is based on [Keep a Changelog](https://keepachangelog.com). ...@@ -77,6 +77,11 @@ is based on [Keep a Changelog](https://keepachangelog.com).
argument). Furthermore, the state class can now provide a `make_behavior` argument). Furthermore, the state class can now provide a `make_behavior`
member function to initialize the actor (this has no effect for function-based member function to initialize the actor (this has no effect for function-based
actors). actors).
- In order to stay more consistent with naming conventions of the standard
library, we have renamed some values of the `pec` enumeration:
+ `illegal_escape_sequence` => `invalid_escape_sequence`
+ `illegal_argument` => `invalid_argument`
+ `illegal_category` => `invalid_category`
### Removed ### Removed
......
...@@ -87,7 +87,7 @@ public: ...@@ -87,7 +87,7 @@ public:
dispatch_parse_cli(ps, tmp, char_blacklist); dispatch_parse_cli(ps, tmp, char_blacklist);
if (ps.code <= pec::trailing_character) { if (ps.code <= pec::trailing_character) {
if (predicate_ && !predicate_(tmp)) if (predicate_ && !predicate_(tmp))
ps.code = pec::illegal_argument; ps.code = pec::invalid_argument;
else else
set_value(x, std::move(tmp)); set_value(x, std::move(tmp));
} }
......
...@@ -60,7 +60,7 @@ void read_string(State& ps, Consumer&& consumer) { ...@@ -60,7 +60,7 @@ void read_string(State& ps, Consumer&& consumer) {
transition(read_chars, 't', res += '\t') transition(read_chars, 't', res += '\t')
transition(read_chars, '\\', res += '\\') transition(read_chars, '\\', res += '\\')
transition(read_chars, '"', res += '"') transition(read_chars, '"', res += '"')
error_transition(pec::illegal_escape_sequence) error_transition(pec::invalid_escape_sequence)
} }
term_state(read_unquoted_chars) { term_state(read_unquoted_chars) {
transition(read_unquoted_chars, alphanumeric_chars, res += ch) transition(read_unquoted_chars, alphanumeric_chars, res += ch)
......
...@@ -45,7 +45,7 @@ enum class pec : uint8_t { ...@@ -45,7 +45,7 @@ enum class pec : uint8_t {
/// Too many characters for an atom. /// Too many characters for an atom.
too_many_characters, too_many_characters,
/// Unrecognized character after escaping `\`. /// Unrecognized character after escaping `\`.
illegal_escape_sequence, invalid_escape_sequence,
/// Misplaced newline, e.g., inside a string. /// Misplaced newline, e.g., inside a string.
unexpected_newline, unexpected_newline,
/// Parsed positive integer exceeds the number of available bits. /// Parsed positive integer exceeds the number of available bits.
...@@ -61,11 +61,11 @@ enum class pec : uint8_t { ...@@ -61,11 +61,11 @@ enum class pec : uint8_t {
/// Stopped at an unrecognized option name. /// Stopped at an unrecognized option name.
not_an_option, not_an_option,
/// Stopped at an unparsable argument. /// Stopped at an unparsable argument.
illegal_argument = 15, invalid_argument = 15,
/// Stopped because an argument was omitted. /// Stopped because an argument was omitted.
missing_argument, missing_argument,
/// Stopped because the key of a category was taken. /// Stopped because the key of a category was taken.
illegal_category, invalid_category,
/// Stopped at an unexpected field name while reading a user-defined type. /// Stopped at an unexpected field name while reading a user-defined type.
invalid_field_name, invalid_field_name,
/// Stopped at a repeated field name while reading a user-defined type. /// Stopped at a repeated field name while reading a user-defined type.
......
...@@ -145,7 +145,7 @@ auto config_option_set::parse(settings& config, argument_iterator first, ...@@ -145,7 +145,7 @@ auto config_option_set::parse(settings& config, argument_iterator first,
// Flags only consume the current element. // Flags only consume the current element.
if (opt.is_flag()) { if (opt.is_flag()) {
if (arg_begin != arg_end) if (arg_begin != arg_end)
return pec::illegal_argument; return pec::invalid_argument;
config_value cfg_true{true}; config_value cfg_true{true};
opt.store(cfg_true); opt.store(cfg_true);
entry[opt_name] = cfg_true; entry[opt_name] = cfg_true;
...@@ -159,7 +159,7 @@ auto config_option_set::parse(settings& config, argument_iterator first, ...@@ -159,7 +159,7 @@ auto config_option_set::parse(settings& config, argument_iterator first,
auto& err = val.error(); auto& err = val.error();
if (err.category() == error_category<pec>::value) if (err.category() == error_category<pec>::value)
return static_cast<pec>(err.code()); return static_cast<pec>(err.code());
return pec::illegal_argument; return pec::invalid_argument;
} }
entry[opt_name] = std::move(*val); entry[opt_name] = std::move(*val);
} }
......
...@@ -25,8 +25,8 @@ std::string to_string(pec x) { ...@@ -25,8 +25,8 @@ std::string to_string(pec x) {
return "fractional_timespan"; return "fractional_timespan";
case pec::too_many_characters: case pec::too_many_characters:
return "too_many_characters"; return "too_many_characters";
case pec::illegal_escape_sequence: case pec::invalid_escape_sequence:
return "illegal_escape_sequence"; return "invalid_escape_sequence";
case pec::unexpected_newline: case pec::unexpected_newline:
return "unexpected_newline"; return "unexpected_newline";
case pec::integer_overflow: case pec::integer_overflow:
...@@ -41,12 +41,12 @@ std::string to_string(pec x) { ...@@ -41,12 +41,12 @@ std::string to_string(pec x) {
return "type_mismatch"; return "type_mismatch";
case pec::not_an_option: case pec::not_an_option:
return "not_an_option"; return "not_an_option";
case pec::illegal_argument: case pec::invalid_argument:
return "illegal_argument"; return "invalid_argument";
case pec::missing_argument: case pec::missing_argument:
return "missing_argument"; return "missing_argument";
case pec::illegal_category: case pec::invalid_category:
return "illegal_category"; return "invalid_category";
case pec::invalid_field_name: case pec::invalid_field_name:
return "invalid_field_name"; return "invalid_field_name";
case pec::repeated_field_name: case pec::repeated_field_name:
......
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