Help us shape the future of Go! Take the 2026 Go Developer Survey

xmlify

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 15 Imported by: 3

README

xmlify

Documentation

Index

Constants

View Source
const (
	TagName = "xmlify"
)

Variables

This section is empty.

Functions

func Elem

func Elem(rType reflect.Type) reflect.Type

func EscapeSpecialChars

func EscapeSpecialChars(value string, config *Config) string

func WriteObject

func WriteObject(writer *Buffer, config *Config, values []string, wasString []bool)

Types

type Accessor

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

func (*Accessor) Has

func (a *Accessor) Has() bool

func (*Accessor) Headers

func (a *Accessor) Headers() ([]string, []string)

func (*Accessor) Interfacer

func (a *Accessor) Interfacer() *xunsafe.Type

func (*Accessor) RegularHeaders

func (a *Accessor) RegularHeaders() ([]string, []string)

func (*Accessor) Reset

func (a *Accessor) Reset()

func (*Accessor) ResetAllChildren

func (a *Accessor) ResetAllChildren()

func (*Accessor) Set

func (a *Accessor) Set(pointer unsafe.Pointer)

func (*Accessor) SetValue added in v0.2.0

func (a *Accessor) SetValue(value interface{})

SetValue retains a real struct allocation for value inputs, including Go's direct-interface single-pointer structs. Already-addressable rows are reused.

type Buffer

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

Buffer represents itemBuffer

func NewBuffer

func NewBuffer(size int) *Buffer

NewBuffer creates a itemBuffer instance with given initial size

func (*Buffer) Read

func (b *Buffer) Read(dest []byte) (int, error)

Read reads current item itemBuffer to dest

type Config

type Config struct {
	Style string // TODO MFI delete style
	// PreserveEmptyHolders emits a field for nil/empty typed relation holders.
	PreserveEmptyHolders bool
	// TODO MFI move below to another config
	RootTag                string
	HeaderTag              string
	HeaderRowTag           string
	HeaderRowFieldAttr     string
	HeaderRowFieldTypeAttr string
	HeaderRowFieldType     map[string]string
	DataTag                string
	DataRowTag             string
	DataRowFieldTag        string
	DataRowFieldTypes      map[string]string
	TabularNullValue       string
	NewLineSeparator       string
	////
	RegularRootTag   string
	RegularRowTag    string
	RegularNullValue string
	// TODO map of types for header and data
	FieldSeparator  string
	ObjectSeparator string
	EncloseBy       string
	EscapeBy        string
	NullValue       string

	Stringify         StringifyConfig
	UniqueFields      []string
	References        []*Reference // parent -> children. Example02.ID -> Boo.FooId
	ExcludedPaths     []string
	StringifierConfig io.StringifierConfig
	// contains filtered or unexported fields
}

type Field

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

type Index

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

func (*Index) Get

func (i *Index) Get(key string) (interface{}, bool)

func (*Index) Has

func (i *Index) Has(owner, value interface{}) bool

type Marshaller

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

func NewMarshaller

func NewMarshaller(rType reflect.Type, config *Config) (*Marshaller, error)

func (*Marshaller) Marshal

func (m *Marshaller) Marshal(val interface{}, options ...interface{}) ([]byte, error)

func (*Marshaller) ReadHeaders

func (m *Marshaller) ReadHeaders(b []byte) ([]string, error)

func (*Marshaller) Unmarshal

func (m *Marshaller) Unmarshal(b []byte, dest interface{}) error

type Node

type Node interface {
	ID() interface{}
	ParentID() interface{}
	AddChildren(node Node)
}

func BuildTree

func BuildTree(nodes []Node) []Node

type NodeIndex

type NodeIndex map[interface{}]map[interface{}]bool

func (NodeIndex) Get

func (i NodeIndex) Get(id interface{}) map[interface{}]bool

type Object

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

func ParentOf

func ParentOf(objects []*Object) (*Object, bool)

func (*Object) Accessor

func (o *Object) Accessor(accessorIndex int, mainConfig *Config, depth int, configs []*Config) (*Accessor, error)

func (*Object) AddChildren

func (o *Object) AddChildren(node Node)

func (*Object) AddHolder

func (o *Object) AddHolder(field *Field, holder *string)

func (*Object) CheckIndexed

func (o *Object) CheckIndexed() (interface{}, bool)

func (*Object) Has

func (o *Object) Has(parent interface{}, value interface{}) bool

func (*Object) ID

func (o *Object) ID() interface{}

func (*Object) ParentID

func (o *Object) ParentID() interface{}

func (*Object) Umarshal

func (o *Object) Umarshal() error

type ObjectIndex

type ObjectIndex map[interface{}]setMarker

func (ObjectIndex) Index

func (i ObjectIndex) Index(value interface{}) setMarker

type Reader

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

Reader represents plain text reader

func NewReader

func NewReader(any interface{}, config *Config, options ...interface{}) (*Reader, reflect.Type, error)

NewReader returns Reader instance and actual data struct type. e.g. data is type of []*Foo - returns Foo.

func (*Reader) ItemCount

func (r *Reader) ItemCount() int

ItemCount returns count of items inside itemBuffer

func (*Reader) Read

func (r *Reader) Read(buffer []byte) (n int, err error)

Read data into itemBuffer

type Reference

type Reference struct {
	ParentField string
	ChildField  string
}

type StringifyConfig

type StringifyConfig struct {
	IgnoreFieldSeparator  bool
	IgnoreObjectSeparator bool
	IgnoreEncloseBy       bool
}

StringifyConfig "extends" Config with ignore flags

type Tag

type Tag struct {
	format.Tag
	Path         string
	Tabular      bool
	OmitTagName  bool
	Cdata        bool
	NullifyEmpty bool
}

Tag represent field tag

func ParseTag

func ParseTag(rTag reflect.StructTag) (*Tag, error)

Parse Tag parses tag

type UnmarshalSession

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

type XMLMarhsaler

type XMLMarhsaler interface {
	MarshalXML() ([]byte, error)
}

Jump to

Keyboard shortcuts

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