csv

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 13 Imported by: 3

Documentation

Index

Constants

View Source
const (
	TagName = "csvName"
)

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

func (*Accessor) Interfacer

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

func (*Accessor) Reset

func (a *Accessor) Reset()

func (*Accessor) Set

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

func (*Accessor) Stringify

func (a *Accessor) Stringify(writer *writer)

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 {
	FieldSeparator    string
	ObjectSeparator   string
	EncloseBy         string
	EscapeBy          string
	NullValue         string
	Stringify         StringifyConfig
	UniqueFields      []string
	References        []*Reference // parent -> children. Foo.ID -> Boo.FooId
	ExcludedPaths     []string
	StringifierConfig io.StringifierConfig
}

Config represents reader config

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{}]PresenceIndex

func (ObjectIndex) Index

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

type PresenceIndex

type PresenceIndex map[interface{}]bool

func (PresenceIndex) Has

func (p PresenceIndex) Has(value interface{}) bool

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 UnmarshalSession

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

Jump to

Keyboard shortcuts

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