gdengine

package
v0.0.0-...-70363f9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckFileExists

func CheckFileExists(name string) bool

Exists reports whether the named file or directory exists.

func OnParseMappedRow

func OnParseMappedRow(Rowparser GDRowParser, data GDMappedRowData) int

Default parse Mapped Data row behaviours

func OnParseRow

func OnParseRow(Rowparser GDRowParser, rowdata GDRowData) int

Default Parse Row behaviour

Types

type GDCellData

type GDCellData struct {
	// Index for the Cell
	Index GDColumnIndex
	// data in the cell
	Data string
	// any other cell data that should be related
	RelatedData map[*GDColumnIndex]string
}

type GDColumMapping

type GDColumMapping struct {
	ColumnIndexes []geinterfaces.IGDColumnIndex `json:"columnindexes,omitempty"`
}

This structs has the mapping of the column indexs

type GDColumnIndex

type GDColumnIndex struct {
	geinterfaces.IGDColumnIndex

	Index int `json:"index"`

	Name string `json:"name"`
	// do we need to associate other columns with this column?
	// for example: column 1 is the first name and column 2 is the second name they should be associated
	RelatedIndexes []geinterfaces.IGDColumnIndex `json:"relatedindexes,omitempty"`
}

This struct is the column index it can be based around the name or an integer index the name will be read by the header row

func CreateColumnIndex

func CreateColumnIndex(Index int, Name string, rcolumns []GDColumnIndex) GDColumnIndex

Create Column Index

func CreateColumnIndexbyIndex

func CreateColumnIndexbyIndex(Index int) GDColumnIndex

func CreateColumnIndexbyName

func CreateColumnIndexbyName(Name string) GDColumnIndex

func CreateRColumnIndexbyIndex

func CreateRColumnIndexbyIndex(Index int, rcolumns []GDColumnIndex) GDColumnIndex

func CreateRColumnIndexbyName

func CreateRColumnIndexbyName(Name string, rcolumns []GDColumnIndex) GDColumnIndex

func (GDColumnIndex) String

func (ci GDColumnIndex) String() string

Print ColumnIndex

type GDEngine

type GDEngine struct {
	// inherit from the engine interface
	geinterfaces.IGDEngine

	// Options
	// this is the options for this engine
	OptionsManager IGDEngineOptionsManager

	// input file path
	InputFilePath string

	// for logging
	Logger GDLogger

	// for parsing the file
	// this can be HTML, CSV etc
	Parser IGDParser
}

Grid data Parser with sturcts

func CreateGDEngine

func CreateGDEngine() GDEngine

func (GDEngine) Execute

func (gdpe GDEngine) Execute(Rowparser GDRowParser) error

func (GDEngine) MapRowData

func (gdpe GDEngine) MapRowData(ColumnIndexes []GDColumnIndex, line []string, linecount int, pass int) GDMappedRowData

func (GDEngine) ParseHeader

func (gdpe GDEngine) ParseHeader(ColumnIndexes []GDColumnIndex, line []string) []GDColumnIndex

Parse the Header

type GDEngineOptions

type GDEngineOptions struct {
	/// dump column mappings to file
	DumpColumnMapping         bool
	DumpColumnMappingFilePath string
	// dump row options to a file
	DumpRowOptions         bool
	DumpRowOptionsFilePath string

	/// Don't do any parsing
	DumpOnly bool

	// Row parsing options
	RowParsingoptions GDRowParsingOptions

	// are we loading the options from a JSON file?
	// do not set if inmmeory options should be used
	RowParsingOptionsFilepath string

	// Column Mappings
	Columnmapping GDColumMapping

	// are we loading the mapping from a JSON file?
	// do not set if inmmeory options should be used
	ColumMappingFilepath string
}

These are the Parse Options

type GDEngineOptionsManager

type GDEngineOptionsManager struct {
	// inherit from interface to get methods
	geinterfaces.IGDEngineOptionsManager

	// Options for the engine
	Options GDEngineOptions
}

func CreateGDEngineOptionsManager

func CreateGDEngineOptionsManager() GDEngineOptionsManager

func (GDEngineOptionsManager) GetColumMapping

func (parser GDEngineOptionsManager) GetColumMapping(Logger GDLogger) (bool, GDColumMapping)

func (GDEngineOptionsManager) GetCurrentOptions

func (parser GDEngineOptionsManager) GetCurrentOptions() GDEngineOptions

func (GDEngineOptionsManager) GetRowParsingOptions

func (parser GDEngineOptionsManager) GetRowParsingOptions(Logger GDLogger) (bool, GDRowParsingOptions)

func (GDEngineOptionsManager) ParseOptions

func (gdpe GDEngineOptionsManager) ParseOptions(Logger GDLogger) (bool, error)

func (GDEngineOptionsManager) SetCurrentOptions

func (parser GDEngineOptionsManager) SetCurrentOptions(opts GDEngineOptions) GDEngineOptionsManager

type GDMappedRowData

type GDMappedRowData struct {
	geinterfaces.IGDMappedRowData
	// row index
	Index int
	// row pass
	Pass int
	// reference to parser options
	Options *GDEngineOptions
	// Parsed Cell Data
	Cells []GDCellData
}

type GDRowData

type GDRowData struct {
	geinterfaces.IGDRowdata
	// row index
	Index int
	// raw data
	RawData []string
	// mapped data
	Pass int
}

type GDRowParsingOptions

type GDRowParsingOptions struct {
	// how many times do we read the row?
	NumOfRowPasses int `json:"numofrowpasses"`

	//SkipHeaderRow bool `json:"skipheaderrow"`
	HeaderRowIndex int `json:"headerrowindex"`

	//Max rows to read
	MaxRows int `json:"maxrows"`

	//what row to start at
	StartRowIndex int `json:"startrowindex"`
}

This struct represents the options for parsing the rows designed to be loaded from file as JSON or be a in memory object

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL