pattern

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Spec

type Spec struct {
	// A sequence of Token structs that indicates the new row layout.
	Tokens []Token `json:"tokens"`

	// CSV separator character.
	Comma string `json:"comma"`

	// Decimal separator for currency.
	CurrSep string `json:"curr_sep"`
}

Spec is derived from a user-provided string pattern. It contains information about the structure of the output CSV file.

func ParsePattern

func ParsePattern(pattern, curSep string) (Spec, error)

ParsePattern converts user input into a Specification struct.

type Token

type Token struct {
	// Indicates the value type stored in a Token struct.
	Type TokenType `json:"type"`

	// Column number. Content of the indicated column will be substituted
	// in place of this token during compilation process.
	Column int `json:"column"`

	// Arbitrary text that will be inserted as is during compilation process.
	Text string `json:"text"`
}

Token is an union-like type. It stores either CSV column number or an arbitrary text to be inserted.

func NewColumnToken

func NewColumnToken(tt TokenType, columnNumber int) Token

Creates a new Token containing specified column number.

func NewNoModToken added in v0.6.0

func NewNoModToken() Token

Creates a new special Token that prevents any column modifications.

func NewTextToken

func NewTextToken(text string) Token

Creates a new Token containing specified text.

type TokenType

type TokenType byte

Indicates a type of value stored in a Token struct.

const (
	// Indicates that Token stores Column.
	TT_COLUMN TokenType = 'd'

	// Indicates that Token stores Column with currency that requires
	// formatting. Unlike the regular TT_COLUMN type, currency Column will be
	// converted into a specified currency format.
	TT_CURRENCY_COLUMN TokenType = 'c'

	// Indicates that no column modifications should be performed.
	TT_NO_MOD TokenType = '*'

	// Indicates that Token stores Text.
	TT_TEXT TokenType = 's'
)

Jump to

Keyboard shortcuts

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