package Common::File::Tied::LineParser;
use strict;

use lib '/app/tools/common/lib';
use Common::Assert;

# The point of this class is to provide objects that know how to parse lines of data, in an abstract way.
# I imagine that there will be subclasses to handle tab and csv delimited data.
# We've learned a lot of stuff about parsing files in the last few years, and the RPS::Sale::File implementation
# has become stuffed full of weird things.  We can't avoid weirdness in our files, but I would like our code
# to be a little easier to maintain...
#
# So I imagine that there is going to be a Factory class that will examine a text file, and figure out what
# subclass of FileParser to instantiate.   We may need a series of 'CellParser' classes to handle some of
# the wackadoodle quoting and escaping issues we've seen in a way that keeps these classes from getting too ugly.
#

sub new {
    my ( $class, %args ) = @_;
    my $self = bless {}, $class;
    return $self->_init(%args);
}

sub _init {
    my ( $self, %args ) = @_;

    return $self;
}

# This is the primary public interface.
# Pass in a string, and it will return an array reference of data.
#
sub parseString {
    my ( $self, $string ) = @_;

    assert( 0, 'override this' );
}

# The idea behind the method is to allow us to deal with files that contain
# 'quoted \n'.  That is, carriage returns that are within quoted sections, and therefore
# should NOT be treated as end-of-line markers.
# Exactly how that works is going to be left up to individual subclasses.
# By default we'll treat all lines as 'complete'.
#
sub lineIsComplete {
    my ( $self, $string ) = @_;
    return 1;
}

1;
