collection

package
v0.0.34 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2021 License: MIT Imports: 10 Imported by: 69

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatProperties

func FormatProperties(tab Properties) string

FormatProperties 将属性表格式化为文本形式

func FormatPropertiesWithSegment

func FormatPropertiesWithSegment(tab Properties) string

FormatPropertiesWithSegment 将属性表格式化为文本形式(支持分段)

Types

type ArgumentReader added in v0.0.14

type ArgumentReader interface {
	SetEnding(ending string)
	Ending() string
	Read() (string, bool)
}

type Arguments

type Arguments interface {
	GetReader(flag string) (ArgumentReader, bool)
	Import([]string)
	Export() []string
}

func CreateArguments

func CreateArguments() Arguments

type Attributes

type Attributes interface {
	Atts

	GetAttributeRequired(name string) (lang.Object, error)

	Import(map[string]lang.Object)
	Export(map[string]lang.Object) map[string]lang.Object
}

func CreateAttributes

func CreateAttributes() Attributes

type Atts added in v0.0.3

type Atts interface {
	GetAttribute(name string) lang.Object
	SetAttribute(name string, value lang.Object)
}

type Environment

type Environment interface {
	GetEnv(name string) (string, error)
	SetEnv(name string, value string)

	Import(map[string]string)
	Export(map[string]string) map[string]string
}

func CreateEnvironment

func CreateEnvironment() Environment

type Parameters

type Parameters interface {
	GetParam(name string) (string, error)

	Import(map[string]string)
	Export(map[string]string) map[string]string
}

func CreateParameters

func CreateParameters() Parameters

type Properties

type Properties interface {
	GetPropertyRequired(name string) (string, error)
	GetProperty(name string, defaultValue string) string
	SetProperty(name string, value string)
	Clear()

	Export(map[string]string) map[string]string
	Import(map[string]string)
}

Properties 接口表示对属性列表的引用。

func CreateProperties

func CreateProperties() Properties

func ParseProperties

func ParseProperties(text string, container Properties) (Properties, error)

ParseProperties 函数把参数 text 解析为属性表,存入dest中。

type Res added in v0.0.33

type Res interface {
	// 加载文本
	ReadText() (string, error)

	// 加载二进制数据
	ReadBinary() ([]byte, error)

	// 读数据流
	Reader() (io.ReadCloser, error)

	// 取长度
	Length() int64

	IsFile() bool
	IsDir() bool
	Exists() bool
}

Res 接口代表一个资源实体

type Resource added in v0.0.33

type Resource struct {
	Name         string
	AbsolutePath string
	RelativePath string
	BasePath     string
	IsDir        bool
}

Resource 结构包含某个资源的信息

type Resources

type Resources interface {

	// 加载文本数据
	GetText(path string) (string, error)

	// 加载二进制数据
	GetBinary(path string) ([]byte, error)

	// 读数据流
	GetReader(path string) (io.ReadCloser, error)

	// 列出所有资源的路径, 相当于{{ List("/",true) }}
	All() []*Resource

	// 列出所有资源的路径
	List(path string, recursive bool) []*Resource

	Get(path string) (Res, error)

	Clear()

	Import(src map[string]Res, override bool)

	Export(dst map[string]Res) map[string]Res
}

Resources 接口提供一组获取资源的方法

func CreateResources added in v0.0.33

func CreateResources() Resources

CreateResources 创建一个空的资源组

func LoadEmbedResources added in v0.0.34

func LoadEmbedResources(fs *embed.FS, path string) Resources

LoadEmbedResources 从嵌入的FS加载资源组

type SimpleArguments

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

func (*SimpleArguments) Export

func (inst *SimpleArguments) Export() []string

func (*SimpleArguments) GetReader added in v0.0.14

func (inst *SimpleArguments) GetReader(flag string) (ArgumentReader, bool)

func (*SimpleArguments) Import

func (inst *SimpleArguments) Import(args []string)

type SimpleAttributes

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

func (*SimpleAttributes) Export

func (inst *SimpleAttributes) Export(dst map[string]lang.Object) map[string]lang.Object

func (*SimpleAttributes) GetAttribute

func (inst *SimpleAttributes) GetAttribute(name string) lang.Object

func (*SimpleAttributes) GetAttributeRequired added in v0.0.3

func (inst *SimpleAttributes) GetAttributeRequired(name string) (lang.Object, error)

func (*SimpleAttributes) Import

func (inst *SimpleAttributes) Import(src map[string]lang.Object)

func (*SimpleAttributes) SetAttribute added in v0.0.3

func (inst *SimpleAttributes) SetAttribute(name string, value lang.Object)

type SimpleEnvironment

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

func (*SimpleEnvironment) Export

func (inst *SimpleEnvironment) Export(dst map[string]string) map[string]string

func (*SimpleEnvironment) GetEnv

func (inst *SimpleEnvironment) GetEnv(name string) (string, error)

func (*SimpleEnvironment) Import

func (inst *SimpleEnvironment) Import(src map[string]string)

func (*SimpleEnvironment) SetEnv

func (inst *SimpleEnvironment) SetEnv(name string, value string)

type SimpleParameters

type SimpleParameters struct {
}

func (*SimpleParameters) Export

func (inst *SimpleParameters) Export(table map[string]string) map[string]string

func (*SimpleParameters) GetParam

func (inst *SimpleParameters) GetParam(name string) (string, error)

func (*SimpleParameters) Import

func (inst *SimpleParameters) Import(src map[string]string)

type SimpleProperties

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

SimpleProperties 实现一个简单的 Properties 集合

func (*SimpleProperties) Clear

func (inst *SimpleProperties) Clear()

Clear 清空本集合中的所有内容

func (*SimpleProperties) Export

func (inst *SimpleProperties) Export(dst map[string]string) map[string]string

Export 把本集合中的所有键值对导出

func (*SimpleProperties) GetProperty

func (inst *SimpleProperties) GetProperty(name string, defaultValue string) string

GetProperty 在集合中取指定的值,如果没有则返回默认值

func (*SimpleProperties) GetPropertyRequired

func (inst *SimpleProperties) GetPropertyRequired(name string) (string, error)

GetPropertyRequired 在集合中取指定的值,如果没有则返回error

func (*SimpleProperties) Import

func (inst *SimpleProperties) Import(src map[string]string)

Import 把参数 src 中的所有键值对导入本集合,保留原有内容(如果没有被覆盖)

func (*SimpleProperties) SetProperty

func (inst *SimpleProperties) SetProperty(name string, value string)

SetProperty 给集合中指定的键值对赋值

Jump to

Keyboard shortcuts

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