lng

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Save

func Save(file *File, fileName string) (ferr error)

Save сохраняет lng-файл на диск

Types

type File

type File struct {
	UpdateTime time.Time
	Changed    bool
	// contains filtered or unexported fields
}

File описывате lng-файл

func Load

func Load(fileName string) (*File, error)

Load загружает (и разбирает) lng-файл с диска

func NewFile

func NewFile() *File

NewFile создаёт lng-файл

func (*File) NewSection

func (f *File) NewSection(name string) (*Section, error)

NewSection добавляет новую секцию

func (*File) Section

func (f *File) Section(name string) *Section

Section возвращает секцию по имени

func (*File) Sections

func (f *File) Sections() []*Section

Sections возвращает список секций

type Key

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

Key описывает ключ секции lng-файла

func (*Key) DecodeName

func (k *Key) DecodeName() (resID int, resName string, err error)

DecodeName декодирует имя, как имя ресурса

func (*Key) Flag

func (k *Key) Flag() KeyFlag

Flag возвращает флаг

func (*Key) Name

func (k *Key) Name() string

Name возвращает имя

func (*Key) RestoreResID

func (k *Key) RestoreResID(resID int) error

RestoreResID добавляет код ресурса к имени

func (*Key) SetFlag

func (k *Key) SetFlag(flag KeyFlag)

SetFlag задаёт флаг

func (*Key) SetName

func (k *Key) SetName(name string)

SetName задаёт имя

func (*Key) SetValue

func (k *Key) SetValue(value string)

SetValue задаёт значение

func (*Key) SetVersion

func (k *Key) SetVersion(version KeyVersion)

SetVersion задаёт версию

func (*Key) String

func (k *Key) String() string

func (*Key) StripResID

func (k *Key) StripResID() error

StripResID удаляет код ресурса из имени

func (*Key) Value

func (k *Key) Value() string

Value возвращает значение

func (*Key) Version

func (k *Key) Version() KeyVersion

Version возвращает версию

type KeyFlag

type KeyFlag int

KeyFlag описывает флаг ключа

const (
	// Std обозначает Стд
	Std KeyFlag = iota
	// Modified обозначает Изменено
	Modified
	// Deleted обозначает Удалено
	Deleted
)

func (KeyFlag) String

func (f KeyFlag) String() string

type KeyVersion

type KeyVersion int

KeyVersion описывает версию ключа

func (KeyVersion) String

func (v KeyVersion) String() string

type Section

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

Section описывает секцию lng-файла

func (*Section) FilterKey

func (s *Section) FilterKey(op func(k *Key) bool)

FilterKey фильтрует ключи (удаляет ключи, не соответствующие условию)

func (*Section) ForEachKey

func (s *Section) ForEachKey(op func(k *Key))

ForEachKey обходит ключи, выполняя указанную операцию Во время обхода добавлять новые ключи нельзя

func (*Section) Key

func (s *Section) Key(name string) (*Key, *Key)

Key возвращает ключ по имени, и одноименный ключ с другим флагом TODO: ускорить получение ключа по имени (map[string]*Key)

func (*Section) KeyByValue

func (s *Section) KeyByValue(value string) *Key

KeyByValue возвращает ключ по значению

func (*Section) Keys

func (s *Section) Keys() []*Key

Keys возвращает список ключей

func (*Section) Name

func (s *Section) Name() string

Name возвращает имя

func (*Section) NewKey

func (s *Section) NewKey(flag KeyFlag, name string, version KeyVersion, value string) (*Key, error)

NewKey добавляет новый ключ

func (*Section) NewKeyAt

func (s *Section) NewKeyAt(atName string, flag KeyFlag, name string, version KeyVersion, value string) (*Key, error)

NewKeyAt добавляет новый ключ после ключа с указанным именем

func (*Section) SortKeys

func (s *Section) SortKeys()

SortKeys сортирует ключи по имени

Jump to

Keyboard shortcuts

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