Struct file_scanner::Scanner
[−]
[src]
pub struct Scanner<'a> { /* fields omitted */ }
Rust implementation of java.util.Scanner
Methods
impl<'a> Scanner<'a>
[src]
Implements the meta-methods of Scanner that affect how the data stream is processed, e.g., delimiter, parsing radix, etc.
fn set_delim(&mut self, delim: Regex) -> &Regex
[src]
Sets the delimiter to be some pre-compiled regex.
fn set_delim_str(&mut self, delim: &str) -> &Regex
[src]
Sets the delimiter to be a string literal. The resulting delimiting expression is guaranteed to only interpret the literal passed in, i.e., this method cannot be used to simultaneously compile and set an arbitrary regular expression.
fn get_delim(&self) -> &Regex
[src]
Return the delimiter for Scanner.next()
and methods that depend on it.
fn set_radix(&mut self, radix: u32) -> u32
[src]
Sets the radix in which numbers are parsed. This value must be on the closed range [2, 36], such that alphabet characters represent values greater than 9 in bases exceeding 10.
fn get_radix(&self) -> u32
[src]
impl<'a> Scanner<'a>
[src]
Implements the methods of Scanner that affect the underlying data stream
fn new(stream: &'a mut BufRead) -> Scanner
[src]
Creates a new instance of Scanner on some object implementing BufRead
fn next(&mut self) -> Option<String>
[src]
Returns Some(String)
containing the next string if there is one.
Otherwise returns None.
We first consume all leading delim
s, then attempt to read everything
until (but excluding) the next delim
. If this results in an empty
string, we will return None
.
fn next_line(&mut self) -> Option<String>
[src]
Read up to (but excluding) the next \n
character.
If there are any leading delim
s, they will be included in the
returned string.
NOTE: unlike next()
we do consume the trailing \n
, if it exists.
fn next_int<T: Integer>(&mut self) -> Option<T>
[src]
Attempts to retrieve the next integer of the specified (or inferred)
type. Even if this fails, we still consume next
.
The default radix for this parsing is 10, but users may specify a
one-time arbitrary radix using Scanner.next_int_radix(u32)
or persistently using Scanner.set_radix(u32)
.
fn next_int_radix<T: Integer>(&mut self, radix: u32) -> Option<T>
[src]
Returns the next integer in some arbitrary base on [2, 36].
If the radix provided is outside of this range, we do nothing.
Otherwise, we will consume next()
even if it is not a valid integer.
NOTE: If one means to repeatedly parse in a fixed, arbitrary base,
it is more efficient to use Scanner.set_radix(u32)
followed by
Scanner.next_int
with no radix argument.
fn next_float<T: Float + FromStr>(&mut self) -> Option<T>
[src]
Attempts to retrieve the next floating-point number of the specified
(or inferred) type. Even if this fails, we still consume next
.
Note that this method is based on Scanner.next()
, so the delimiter
is still the same.