mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:07:36 +00:00
LibPDF: Implement Reader::is_[eol, whitespace](char)
These two static members are now used to implement respective `matches_` methods but will also be useful to provide a global implementation of the specified concept of whitespace.
This commit is contained in:
parent
dac703a0b8
commit
db08fe12ec
2 changed files with 16 additions and 2 deletions
|
@ -9,14 +9,25 @@
|
||||||
|
|
||||||
namespace PDF {
|
namespace PDF {
|
||||||
|
|
||||||
|
bool Reader::is_eol(char c)
|
||||||
|
{
|
||||||
|
return c == 0xa || c == 0xd;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Reader::is_whitespace(char c)
|
||||||
|
{
|
||||||
|
// 3.1.1 Character Set
|
||||||
|
return is_eol(c) || c == 0 || c == 0x9 || c == 0xc || c == ' ';
|
||||||
|
}
|
||||||
|
|
||||||
bool Reader::matches_eol() const
|
bool Reader::matches_eol() const
|
||||||
{
|
{
|
||||||
return matches_any(0xa, 0xd);
|
return !done() && is_eol(peek());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Reader::matches_whitespace() const
|
bool Reader::matches_whitespace() const
|
||||||
{
|
{
|
||||||
return matches_eol() || matches_any(0, 0x9, 0xc, ' ');
|
return !done() && is_whitespace(peek());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Reader::matches_number() const
|
bool Reader::matches_number() const
|
||||||
|
|
|
@ -131,6 +131,9 @@ public:
|
||||||
move_until([&predicate](char t) { return !predicate(t); });
|
move_until([&predicate](char t) { return !predicate(t); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool is_eol(char);
|
||||||
|
static bool is_whitespace(char);
|
||||||
|
|
||||||
bool matches_eol() const;
|
bool matches_eol() const;
|
||||||
bool matches_whitespace() const;
|
bool matches_whitespace() const;
|
||||||
bool matches_number() const;
|
bool matches_number() const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue