atv

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2020 License: MIT Imports: 16 Imported by: 2

Documentation

Overview

Package atv functions to read, write and manipulate ATV files containing a mGuard configuration.

Index

Constants

This section is empty.

Variables

View Source
var ErrNilReceiver = fmt.Errorf("The receiver is nil")

ErrNilReceiver is an error that is issued if a function is called with a nil receiver.

Functions

This section is empty.

Types

type AccessModifier added in v0.3.0

type AccessModifier int

AccessModifier influences the access of a setting in an ATV document.

const (
	// MustNotOverwrite indicates that a setting must not be overwritten.
	MustNotOverwrite AccessModifier = iota

	// MayOverwrite indicates that a setting may be overwritten.
	MayOverwrite

	// MustOverwrite indicates that a setting must be overwritten.
	MustOverwrite

	// MayAppend indicates that a setting can be extended by appending additional rows (table values only).
	MayAppend

	// DefaultAccessModifier is the access modifier that applys, if no access modifier is specified (for internal use only).
	DefaultAccessModifier
)

func ParseAccessModifier added in v0.3.0

func ParseAccessModifier(s string) (AccessModifier, error)

ParseAccessModifier parses the specified string as an access modifier.

func (AccessModifier) String added in v0.3.0

func (access AccessModifier) String() string

String returns the string representation of the access modifier.

type File added in v0.3.0

type File struct {
	// contains filtered or unexported fields
}

File represents a mGuard configuration file.

func FromFile added in v0.3.0

func FromFile(path string) (*File, error)

FromFile reads the specified ATV file from disk.

func FromReader added in v0.3.0

func FromReader(reader io.Reader) (*File, error)

FromReader reads an ATV document from the specified io.Reader.

func (*File) Dupe added in v0.3.0

func (file *File) Dupe() *File

Dupe returns a copy of the ATV document.

func (*File) GetAccess added in v0.3.0

func (file *File) GetAccess(name string) (*AccessModifier, error)

GetAccess gets the access modifier of the setting with the specified name.

func (*File) GetPragma added in v0.3.0

func (file *File) GetPragma(name string) (*string, error)

GetPragma returns the value of the pragma with the specified name.

func (*File) GetRowIDs added in v0.3.0

func (file *File) GetRowIDs() ([]RowID, error)

GetRowIDs returns all row ids recursively.

func (*File) GetRowReferences added in v0.3.0

func (file *File) GetRowReferences() ([]RowRef, error)

GetRowReferences returns all row references recursively.

func (*File) GetSetting added in v0.3.0

func (file *File) GetSetting(settingName string) (string, error)

GetSetting gets the setting with the specified name.

func (*File) GetUUID added in v0.3.0

func (file *File) GetUUID(name string) (*UUID, error)

GetUUID gets the UUID of the setting with the specified name.

func (*File) GetVersion added in v0.3.0

func (file *File) GetVersion() (Version, error)

GetVersion gets the version of the document.

func (*File) Merge added in v0.3.0

func (file *File) Merge(other *File) (*File, error)

Merge merges all settings from the specified ATV document into the current one.

func (*File) MergeSelectively added in v0.4.0

func (file *File) MergeSelectively(other *File, config *MergeConfiguration) (*File, error)

MergeSelectively merges the specified settings from the specified ATV document into the current one.

func (*File) Migrate added in v0.3.0

func (file *File) Migrate(targetVersion Version) (*File, error)

Migrate migrates the ATV file to the specified version (upwards only).

func (*File) RemoveAccess added in v0.3.0

func (file *File) RemoveAccess(name string) error

RemoveAccess removes the access modifier of the setting with the specified name.

func (*File) RemoveUUID added in v0.3.0

func (file *File) RemoveUUID(name string) error

RemoveUUID removes the UUID of the setting with the specified name.

func (*File) SetAccess added in v0.3.0

func (file *File) SetAccess(name string, access AccessModifier) error

SetAccess sets the access modifier of the setting with the specified name.

func (*File) SetPragma added in v0.3.0

func (file *File) SetPragma(name string, value string) error

SetPragma sets the value of the pragma with the specified name.

func (*File) SetUUID added in v0.3.0

func (file *File) SetUUID(name string, uuid UUID) error

SetUUID sets the UUID of the setting with the specified name.

func (*File) SetVersion added in v0.3.0

func (file *File) SetVersion(version Version) error

SetVersion sets the version of the document. This should only be done after a migration step to keep the document structure and the version number consistent.

func (*File) String added in v0.3.0

func (file *File) String() string

String returns a properly formatted string representation of the ATV document.

func (*File) ToFile added in v0.3.0

func (file *File) ToFile(path string) error

ToFile saves the ATV document to the specified file.

func (*File) ToWriter added in v0.3.0

func (file *File) ToWriter(writer io.Writer) error

ToWriter writes the ATV document to the specified io.Writer.

type MergeConfiguration added in v0.4.0

type MergeConfiguration struct {
	// contains filtered or unexported fields
}

MergeConfiguration defines which settings should be merged from one ATV document into another.

func LoadMergeConfiguration added in v0.4.0

func LoadMergeConfiguration(path string) (*MergeConfiguration, error)

LoadMergeConfiguration loads a merge configuration file.

func (*MergeConfiguration) ShouldMergeSetting added in v0.4.0

func (cfg *MergeConfiguration) ShouldMergeSetting(path documentSettingPath) bool

ShouldMergeSetting indicates whether the specified setting should be merged.

type RowID

type RowID string

RowID is the id of a table row in an ATV document.

type RowRef

type RowRef string

RowRef represents a reference to a table row.

type UUID added in v0.3.0

type UUID string

UUID represents a UUID associated with a setting.

type Version added in v0.3.0

type Version struct {
	Major  int
	Minor  int
	Patch  int
	Suffix string
}

Version represents the version of an ATV document.

func (Version) Compare added in v0.3.0

func (version Version) Compare(other Version) int

Compare compares the current version with the specified one. Returns -1, if the current version is less than the specified one. Returns 0, if the current version equals the current one. Returns +1, if the current version is greater than the specified one.

func (Version) String added in v0.3.0

func (version Version) String() string

String returns the version as a string.

Jump to

Keyboard shortcuts

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