parse

package
v2.5.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2025 License: MIT Imports: 14 Imported by: 0

README

Parse

structure

Documentation

Overview

The parse package contains structures and functions for parsing Mo/Po files with the respective options.

Index

Constants

View Source
const (
	LittleEndian = util.LittleEndian
	BigEndian    = util.BigEndian
	NativeEndian = util.NativeEndian
)

Variables

This section is empty.

Functions

func Mo

func Mo(path string, opts ...MoOption) (*po.File, error)

func MoFromBytes

func MoFromBytes(b []byte, name string, opts ...MoOption) (*po.File, error)

func MoFromFile

func MoFromFile(f *os.File, opts ...MoOption) (*po.File, error)

func MoFromReader

func MoFromReader(r io.Reader, name string, opts ...MoOption) (*po.File, error)

func Po

func Po(path string, opts ...PoOption) (*po.File, error)

Parse directly the provided file.

func PoFromBytes

func PoFromBytes(b []byte, name string, opts ...PoOption) (*po.File, error)

func PoFromFile

func PoFromFile(f *os.File, opts ...PoOption) (*po.File, error)

func PoFromReader

func PoFromReader(r io.Reader, name string, opts ...PoOption) (*po.File, error)

func PoFromString

func PoFromString(s, name string, opts ...PoOption) (*po.File, error)

Types

type Endianness added in v2.3.0

type Endianness = util.Endianness

type MoConfig added in v2.3.0

type MoConfig struct {

	// The logger can be nil, otherwise this logger will be used to print all errors by default.
	Logger *log.Logger
	// Specifies the endianness to work with,
	// if [NativeEndian], the endianness
	// automatically determined by the magic number will be used,
	// otherwise, the specified endianness will be used.
	Endianness Endianness
	// Causes parsing to fail if the entries are not sorted properly.
	MustBeSorted bool
	// contains filtered or unexported fields
}

func DefaultMoConfig added in v2.3.0

func DefaultMoConfig(opts ...MoOption) MoConfig

func (*MoConfig) ApplyOptions added in v2.3.0

func (mc *MoConfig) ApplyOptions(opts ...MoOption)

Overwrite the configuration with the options provided, saving the previous state so that it can be restored later with MoConfig.RestoreLastCfg if desired.

func (*MoConfig) RestoreLastCfg added in v2.3.0

func (mc *MoConfig) RestoreLastCfg()

Restores the configuration state prior to the last MoConfig.ApplyOptions if it exists, otherwise it does nothing.

type MoOption added in v2.3.0

type MoOption func(*MoConfig)

func MoWithConfig added in v2.3.0

func MoWithConfig(c MoConfig) MoOption

func MoWithEndianness added in v2.3.0

func MoWithEndianness(e Endianness) MoOption

func MoWithLogger added in v2.5.0

func MoWithLogger(logger *log.Logger) MoOption

func MoWithMustBeSorted added in v2.5.0

func MoWithMustBeSorted(m bool) MoOption

type MoParser

type MoParser struct {
	Config MoConfig
	// contains filtered or unexported fields
}

func NewMo

func NewMo(path string, opts ...MoOption) (*MoParser, error)

func NewMoFromBytes

func NewMoFromBytes(b []byte, name string, opts ...MoOption) *MoParser

func NewMoFromFile

func NewMoFromFile(f *os.File, opts ...MoOption) (*MoParser, error)

func NewMoFromReader

func NewMoFromReader(r io.Reader, name string, opts ...MoOption) (*MoParser, error)

func (MoParser) Error

func (m MoParser) Error() error

Return the first error in the stack.

func (MoParser) Errors

func (m MoParser) Errors() []error

func (*MoParser) Parse

func (m *MoParser) Parse() (file *po.File)

func (*MoParser) ParseWithOptions added in v2.3.0

func (m *MoParser) ParseWithOptions(opts ...MoOption) (file *po.File)

type PoConfig

type PoConfig struct {
	IgnoreComments    bool
	IgnoreAllComments bool
	// The logger can be nil, otherwise this logger will be used to print all errors by default.
	Logger          *log.Logger
	Verbose         bool
	SkipHeader      bool
	CleanDuplicates bool

	ParseObsoletes          bool
	UseCustomObsoletePrefix bool
	CustomObsoletePrefix    rune
	// contains filtered or unexported fields
}

func DefaultPoConfig

func DefaultPoConfig(opts ...PoOption) PoConfig

func (*PoConfig) ApplyOptions

func (p *PoConfig) ApplyOptions(opts ...PoOption)

Overwrite the configuration with the options provided, saving the previous state so that it can be restored later with PoConfig.RestoreLastCfg if desired.

func (*PoConfig) RestoreLastCfg

func (p *PoConfig) RestoreLastCfg()

Restores the configuration state prior to the last PoConfig.ApplyOptions if it exists, otherwise it does nothing.

type PoOption

type PoOption func(*PoConfig)

func PoWithCleanDuplicates

func PoWithCleanDuplicates(cd bool) PoOption

func PoWithConfig

func PoWithConfig(cfg PoConfig) PoOption

func PoWithCustomObsoletePrefix

func PoWithCustomObsoletePrefix(r rune) PoOption

func PoWithIgnoreAllComments

func PoWithIgnoreAllComments(iag bool) PoOption

func PoWithIgnoreComments

func PoWithIgnoreComments(ig bool) PoOption

func PoWithLogger

func PoWithLogger(logger *log.Logger) PoOption

func PoWithParseObsolete

func PoWithParseObsolete(p bool) PoOption

func PoWithSkipHeader

func PoWithSkipHeader(s bool) PoOption

func PoWithUseCustomObsoletePrefix

func PoWithUseCustomObsoletePrefix(u bool) PoOption

func PoWithVerbose added in v2.5.0

func PoWithVerbose(v bool) PoOption

type PoParser

type PoParser struct {
	Config PoConfig
	// contains filtered or unexported fields
}

func NewPo

func NewPo(path string, options ...PoOption) (*PoParser, error)

func NewPoFromBytes

func NewPoFromBytes(data []byte, name string, options ...PoOption) *PoParser

func NewPoFromFile

func NewPoFromFile(f *os.File, options ...PoOption) (*PoParser, error)

func NewPoFromReader

func NewPoFromReader(r io.Reader, name string, options ...PoOption) (*PoParser, error)

func NewPoFromString

func NewPoFromString(s, name string, options ...PoOption) *PoParser

func (PoParser) Error

func (p PoParser) Error() error

Return the first error in the stack.

func (PoParser) Errors

func (p PoParser) Errors() []error

func (*PoParser) Parse

func (p *PoParser) Parse() *po.File

func (*PoParser) ParseWithOptions

func (p *PoParser) ParseWithOptions(opts ...PoOption) *po.File

func (PoParser) Warnings

func (p PoParser) Warnings() []error

Jump to

Keyboard shortcuts

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