Documentation
¶
Index ¶
- func GetBuiltinConverterTypes() []reflect.Type
- func RegisterBuiltinConverters(registry *ConverterRegistry) error
- func RunDemo()
- type AutoPDFFormattable
- type ConversionOptions
- type Converter
- type ConverterBuilder
- func (b *ConverterBuilder) Build() *StructConverter
- func (b *ConverterBuilder) WithBuiltinConverters() *ConverterBuilder
- func (b *ConverterBuilder) WithCustomConverter(typ interface{}, converter Converter) *ConverterBuilder
- func (b *ConverterBuilder) WithDefaultFlatten(flatten bool) *ConverterBuilder
- func (b *ConverterBuilder) WithDurationFormat(format string) *ConverterBuilder
- func (b *ConverterBuilder) WithOmitEmpty(omit bool) *ConverterBuilder
- func (b *ConverterBuilder) WithRegistry(r *ConverterRegistry) *ConverterBuilder
- func (b *ConverterBuilder) WithSliceSeparator(separator string) *ConverterBuilder
- func (b *ConverterBuilder) WithTagName(name string) *ConverterBuilder
- func (b *ConverterBuilder) WithTimeFormat(format string) *ConverterBuilder
- type ConverterRegistry
- func (r *ConverterRegistry) Clear()
- func (r *ConverterRegistry) Count() int
- func (r *ConverterRegistry) Get(typ reflect.Type) (Converter, bool)
- func (r *ConverterRegistry) Has(typ reflect.Type) bool
- func (r *ConverterRegistry) List() []reflect.Type
- func (r *ConverterRegistry) Register(typ reflect.Type, converter Converter) error
- func (r *ConverterRegistry) RegisterBuiltinConverters() error
- func (r *ConverterRegistry) RegisterInterface(typ reflect.Type, converter Converter) error
- func (r *ConverterRegistry) Unregister(typ reflect.Type)
- type DemoStruct
- type DurationConverter
- type DurationPtrConverter
- type FieldTag
- type FloatSliceConverter
- type IntSliceConverter
- type SliceConverter
- type StringSliceConverter
- type StructConverter
- type TimeConverter
- type TimePtrConverter
- type URLConverter
- type URLPtrConverter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetBuiltinConverterTypes ¶
GetBuiltinConverterTypes returns a list of all built-in converter types
func RegisterBuiltinConverters ¶
func RegisterBuiltinConverters(registry *ConverterRegistry) error
RegisterBuiltinConverters registers all built-in converters
Types ¶
type AutoPDFFormattable ¶
AutoPDFFormattable allows custom types to define their own conversion
type ConversionOptions ¶
ConversionOptions configures conversion behavior
type Converter ¶
type Converter interface {
Convert(value interface{}) (config.Variable, error)
CanConvert(value interface{}) bool
}
Converter converts Go values to AutoPDF Variables
type ConverterBuilder ¶
type ConverterBuilder struct {
// contains filtered or unexported fields
}
ConverterBuilder provides a fluent API for converter construction
func NewConverterBuilder ¶
func NewConverterBuilder() *ConverterBuilder
NewConverterBuilder creates a new ConverterBuilder with default options
func (*ConverterBuilder) Build ¶
func (b *ConverterBuilder) Build() *StructConverter
Build creates the StructConverter with the configured options
func (*ConverterBuilder) WithBuiltinConverters ¶
func (b *ConverterBuilder) WithBuiltinConverters() *ConverterBuilder
WithBuiltinConverters registers all built-in converters
func (*ConverterBuilder) WithCustomConverter ¶
func (b *ConverterBuilder) WithCustomConverter(typ interface{}, converter Converter) *ConverterBuilder
WithCustomConverter registers a custom converter for a specific type
func (*ConverterBuilder) WithDefaultFlatten ¶
func (b *ConverterBuilder) WithDefaultFlatten(flatten bool) *ConverterBuilder
WithDefaultFlatten sets the default flattening behavior
func (*ConverterBuilder) WithDurationFormat ¶
func (b *ConverterBuilder) WithDurationFormat(format string) *ConverterBuilder
WithDurationFormat sets the default duration format for time.Duration converters
func (*ConverterBuilder) WithOmitEmpty ¶
func (b *ConverterBuilder) WithOmitEmpty(omit bool) *ConverterBuilder
WithOmitEmpty sets the omit empty behavior
func (*ConverterBuilder) WithRegistry ¶
func (b *ConverterBuilder) WithRegistry(r *ConverterRegistry) *ConverterBuilder
WithRegistry sets the converter registry
func (*ConverterBuilder) WithSliceSeparator ¶
func (b *ConverterBuilder) WithSliceSeparator(separator string) *ConverterBuilder
WithSliceSeparator sets the default separator for slice flattening
func (*ConverterBuilder) WithTagName ¶
func (b *ConverterBuilder) WithTagName(name string) *ConverterBuilder
WithTagName sets the struct tag name to use
func (*ConverterBuilder) WithTimeFormat ¶
func (b *ConverterBuilder) WithTimeFormat(format string) *ConverterBuilder
WithTimeFormat sets the default time format for time.Time converters
type ConverterRegistry ¶
type ConverterRegistry struct {
// contains filtered or unexported fields
}
ConverterRegistry manages custom converters for specific types
func NewConverterRegistry ¶
func NewConverterRegistry() *ConverterRegistry
NewConverterRegistry creates a new converter registry
func (*ConverterRegistry) Clear ¶
func (r *ConverterRegistry) Clear()
Clear removes all registered converters
func (*ConverterRegistry) Count ¶
func (r *ConverterRegistry) Count() int
Count returns the number of registered converters
func (*ConverterRegistry) Get ¶
func (r *ConverterRegistry) Get(typ reflect.Type) (Converter, bool)
Get retrieves a converter for a specific type
func (*ConverterRegistry) Has ¶
func (r *ConverterRegistry) Has(typ reflect.Type) bool
Has checks if a converter is registered for a specific type
func (*ConverterRegistry) List ¶
func (r *ConverterRegistry) List() []reflect.Type
List returns all registered types
func (*ConverterRegistry) Register ¶
func (r *ConverterRegistry) Register(typ reflect.Type, converter Converter) error
Register registers a converter for a specific type
func (*ConverterRegistry) RegisterBuiltinConverters ¶
func (r *ConverterRegistry) RegisterBuiltinConverters() error
RegisterBuiltinConverters registers all built-in converters
func (*ConverterRegistry) RegisterInterface ¶
func (r *ConverterRegistry) RegisterInterface(typ reflect.Type, converter Converter) error
RegisterInterface registers a converter for an interface type
func (*ConverterRegistry) Unregister ¶
func (r *ConverterRegistry) Unregister(typ reflect.Type)
Unregister removes a converter for a specific type
type DemoStruct ¶
type DemoStruct struct {
Title string `autopdf:"title"`
Author string `autopdf:"author"`
CreatedAt time.Time `autopdf:"created_at"`
Tags []string `autopdf:"tags,flatten"`
IsActive bool `autopdf:"is_active"`
}
DemoStruct demonstrates the struct conversion feature
type DurationConverter ¶
type DurationConverter struct {
Format string // "seconds", "milliseconds", "string"
}
DurationConverter converts time.Duration to string
func NewDurationConverter ¶
func NewDurationConverter() *DurationConverter
NewDurationConverter creates a new DurationConverter with default format
func NewDurationConverterWithFormat ¶
func NewDurationConverterWithFormat(format string) *DurationConverter
NewDurationConverterWithFormat creates a new DurationConverter with custom format
func (*DurationConverter) CanConvert ¶
func (dc *DurationConverter) CanConvert(value interface{}) bool
CanConvert checks if the value is a time.Duration
type DurationPtrConverter ¶
type DurationPtrConverter struct {
Format string // "seconds", "milliseconds", "string"
}
DurationPtrConverter converts *time.Duration to string
func NewDurationPtrConverter ¶
func NewDurationPtrConverter() *DurationPtrConverter
NewDurationPtrConverter creates a new DurationPtrConverter with default format
func NewDurationPtrConverterWithFormat ¶
func NewDurationPtrConverterWithFormat(format string) *DurationPtrConverter
NewDurationPtrConverterWithFormat creates a new DurationPtrConverter with custom format
func (*DurationPtrConverter) CanConvert ¶
func (dpc *DurationPtrConverter) CanConvert(value interface{}) bool
CanConvert checks if the value is a *time.Duration
type FieldTag ¶
type FieldTag struct {
Name string // Field name in template
Omit bool // Skip this field (for "-" tag)
OmitEmpty bool // Omit if empty value
Flatten bool // Flatten nested structures
Inline bool // Inline nested struct fields
Options []string // Additional options
}
FieldTag represents parsed autopdf struct tag
func ParseTag ¶
ParseTag parses "autopdf" struct tag Supports formats:
autopdf:"field_name" autopdf:"field_name,omitempty" autopdf:"field_name,flatten" autopdf:"field_name,inline" autopdf:"-" (skip field)
type FloatSliceConverter ¶
type FloatSliceConverter struct {
// contains filtered or unexported fields
}
FloatSliceConverter is a specialized converter for []float64
func NewFloatSliceConverter ¶
func NewFloatSliceConverter() *FloatSliceConverter
NewFloatSliceConverter creates a new FloatSliceConverter
func NewFloatSliceConverterWithSeparator ¶
func NewFloatSliceConverterWithSeparator(separator string) *FloatSliceConverter
NewFloatSliceConverterWithSeparator creates a new FloatSliceConverter with custom separator
func (*FloatSliceConverter) CanConvert ¶
func (fsc *FloatSliceConverter) CanConvert(value interface{}) bool
CanConvert checks if the value is a []float64
type IntSliceConverter ¶
type IntSliceConverter struct {
// contains filtered or unexported fields
}
IntSliceConverter is a specialized converter for []int
func NewIntSliceConverter ¶
func NewIntSliceConverter() *IntSliceConverter
NewIntSliceConverter creates a new IntSliceConverter
func NewIntSliceConverterWithSeparator ¶
func NewIntSliceConverterWithSeparator(separator string) *IntSliceConverter
NewIntSliceConverterWithSeparator creates a new IntSliceConverter with custom separator
func (*IntSliceConverter) CanConvert ¶
func (isc *IntSliceConverter) CanConvert(value interface{}) bool
CanConvert checks if the value is a []int
type SliceConverter ¶
type SliceConverter struct {
// contains filtered or unexported fields
}
SliceConverter converts slices and arrays
func NewSliceConverter ¶
func NewSliceConverter() *SliceConverter
NewSliceConverter creates a new SliceConverter
func NewSliceConverterWithOptions ¶
func NewSliceConverterWithOptions(flatten bool, separator string) *SliceConverter
NewSliceConverterWithOptions creates a new SliceConverter with options
func (*SliceConverter) CanConvert ¶
func (sc *SliceConverter) CanConvert(value interface{}) bool
CanConvert checks if the value is a slice or array
func (*SliceConverter) Convert ¶
func (sc *SliceConverter) Convert(value interface{}) (config.Variable, error)
Convert creates SliceVariable or flattened string based on options
func (*SliceConverter) SetElementConverter ¶
func (sc *SliceConverter) SetElementConverter(converter Converter)
SetElementConverter sets the converter for individual elements
type StringSliceConverter ¶
type StringSliceConverter struct {
// contains filtered or unexported fields
}
StringSliceConverter is a specialized converter for []string
func NewStringSliceConverter ¶
func NewStringSliceConverter() *StringSliceConverter
NewStringSliceConverter creates a new StringSliceConverter
func NewStringSliceConverterWithSeparator ¶
func NewStringSliceConverterWithSeparator(separator string) *StringSliceConverter
NewStringSliceConverterWithSeparator creates a new StringSliceConverter with custom separator
func (*StringSliceConverter) CanConvert ¶
func (ssc *StringSliceConverter) CanConvert(value interface{}) bool
CanConvert checks if the value is a []string
type StructConverter ¶
type StructConverter struct {
// contains filtered or unexported fields
}
StructConverter is the main converter for structs
func BuildForFlattened ¶
func BuildForFlattened() *StructConverter
BuildForFlattened creates a StructConverter that flattens nested structures
func BuildForTemplates ¶
func BuildForTemplates() *StructConverter
BuildForTemplates creates a StructConverter optimized for template usage
func BuildWithDefaults ¶
func BuildWithDefaults() *StructConverter
BuildWithDefaults creates a StructConverter with sensible defaults
func NewStructConverter ¶
func NewStructConverter() *StructConverter
NewStructConverter creates a new StructConverter with default options
func NewStructConverterWithOptions ¶
func NewStructConverterWithOptions(options ConversionOptions) *StructConverter
NewStructConverterWithOptions creates a new StructConverter with custom options
func (*StructConverter) ConvertStruct ¶
func (sc *StructConverter) ConvertStruct(v interface{}) (*config.Variables, error)
ConvertStruct converts a struct to Variables using reflection
type TimeConverter ¶
type TimeConverter struct {
Format string // Default: RFC3339
}
TimeConverter converts time.Time to string
func NewTimeConverter ¶
func NewTimeConverter() *TimeConverter
NewTimeConverter creates a new TimeConverter with default format
func NewTimeConverterWithFormat ¶
func NewTimeConverterWithFormat(format string) *TimeConverter
NewTimeConverterWithFormat creates a new TimeConverter with custom format
func (*TimeConverter) CanConvert ¶
func (tc *TimeConverter) CanConvert(value interface{}) bool
CanConvert checks if the value is a time.Time
type TimePtrConverter ¶
type TimePtrConverter struct {
Format string // Default: RFC3339
}
TimePtrConverter converts *time.Time to string
func NewTimePtrConverter ¶
func NewTimePtrConverter() *TimePtrConverter
NewTimePtrConverter creates a new TimePtrConverter with default format
func NewTimePtrConverterWithFormat ¶
func NewTimePtrConverterWithFormat(format string) *TimePtrConverter
NewTimePtrConverterWithFormat creates a new TimePtrConverter with custom format
func (*TimePtrConverter) CanConvert ¶
func (tpc *TimePtrConverter) CanConvert(value interface{}) bool
CanConvert checks if the value is a *time.Time
type URLConverter ¶
type URLConverter struct{}
URLConverter converts url.URL to string
func NewURLConverter ¶
func NewURLConverter() *URLConverter
NewURLConverter creates a new URLConverter
func (*URLConverter) CanConvert ¶
func (uc *URLConverter) CanConvert(value interface{}) bool
CanConvert checks if the value is a url.URL
type URLPtrConverter ¶
type URLPtrConverter struct{}
URLPtrConverter converts *url.URL to string
func NewURLPtrConverter ¶
func NewURLPtrConverter() *URLPtrConverter
NewURLPtrConverter creates a new URLPtrConverter
func (*URLPtrConverter) CanConvert ¶
func (upc *URLPtrConverter) CanConvert(value interface{}) bool
CanConvert checks if the value is a *url.URL