1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:48:11 +00:00

LibPDF: Add Reader::consume_non_eol_whitespace()

This commit is contained in:
Nico Weber 2024-01-03 17:28:46 -05:00 committed by Andreas Kling
parent c59e08123b
commit efb37f7252
2 changed files with 24 additions and 1 deletions

View file

@ -15,9 +15,14 @@ bool Reader::is_eol(char c)
} }
bool Reader::is_whitespace(char c) bool Reader::is_whitespace(char c)
{
return is_eol(c) || is_non_eol_whitespace(c);
}
bool Reader::is_non_eol_whitespace(char c)
{ {
// 3.1.1 Character Set // 3.1.1 Character Set
return is_eol(c) || c == 0 || c == 0x9 || c == 0xc || c == ' '; return c == 0 || c == 0x9 || c == 0xc || c == ' ';
} }
bool Reader::matches_eol() const bool Reader::matches_eol() const
@ -30,6 +35,11 @@ bool Reader::matches_whitespace() const
return !done() && is_whitespace(peek()); return !done() && is_whitespace(peek());
} }
bool Reader::matches_non_eol_whitespace() const
{
return !done() && is_non_eol_whitespace(peek());
}
bool Reader::matches_number() const bool Reader::matches_number() const
{ {
if (done()) if (done())
@ -74,6 +84,16 @@ bool Reader::consume_whitespace()
return consumed; return consumed;
} }
bool Reader::consume_non_eol_whitespace()
{
bool consumed = false;
while (matches_non_eol_whitespace()) {
consumed = true;
consume();
}
return consumed;
}
char Reader::consume() char Reader::consume()
{ {
return read(); return read();

View file

@ -133,15 +133,18 @@ public:
static bool is_eol(char); static bool is_eol(char);
static bool is_whitespace(char); static bool is_whitespace(char);
static bool is_non_eol_whitespace(char);
bool matches_eol() const; bool matches_eol() const;
bool matches_whitespace() const; bool matches_whitespace() const;
bool matches_non_eol_whitespace() const;
bool matches_number() const; bool matches_number() const;
bool matches_delimiter() const; bool matches_delimiter() const;
bool matches_regular_character() const; bool matches_regular_character() const;
bool consume_eol(); bool consume_eol();
bool consume_whitespace(); bool consume_whitespace();
bool consume_non_eol_whitespace();
char consume(); char consume();
void consume(int amount); void consume(int amount);
bool consume(char); bool consume(char);