#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum State {
Numeric,
Alpha,
IsoIec646,
}
pub struct CurrentParsingState {
position: usize,
encoding: State,
}
impl CurrentParsingState {
pub fn new() -> Self {
Self {
position: 0,
encoding: State::Numeric,
}
}
pub fn getPosition(&self) -> usize {
self.position
}
pub fn setPosition(&mut self, position: usize) {
self.position = position
}
pub fn incrementPosition(&mut self, delta: usize) {
self.position += delta;
}
pub fn isAlpha(&self) -> bool {
self.encoding == State::Alpha
}
pub fn isNumeric(&self) -> bool {
self.encoding == State::Numeric
}
pub fn isIsoIec646(&self) -> bool {
self.encoding == State::IsoIec646
}
pub fn setNumeric(&mut self) {
self.encoding = State::Numeric;
}
pub fn setAlpha(&mut self) {
self.encoding = State::Alpha;
}
pub fn setIsoIec646(&mut self) {
self.encoding = State::IsoIec646;
}
}
impl Default for CurrentParsingState {
fn default() -> Self {
Self::new()
}
}