TableParserHelper

com.phasmidsoftware.tableparser.core.parse.TableParserHelper
abstract class TableParserHelper[X](sourceHasHeaderRow: Boolean = ..., forgiving: Boolean = ...)(using fieldNames: => FieldNames[X]) extends CellParsers

TableParserHelper: abstract class to help with defining an implicit TableParser of Table[X]. Note that this class extends CellParser[X]. It is expected that this should be sub-classed by the object which is the companion object of X. That will make it easiest for the compiler to discover the implicit value of type TableParser of Table[X]

NOTE: this class should be used for simple cases where the the data and type X match according to one of options for sourceHasHeaderRow. More complex situations can easily be handled but not using this TableParserHelper class.

Type parameters

X

the type for which we require a TableParser[X].

Value parameters

forgiving

true if individual rows of the source which do not parse successfully, are logged but otherwise do not affect the success of the overall parsing.

sourceHasHeaderRow

true (default) if the data to be read has an explicit header row with column names that match the parameters of type X; false if there is no header row in the data AND if the data has (unnamed) columns of the same number and in the same order as defined by type X.

Attributes

Graph
Supertypes
trait CellParsers
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

Abstract method which will return a CellParser[X]. NOTE that a typical definition will be CellParser.derived[Player].

Abstract method which will return a CellParser[X]. NOTE that a typical definition will be CellParser.derived[Player].

Attributes

Inherited methods

def cellParser[P : CellParser, T](construct: P => T): CellParser[T]

Method to return a CellParser[T] based on a function to convert a P into a T

Method to return a CellParser[T] based on a function to convert a P into a T

Type parameters

P

the type of the intermediate type.

T

the underlying type of the result.

Value parameters

construct

a function P => T.

Attributes

Returns

a SingleCellParser which converts a String into the intermediate type P and thence into a T

Inherited from:
CellParsers
inline def cellParser2Conditional[K, P, T](construct: (K, P) => T, parsers: Map[K, CellParser[P]])(using kp: CellParser[K], m: ProductOf[T], helper: ColumnHelper[T]): CellParser[T]

Method to return a CellParser[T] where T is a 2-ary Product and which is based on a function to convert a (K,P) into a T. This method differs from cellParser2 in that the parser of P (a CellParser[P]) is not found implicitly, but rather is looked up dynamically depending on the value of the first parameter (of type K).

Method to return a CellParser[T] where T is a 2-ary Product and which is based on a function to convert a (K,P) into a T. This method differs from cellParser2 in that the parser of P (a CellParser[P]) is not found implicitly, but rather is looked up dynamically depending on the value of the first parameter (of type K).

Type parameters

K

the type of the conditional lookup key, which is also the type of the first field of T. Typically, this will be a String, but it could also be an Int or something more exotic.

P

the type of the second field of the Product type T.

T

the underlying type of the result, a case class with two fields.

Value parameters

construct

a function (K,P) => T, usually the apply method of a case class.

helper

the ColumnHelper[T].

m

the Mirror of T, from which the field names come.

parsers

a Map[K, CellParser[P]] which determines which particular parser of P will be used. The key value looked up is the value of the first (K) field.

Attributes

Returns

a MultiCellParser which converts Strings from a Row into the field types K and P and thence into a T.

Inherited from:
CellParsers
def cellParserOption[P : CellParser]: CellParser[Option[P]]

Method to return a CellParser[Option[P]].

Method to return a CellParser[Option[P]].

This class is used for optional types which are non-scalar, i.e., there are no implicitly defined parsers for the Option[P].

Type parameters

P

the underlying type of the result

Attributes

Returns

a SingleCellParser[Option[P]]

Inherited from:
CellParsers
def cellParserRepetition[P : CellParser](start: Int = ...): CellParser[Seq[P]]

Method to return a CellParser[Seq[P]] from a potentially unlimited set of P objects. The counting of the elements starts at start (defaults to 1).

Method to return a CellParser[Seq[P]] from a potentially unlimited set of P objects. The counting of the elements starts at start (defaults to 1).

Type parameters

P

the underlying type of the result

Attributes

Returns

a MultiCellParser[Seq[P]

Inherited from:
CellParsers
def cellParserSeq[P : CellParser]: CellParser[Seq[P]]

Method to return a CellParser[Seq[P]. This is used only by unit tests. CONSIDER eliminating this; only used in unit tests

Method to return a CellParser[Seq[P]. This is used only by unit tests. CONSIDER eliminating this; only used in unit tests

Type parameters

P

the underlying type of the result

Attributes

Returns

a MultiCellParser[Seq[P]

Inherited from:
CellParsers
def columnHelper[T](aliases: (String, String)*): ColumnHelper[T]

Method to yield a ColumnHelper[T] based on some number of explicit aliases,

Method to yield a ColumnHelper[T] based on some number of explicit aliases,

Type parameters

T

the underlying type of the resulting ColumnHelper

Value parameters

aliases

a variable number of explicit aliases to translate specific case class parameter names into their column name equivalents.

Attributes

Returns

a new instance of ColumnHelper[T]

Inherited from:
CellParsers
def columnHelper[T](columnNameMapper: String => String, maybePrefix: Option[String], aliases: (String, String)*): ColumnHelper[T]

Method to yield a ColumnHelper[T] based on a column name mapper, an optional prefix, and some number of explicit aliases,

Method to yield a ColumnHelper[T] based on a column name mapper, an optional prefix, and some number of explicit aliases,

Type parameters

T

the underlying type of the resulting ColumnHelper

Value parameters

aliases

a variable number of explicit aliases to translate specific case class parameter names into their column name equivalents.

columnNameMapper

a mapper of String=>String which will translate case class parameter names into column names.

maybePrefix

an optional prefix for the column name.

Attributes

Returns

a new instance of ColumnHelper[T]

Inherited from:
CellParsers
def columnHelper[T](columnNameMapper: String => String, aliases: (String, String)*): ColumnHelper[T]

Method to yield a ColumnHelper[T] based on a column name mapper, and some number of explicit aliases,

Method to yield a ColumnHelper[T] based on a column name mapper, and some number of explicit aliases,

Type parameters

T

the underlying type of the resulting ColumnHelper

Value parameters

aliases

a variable number of explicit aliases to translate specific case class parameter names into their column name equivalents.

columnNameMapper

a mapper of String=>String which will translate case class parameter names into column names.

Attributes

Returns

a new instance of ColumnHelper[T]

Inherited from:
CellParsers
def columnHelper[T](maybePrefix: Option[String], aliases: (String, String)*): ColumnHelper[T]

Method to yield a ColumnHelper[T] based on an optional prefix, and some number of explicit aliases,

Method to yield a ColumnHelper[T] based on an optional prefix, and some number of explicit aliases,

Type parameters

T

the underlying type of the resulting ColumnHelper

Value parameters

aliases

a variable number of explicit aliases to translate specific case class parameter names into their column name equivalents.

maybePrefix

an optional prefix for the column name.

Attributes

Returns

a new instance of ColumnHelper[T]

Inherited from:
CellParsers

Method to return a CellParser[RawRow] from a Row.

Method to return a CellParser[RawRow] from a Row.

Attributes

Returns

a CellParser[RawRow]

Inherited from:
CellParsers

Inherited fields

lazy val cellParserOptionNonEmptyString: CellParser[Option[String]]

Method to return a CellParser[Option[String].

Method to return a CellParser[Option[String].

TODO: why do we need this in addition to cellParserOption?

CONSIDER: using BlankException as above...

Attributes

Returns

a SingleCellParser[Option[String]

Inherited from:
CellParsers

Givens

Givens

given ptp: TableParser[Table[X]]
given xp: CellParser[X]