pub struct CharacterReader<'a> { /* private fields */ }Expand description
A forward-only reader over a string.
Implementations§
Source§impl CharacterReader<'_>
impl CharacterReader<'_>
Sourcepub fn parse_arguments(
&mut self,
open: char,
close: char,
) -> Result<Vec<String>, ExpressionParseException>
pub fn parse_arguments( &mut self, open: char, close: char, ) -> Result<Vec<String>, ExpressionParseException>
Parses a list of arguments enclosed in open/close and separated by
,. The reader must be positioned on open.
Sourcepub fn parse_arguments_with_delimiter(
&mut self,
open: char,
close: char,
delimiter: char,
) -> Result<Vec<String>, ExpressionParseException>
pub fn parse_arguments_with_delimiter( &mut self, open: char, close: char, delimiter: char, ) -> Result<Vec<String>, ExpressionParseException>
Parses a list of arguments enclosed in open/close and separated by
delimiter. The reader must be positioned on open.
Source§impl<'a> CharacterReader<'a>
impl<'a> CharacterReader<'a>
Sourcepub fn peek(&self) -> Option<char>
pub fn peek(&self) -> Option<char>
Gets the next character without consuming it, or None at the end.
Sourcepub fn position(&self) -> i32
pub fn position(&self) -> i32
Gets the number of characters consumed so far.
As upstream, Self::skip does not advance the position.
Sourcepub fn take(&mut self) -> Option<char>
pub fn take(&mut self) -> Option<char>
Consumes and returns the next character, or returns None at the end.
Sourcepub fn skip_whitespace(&mut self)
pub fn skip_whitespace(&mut self)
Consumes leading white space.
Sourcepub fn take_if_str(&mut self, s: &str) -> bool
pub fn take_if_str(&mut self, s: &str) -> bool
Consumes s if the remaining input starts with it.
Sourcepub fn take_if_fn(&mut self, condition: impl Fn(char) -> bool) -> bool
pub fn take_if_fn(&mut self, condition: impl Fn(char) -> bool) -> bool
Consumes the next character if it satisfies condition.
Sourcepub fn take_until(&mut self, c: char) -> &'a str
pub fn take_until(&mut self, c: char) -> &'a str
Consumes and returns everything up to (not including) the first c,
or the rest of the input when c does not occur.
Sourcepub fn take_while(&mut self, condition: impl Fn(char) -> bool) -> &'a str
pub fn take_while(&mut self, condition: impl Fn(char) -> bool) -> &'a str
Consumes and returns the longest prefix whose characters all satisfy
condition.
Sourcepub fn try_peek(&self, count: usize) -> &'a str
pub fn try_peek(&self, count: usize) -> &'a str
Returns the next count characters without consuming them, or an empty
string when fewer than count characters remain.
Sourcepub fn peek_whitespace(&self) -> &'a str
pub fn peek_whitespace(&self) -> &'a str
Returns the leading white space without consuming it.
Sourcepub fn skip(&mut self, count: usize)
pub fn skip(&mut self, count: usize)
Consumes count characters without advancing Self::position
(as upstream).
§Panics
Panics when fewer than count characters remain; callers skip only
what they have peeked.
Source§impl<'a> CharacterReader<'a>
impl<'a> CharacterReader<'a>
Sourcepub fn parse_identifier(&mut self) -> &'a str
pub fn parse_identifier(&mut self) -> &'a str
Parses an identifier: a letter or _ followed by letters, _, marks,
connector punctuation, format characters and decimal digits. Returns an
empty string (consuming nothing) when the input does not start with an
identifier.
Sourcepub fn parse_type_identifier(&mut self) -> &'a str
pub fn parse_type_identifier(&mut self) -> &'a str
Parses an identifier that may name a nested type, e.g. “Outer+Inner”.
Sourcepub fn parse_number(&mut self) -> &'a str
pub fn parse_number(&mut self) -> &'a str
Parses a run of decimal digits (possibly empty).
Source§impl CharacterReader<'_>
impl CharacterReader<'_>
Sourcepub fn check_keyword(&self, keyword: &str) -> bool
pub fn check_keyword(&self, keyword: &str) -> bool
Checks whether the input continues with optional white space followed
by keyword, without consuming anything.
Sourcepub fn take_if_keyword(&mut self, keyword: &str) -> bool
pub fn take_if_keyword(&mut self, keyword: &str) -> bool
Consumes optional white space followed by keyword if the input
continues with it.
As upstream, the consumed characters are skipped without advancing
CharacterReader::position.
Source§impl<'a> CharacterReader<'a>
impl<'a> CharacterReader<'a>
Sourcepub fn parse_style_class(&mut self) -> &'a str
pub fn parse_style_class(&mut self) -> &'a str
Parses a style class name: an identifier that may also contain -.
Returns an empty string (consuming nothing) when the input does not
start with a class name.
Trait Implementations§
Source§impl<'a> Clone for CharacterReader<'a>
impl<'a> Clone for CharacterReader<'a>
Auto Trait Implementations§
impl<'a> Freeze for CharacterReader<'a>
impl<'a> RefUnwindSafe for CharacterReader<'a>
impl<'a> Send for CharacterReader<'a>
impl<'a> Sync for CharacterReader<'a>
impl<'a> Unpin for CharacterReader<'a>
impl<'a> UnsafeUnpin for CharacterReader<'a>
impl<'a> UnwindSafe for CharacterReader<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
affects_render, metadata
overrides). Read more