mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 15:57:35 +00:00
AK: Remove the ctype adapters and use the actual ctype functions instead
This finally takes care of the kind-of excessive boilerplate code that were the ctype adapters. On the other hand, I had to link `LibC/ctype.cpp` to the Kernel (for `AK/JsonParser.cpp` and `AK/Format.cpp`). The previous commit actually makes sense now: the `string.h` includes in `ctype.{h,cpp}` would require to link more LibC stuff to the Kernel when it only needs the `_ctype_` array of `ctype.cpp`, and there wasn't any string stuff used in ctype. Instead of all this I could have put static derivatives of `is_any_of()` in the concerned AK files, however that would have meant more boilerplate and workarounds; so I went for the Kernel approach.
This commit is contained in:
parent
f158cb27ea
commit
f0f6b09acb
8 changed files with 33 additions and 125 deletions
|
@ -136,42 +136,12 @@ constexpr auto is_any_of(const StringView& values)
|
|||
return [values](auto c) { return values.contains(c); };
|
||||
}
|
||||
|
||||
/*
|
||||
* CType adapters: pass them as Conditions to a GenericLexer's methods
|
||||
* Examples:
|
||||
* - `if (lexer.next_is(is_digit))`
|
||||
* - `auto name = lexer.consume_while(is_alphanum);
|
||||
* - `lexer.ignore_until(is_any_of("<^>"))`
|
||||
*/
|
||||
bool is_alpha(char);
|
||||
bool is_alphanum(char);
|
||||
bool is_control(char);
|
||||
bool is_digit(char);
|
||||
bool is_graphic(char);
|
||||
bool is_hex_digit(char);
|
||||
bool is_lowercase(char);
|
||||
bool is_path_separator(char);
|
||||
bool is_printable(char);
|
||||
bool is_punctuation(char);
|
||||
bool is_quote(char);
|
||||
bool is_uppercase(char);
|
||||
bool is_whitespace(char);
|
||||
constexpr auto is_path_separator = is_any_of("/\\");
|
||||
constexpr auto is_quote = is_any_of("'\"");
|
||||
|
||||
}
|
||||
|
||||
using AK::GenericLexer;
|
||||
|
||||
using AK::is_alpha;
|
||||
using AK::is_alphanum;
|
||||
using AK::is_any_of;
|
||||
using AK::is_control;
|
||||
using AK::is_digit;
|
||||
using AK::is_graphic;
|
||||
using AK::is_hex_digit;
|
||||
using AK::is_lowercase;
|
||||
using AK::is_path_separator;
|
||||
using AK::is_printable;
|
||||
using AK::is_punctuation;
|
||||
using AK::is_quote;
|
||||
using AK::is_uppercase;
|
||||
using AK::is_whitespace;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue