parent
cedcb72337
commit
62bab50f11
@ -1,70 +0,0 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// 🚀 Project active3
|
||||
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name c.go
|
||||
// ✍️ Created by DEV
|
||||
// 📅 Modified 09/05/2024
|
||||
//
|
||||
// 🔒 Copyright 2024 activething.com
|
||||
//
|
||||
// 📜 LICENSE --------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package erinfo
|
||||
|
||||
|
||||
type ErrorBuilder struct {
|
||||
fields.
|
||||
}
|
||||
|
||||
|
||||
|
||||
Buildable (value Buildable)
|
||||
|
||||
Any (value any)
|
||||
|
||||
Raw (value []byte)
|
||||
Binary(value []byte)
|
||||
String(value string)
|
||||
|
||||
Bool (value bool)
|
||||
|
||||
Int (value int )
|
||||
Int8 (value int8 )
|
||||
Int16 (value int16)
|
||||
Int32 (value int32)
|
||||
Int64 (value int64)
|
||||
|
||||
Uint (value uint )
|
||||
Uint8 (value uint8 )
|
||||
Uint16(value uint16)
|
||||
Uint32(value uint32)
|
||||
Uint64(value uint64)
|
||||
|
||||
Float32 (value float32)
|
||||
Float64 (value float64)
|
||||
|
||||
Error (value error)
|
||||
|
||||
Time (value time.Time)
|
||||
Duration(value time.Duration)
|
||||
Reflect (value reflect.Value)
|
||||
|
||||
List (func (listBuilder ListBuilder ))
|
||||
Map (func (mapBuilder MapBuilder ))
|
||||
Object(func (objBuilder ObjectBuilder))
|
||||
|
||||
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project active2
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File Name collectable.go
|
||||
// Created by DEV
|
||||
// Modified 20/04/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package erinfo
|
||||
|
||||
type (
|
||||
|
||||
Collectable interface {
|
||||
Collect (collector Collector)
|
||||
}
|
||||
)
|
||||
@ -1,51 +0,0 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project active2
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File Name collector.go
|
||||
// Created by DEV
|
||||
// Modified 20/04/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package erinfo
|
||||
|
||||
import (
|
||||
"flds"
|
||||
"reflect"
|
||||
"time"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
Collector interface {
|
||||
AddField (field ... flds.Field)
|
||||
|
||||
AddFieldAny (name string, value any)
|
||||
AddFieldBool (name string, value bool)
|
||||
AddFieldBinary (name string, value []byte)
|
||||
AddFieldString (name string, value string)
|
||||
AddFieldInt (name string, value int)
|
||||
AddFieldUint (name string, value uint)
|
||||
AddFieldFloat (name string, value float64)
|
||||
AddFieldTime (name string, value time.Time)
|
||||
AddFieldDuration(name string, value time.Duration)
|
||||
AddFieldError (name string, value error)
|
||||
AddFieldReflect (name string, value reflect.Value)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@ -0,0 +1,101 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// 🚀 Project active3
|
||||
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name c.go
|
||||
// ✍️ Created by DEV
|
||||
// 📅 Modified 09/05/2024
|
||||
//
|
||||
// 🔒 Copyright 2024 activething.com
|
||||
//
|
||||
// 📜 LICENSE --------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package erinfo
|
||||
|
||||
import (
|
||||
"blds"
|
||||
"blds/bstate"
|
||||
"flds"
|
||||
"reflect"
|
||||
"time"
|
||||
)
|
||||
|
||||
type objectBuilder struct {
|
||||
curName string
|
||||
nexVal bool
|
||||
fields flds.FieldsObject
|
||||
}
|
||||
|
||||
|
||||
func (b *objectBuilder) Field (name string) blds.ValueBuilder {
|
||||
if b.nexVal {
|
||||
panic(bstate.G.ErrStateInvalidElem)
|
||||
}
|
||||
b.curName= name
|
||||
b.nexVal = true
|
||||
|
||||
return b
|
||||
}
|
||||
|
||||
|
||||
func (b *objectBuilder) list() flds.Fields {
|
||||
return b.fields.List() }
|
||||
|
||||
func (b *objectBuilder) add (field flds.Field) {
|
||||
if field != nil {
|
||||
if er := b.fields.Add(field); er != nil {
|
||||
panic(er)
|
||||
}
|
||||
}
|
||||
b.curName= ""
|
||||
b.nexVal = false
|
||||
}
|
||||
|
||||
func (b *objectBuilder) Any (value any) { b.add (flds.NewFieldAny (b.curName,value)) }
|
||||
|
||||
func (b *objectBuilder) Raw (value []byte) { b.add (flds.NewFieldBinary (b.curName,value)) }
|
||||
func (b *objectBuilder) Binary(value []byte) { b.add (flds.NewFieldBinary (b.curName,value)) }
|
||||
func (b *objectBuilder) String(value string) { b.add (flds.NewFieldString (b.curName,value)) }
|
||||
|
||||
func (b *objectBuilder) Bool (value bool) { b.add (flds.NewFieldBool (b.curName,value)) }
|
||||
|
||||
func (b *objectBuilder) Int (value int ) { b.add (flds.NewFieldInt (b.curName,value)) }
|
||||
func (b *objectBuilder) Int8 (value int8 ) { b.add (flds.NewFieldInt (b.curName,int(value))) }
|
||||
func (b *objectBuilder) Int16 (value int16) { b.add (flds.NewFieldInt (b.curName,int(value))) }
|
||||
func (b *objectBuilder) Int32 (value int32) { b.add (flds.NewFieldInt (b.curName,int(value))) }
|
||||
func (b *objectBuilder) Int64 (value int64) { b.add (flds.NewFieldInt (b.curName,int(value))) }
|
||||
|
||||
func (b *objectBuilder) Uint (value uint ) { b.add (flds.NewFieldUint (b.curName,value)) }
|
||||
func (b *objectBuilder) Uint8 (value uint8 ) { b.add (flds.NewFieldUint (b.curName,uint(value))) }
|
||||
func (b *objectBuilder) Uint16(value uint16) { b.add (flds.NewFieldUint (b.curName,uint(value))) }
|
||||
func (b *objectBuilder) Uint32(value uint32) { b.add (flds.NewFieldUint (b.curName,uint(value))) }
|
||||
func (b *objectBuilder) Uint64(value uint64) { b.add (flds.NewFieldUint (b.curName,uint(value))) }
|
||||
|
||||
func (b *objectBuilder) Float32 (value float32) { b.add (flds.NewFieldFloat (b.curName,float64(value))) }
|
||||
func (b *objectBuilder) Float64 (value float64) { b.add (flds.NewFieldFloat (b.curName,value)) }
|
||||
|
||||
func (b *objectBuilder) Error (value error) { b.add (flds.NewFieldError (b.curName,value)) }
|
||||
|
||||
func (b *objectBuilder) Time (value time.Time) { b.add (flds.NewFieldTime (b.curName,value)) }
|
||||
func (b *objectBuilder) Duration(value time.Duration) { b.add (flds.NewFieldDuration (b.curName,value)) }
|
||||
|
||||
func (b *objectBuilder) Reflect (value reflect.Value) { b.add (flds.NewFieldReflect (b.curName,value)) }
|
||||
|
||||
func (b *objectBuilder) List (_ func (_ blds.ListBuilder )) { b.add(nil) }
|
||||
func (b *objectBuilder) Map (_ func (_ blds.MapBuilder )) { b.add(nil) }
|
||||
func (b *objectBuilder) Object(_ func (_ blds.ObjectBuilder)) { b.add(nil) }
|
||||
|
||||
|
||||
|
||||
@ -1,142 +0,0 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// 🚀 Project active3
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name field_any.go
|
||||
// ✍️ Created by DEV
|
||||
// 📅 Modified 01/05/2024
|
||||
//
|
||||
// 🔒 COPYRIGHT Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package flds
|
||||
|
||||
import (
|
||||
"blds"
|
||||
"reflect"
|
||||
"time"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
FieldAny struct {
|
||||
partialField[any]
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
func NewFieldAny (name string, value any) *FieldAny {
|
||||
return &FieldAny{ partialField : makePartialFieldLocal[any](name,value) } }
|
||||
|
||||
|
||||
func NewDFieldAny(name string, valueFn func() any) *FieldAny {
|
||||
return &FieldAny{ partialField : makePartialFieldDefer[any](name,valueFn) } }
|
||||
|
||||
func NewDOFieldAny (name string, valueFn func()any) *FieldAny {
|
||||
return &FieldAny{ partialField : makePartialFieldOnce[any](name,valueFn) }}
|
||||
|
||||
|
||||
func (f FieldAny) Kind() Kind {
|
||||
return KindAny | f.valuerKind() }
|
||||
|
||||
|
||||
func (f FieldAny) AsBool() (bool,bool) {
|
||||
v,ok := f.Native().(bool)
|
||||
return v,ok
|
||||
}
|
||||
|
||||
func (f FieldAny) AsBinary() ([]byte,bool) {
|
||||
v, ok := f.Native().([]byte)
|
||||
return v, ok
|
||||
}
|
||||
|
||||
func (f FieldAny) AsString() (string,bool) {
|
||||
v,ok := f.Native().(string)
|
||||
return v,ok
|
||||
}
|
||||
|
||||
func (f FieldAny) AsInt() (int,bool) {
|
||||
switch t := f.Native().(type) {
|
||||
case int : return t,true
|
||||
case int8 : return int(t),true
|
||||
case int16: return int(t),true
|
||||
case int32: return int(t),true
|
||||
case int64: return int(t),true
|
||||
default : return 0,false
|
||||
}
|
||||
}
|
||||
|
||||
func (f FieldAny) AsUint() (uint,bool) {
|
||||
switch t := f.Native().(type) {
|
||||
case uint : return t,true
|
||||
case uint8 : return uint(t),true
|
||||
case uint16: return uint(t),true
|
||||
case uint32: return uint(t),true
|
||||
case uint64: return uint(t),true
|
||||
default : return 0,false
|
||||
}
|
||||
}
|
||||
|
||||
func (f FieldAny) AsFloat() (float64,bool) {
|
||||
vl := f.Native()
|
||||
v, ok := vl.(float64)
|
||||
if !ok {
|
||||
var f32 float32
|
||||
if f32,ok = vl.(float32); ok {
|
||||
v = float64(f32)
|
||||
}
|
||||
}
|
||||
return v, ok
|
||||
}
|
||||
|
||||
|
||||
func (f FieldAny) Date () (time.Time,bool) {
|
||||
v, ok := f.Native().(time.Time)
|
||||
return v, ok
|
||||
}
|
||||
|
||||
func (f FieldAny) AsTime() (time.Time,bool) {
|
||||
v, ok := f.Native().(time.Time)
|
||||
return v, ok
|
||||
}
|
||||
|
||||
func (f FieldAny) AsDuration() (time.Duration,bool) {
|
||||
v, ok := f.Native().(time.Duration)
|
||||
return v, ok
|
||||
}
|
||||
|
||||
|
||||
|
||||
func (f FieldAny) AsError() (error,bool) {
|
||||
v, ok := f.Native().(error)
|
||||
return v, ok
|
||||
}
|
||||
|
||||
|
||||
func (f FieldAny) AsReflect() (reflect.Value,bool) {
|
||||
v, ok := f.Native().(reflect.Value)
|
||||
return v, ok
|
||||
}
|
||||
|
||||
|
||||
func (f FieldAny) Build (builder blds.Builder) {
|
||||
builder.Object(func(b blds.ObjectBuilder){ f.BuildField(b) }) }
|
||||
|
||||
|
||||
func (f FieldAny) BuildField (obuilder blds.ObjectBuilder) {
|
||||
obuilder.Field(f.name).Any(f.Native()) }
|
||||
|
||||
|
||||
|
||||
@ -1,65 +0,0 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// 🚀 Project active3
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name field_binary.go
|
||||
// ✍️ Created by DEV
|
||||
// 📅 Modified 01/05/2024
|
||||
//
|
||||
// 🔒 COPYRIGHT Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package flds
|
||||
|
||||
import (
|
||||
"blds"
|
||||
"encoding/base64"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
FieldBinary struct {
|
||||
|
||||
partialField[[]byte]
|
||||
}
|
||||
)
|
||||
|
||||
func NewFieldBinary (name string, value []byte) *FieldBinary {
|
||||
return &FieldBinary{ partialField : makePartialFieldLocal[[]byte](name,value) } }
|
||||
|
||||
func NewDFieldBinary (name string, valueFn func() []byte) *FieldBinary {
|
||||
return &FieldBinary{ partialField : makePartialFieldDefer[[]byte](name,valueFn) } }
|
||||
|
||||
func NewDOFieldBinary (name string, valueFn func() []byte) *FieldBinary {
|
||||
return &FieldBinary{ partialField : makePartialFieldOnce[[]byte](name,valueFn) } }
|
||||
|
||||
|
||||
func (f FieldBinary) Kind () Kind {
|
||||
return KindBinary | f.valuerKind() }
|
||||
|
||||
|
||||
func (f FieldBinary) AsBinary() ([]byte,bool) {
|
||||
return f.Native(),true }
|
||||
|
||||
|
||||
func (f FieldBinary) AppendAsString (dest []byte) []byte {
|
||||
return append(dest,[]byte(base64.StdEncoding.EncodeToString(f.Native()))...) }
|
||||
|
||||
|
||||
func (f FieldBinary) Build (builder blds.Builder) {
|
||||
builder.Object(func(b blds.ObjectBuilder){ f.BuildField(b) }) }
|
||||
|
||||
func (f FieldBinary) BuildField (obuilder blds.ObjectBuilder) {
|
||||
obuilder.Field(f.name).Binary(f.Native()) }
|
||||
@ -1,67 +0,0 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// 🚀 Project active3
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name field_bool.go
|
||||
// ✍️ Created by DEV
|
||||
// 📅 Modified 01/05/2024
|
||||
//
|
||||
// 🔒 COPYRIGHT Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package flds
|
||||
|
||||
import (
|
||||
"blds"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
FieldBool struct {
|
||||
|
||||
partialField[bool]
|
||||
}
|
||||
)
|
||||
|
||||
func NewFieldBool (name string, value bool) *FieldBool {
|
||||
return &FieldBool{ partialField: makePartialFieldLocal[bool](name,value) } }
|
||||
|
||||
func NewDFieldBool (name string, valueFn func() bool) *FieldBool {
|
||||
return &FieldBool{ partialField: makePartialFieldDefer[bool](name,valueFn) } }
|
||||
|
||||
func NewDOFieldBool (name string, valueFn func() bool) *FieldBool {
|
||||
return &FieldBool{ partialField: makePartialFieldOnce[bool](name,valueFn) } }
|
||||
|
||||
|
||||
|
||||
func (f FieldBool) Kind () Kind {
|
||||
return KindBool | f.valuerKind() }
|
||||
|
||||
|
||||
func (f FieldBool) AsBool() (bool,bool) {
|
||||
return f.Native(),true }
|
||||
|
||||
|
||||
func (f FieldBool) AppendAsString (dest []byte) []byte {
|
||||
return strconv.AppendBool(dest,f.Native()) }
|
||||
|
||||
|
||||
func (f FieldBool) Build (builder blds.Builder) {
|
||||
builder.Object(func(b blds.ObjectBuilder){ f.BuildField(b) }) }
|
||||
|
||||
func (f FieldBool) BuildField (obuilder blds.ObjectBuilder) {
|
||||
obuilder.Field(f.name).Bool(f.Native()) }
|
||||
|
||||
@ -1,66 +0,0 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// 🚀 Project active3
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name field_time.go
|
||||
// ✍️ Created by DEV
|
||||
// 📅 Modified 01/05/2024
|
||||
//
|
||||
// 🔒 COPYRIGHT Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package flds
|
||||
|
||||
import (
|
||||
"blds"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
FieldDuration struct {
|
||||
|
||||
partialField [time.Duration]
|
||||
}
|
||||
)
|
||||
|
||||
func NewFieldDuration (name string, value time.Duration) *FieldDuration {
|
||||
return &FieldDuration{ partialField : makePartialFieldLocal[time.Duration](name,value) } }
|
||||
|
||||
func NewDFieldDuration (name string, valueFn func() time.Duration) *FieldDuration {
|
||||
return &FieldDuration{ partialField : makePartialFieldDefer[time.Duration](name,valueFn) } }
|
||||
|
||||
func NewDOFieldDuration (name string, valueFn func() time.Duration) *FieldDuration {
|
||||
return &FieldDuration{ partialField : makePartialFieldOnce[time.Duration](name,valueFn) } }
|
||||
|
||||
|
||||
|
||||
func (f FieldDuration) Kind () Kind {
|
||||
return KindDuration | f.valuerKind() }
|
||||
|
||||
|
||||
func (f FieldDuration) AsDuration() (time.Duration,bool) {
|
||||
return f.Native(),true }
|
||||
|
||||
func (f FieldDuration) AppendAsString(dest []byte) []byte {
|
||||
return strconv.AppendUint(dest,uint64(f.Native()),10) }
|
||||
|
||||
|
||||
func (f FieldDuration) Build (builder blds.Builder) {
|
||||
builder.Object(func(b blds.ObjectBuilder){ f.BuildField(b) })}
|
||||
|
||||
func (f FieldDuration) BuildField (obuilder blds.ObjectBuilder) {
|
||||
obuilder.Field(f.name).Duration(f.Native()) }
|
||||
@ -1,74 +0,0 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// 🚀 Project active3
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name field_error.go
|
||||
// ✍️ Created by DEV
|
||||
// 📅 Modified 01/05/2024
|
||||
//
|
||||
// 🔒 COPYRIGHT Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package flds
|
||||
|
||||
import (
|
||||
"blds"
|
||||
"typs/strs"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
FieldError struct {
|
||||
|
||||
partialField[error]
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
func NewFieldError (name string, value error) *FieldError {
|
||||
return &FieldError{ partialField : makePartialFieldLocal[error](name,value) }}
|
||||
|
||||
func NewDFieldError (name string, valueFn func() error) *FieldError {
|
||||
return &FieldError{ partialField : makePartialFieldDefer[error](name,valueFn) } }
|
||||
|
||||
func NewDOFieldError (name string, valueFn func() error) *FieldError {
|
||||
return &FieldError{ partialField : makePartialFieldOnce[error](name,valueFn) } }
|
||||
|
||||
|
||||
func (f FieldError) Kind () Kind {
|
||||
return KindError | f.valuerKind() }
|
||||
|
||||
|
||||
func (f FieldError) AsError() (error,bool) {
|
||||
return f.Native(),true }
|
||||
|
||||
func (f FieldError) AppendAsString (dest []byte) []byte {
|
||||
e := f.Native()
|
||||
if e == nil {
|
||||
return dest
|
||||
}
|
||||
if st,is := e.(strs.Stringer); is {
|
||||
return append(dest,[]byte(st.String())...)
|
||||
}
|
||||
return append(dest,[]byte(e.Error())...)
|
||||
}
|
||||
|
||||
|
||||
func (f FieldError) Build (builder blds.Builder) {
|
||||
builder.Object(func(b blds.ObjectBuilder){ f.BuildField(b) }) }
|
||||
|
||||
|
||||
func (f FieldError) BuildField (obuilder blds.ObjectBuilder) {
|
||||
obuilder.Field(f.name).Error(f.Native()) }
|
||||
@ -1,66 +0,0 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// 🚀 Project active3
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name field_float.go
|
||||
// ✍️ Created by DEV
|
||||
// 📅 Modified 01/05/2024
|
||||
//
|
||||
// 🔒 COPYRIGHT Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package flds
|
||||
|
||||
import (
|
||||
"blds"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
FieldFloat struct {
|
||||
|
||||
partialField[float64]
|
||||
}
|
||||
)
|
||||
|
||||
func NewFieldFloat (name string, value float64) *FieldFloat {
|
||||
return &FieldFloat{ partialField : makePartialFieldLocal[float64](name,value) } }
|
||||
|
||||
func NewDFieldFloat (name string, valueFn func()float64) *FieldFloat {
|
||||
return &FieldFloat{ partialField : makePartialFieldDefer[float64](name,valueFn) } }
|
||||
|
||||
func NewDOFieldFloat (name string, valueFn func()float64) *FieldFloat {
|
||||
return &FieldFloat{ partialField : makePartialFieldOnce[float64](name,valueFn) } }
|
||||
|
||||
|
||||
func (f FieldFloat) Kind () Kind {
|
||||
return KindFloat | f.valuerKind() }
|
||||
|
||||
|
||||
func (f FieldFloat) AsFloat() (float64,bool) {
|
||||
return f.Native(),true }
|
||||
|
||||
|
||||
func (f FieldFloat) AppendAsString (dest []byte) []byte {
|
||||
return strconv.AppendFloat(dest,f.Native(),'f',-1,64) }
|
||||
|
||||
|
||||
func (f FieldFloat) Build (builder blds.Builder) {
|
||||
builder.Object(func(b blds.ObjectBuilder){ f.BuildField(b) }) }
|
||||
|
||||
|
||||
func (f FieldFloat) BuildField (obuilder blds.ObjectBuilder) {
|
||||
obuilder.Field(f.name).Float64(f.Native()) }
|
||||
@ -1,71 +0,0 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// 🚀 Project active3
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name field_int.go
|
||||
// ✍️ Created by DEV
|
||||
// 📅 Modified 01/05/2024
|
||||
//
|
||||
// 🔒 COPYRIGHT Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package flds
|
||||
|
||||
import (
|
||||
"blds"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
FieldInt struct {
|
||||
partialField[int]
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
func NewFieldInt (name string, value int) *FieldInt {
|
||||
return &FieldInt{ partialField : makePartialFieldLocal[int](name,value) }}
|
||||
|
||||
func NewDFieldInt (name string, valueFn func()int) *FieldInt {
|
||||
return &FieldInt{ partialField : makePartialFieldDefer[int](name,valueFn) }}
|
||||
|
||||
func NewDOFieldInt (name string, valueFn func()int) *FieldInt {
|
||||
return &FieldInt{ partialField : makePartialFieldOnce[int](name,valueFn) }}
|
||||
|
||||
|
||||
|
||||
func (f FieldInt) Kind () Kind {
|
||||
return KindInt | f.valuerKind() }
|
||||
|
||||
|
||||
func (f FieldInt) AsInt() (int,bool) {
|
||||
return f.Native(),true }
|
||||
|
||||
|
||||
func (f FieldInt) AppendAsString (dest []byte) []byte {
|
||||
return strconv.AppendInt(dest,int64(f.Native()),10) }
|
||||
|
||||
|
||||
func (f FieldInt) Build (builder blds.Builder) {
|
||||
builder.Object(func(b blds.ObjectBuilder){ f.BuildField(b) }) }
|
||||
|
||||
|
||||
func (f FieldInt) BuildField (obuilder blds.ObjectBuilder) {
|
||||
obuilder.Field(f.name).Int(f.Native()) }
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,69 +0,0 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// 🚀 Project active3
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name field_reflect.go
|
||||
// ✍️ Created by DEV
|
||||
// 📅 Modified 01/05/2024
|
||||
//
|
||||
// 🔒 COPYRIGHT Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package flds
|
||||
|
||||
import (
|
||||
"blds"
|
||||
"fmt"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
FieldReflect struct {
|
||||
|
||||
partialField[reflect.Value]
|
||||
}
|
||||
)
|
||||
|
||||
func NewFieldReflect (name string, value reflect.Value) *FieldReflect {
|
||||
return &FieldReflect{ partialField : makePartialFieldLocal[reflect.Value](name,value) } }
|
||||
|
||||
func NewDFieldReflect (name string, valueFn func()reflect.Value) *FieldReflect {
|
||||
return &FieldReflect{ partialField : makePartialFieldDefer[reflect.Value](name,valueFn) } }
|
||||
|
||||
func NewDOFieldReflect (name string, valueFn func()reflect.Value) *FieldReflect {
|
||||
return &FieldReflect{ partialField : makePartialFieldOnce[reflect.Value](name,valueFn) } }
|
||||
|
||||
|
||||
func (f FieldReflect) Kind () Kind {
|
||||
return KindReflect | f.valuerKind() }
|
||||
|
||||
|
||||
func (f FieldReflect) AsReflect() (reflect.Value,bool) {
|
||||
return f.Native(),true }
|
||||
|
||||
func (f FieldReflect) AppendAsString (dest []byte) []byte {
|
||||
return append (dest,fmt.Sprintf("%#v",f.Native())...) }
|
||||
|
||||
|
||||
func (f FieldReflect) Build (builder blds.Builder) {
|
||||
builder.Object(func(b blds.ObjectBuilder){ f.BuildField(b) }) }
|
||||
|
||||
func (f FieldReflect) BuildField (obuilder blds.ObjectBuilder) {
|
||||
obuilder.Field(f.name).Reflect(f.Native()) }
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,63 +0,0 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// 🚀 Project active3
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name field_string.go
|
||||
// ✍️ Created by DEV
|
||||
// 📅 Modified 01/05/2024
|
||||
//
|
||||
// 🔒 COPYRIGHT Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package flds
|
||||
|
||||
import (
|
||||
"blds"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
FieldString struct {
|
||||
|
||||
partialField[string]
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
func NewFieldString (name string, value string) *FieldString {
|
||||
return &FieldString{ partialField : makePartialFieldLocal[string](name,value) } }
|
||||
|
||||
func NewDFieldString (name string, valueFn func() string) *FieldString {
|
||||
return &FieldString{ partialField : makePartialFieldDefer[string](name,valueFn) } }
|
||||
|
||||
func NewDOFieldString (name string, valueFn func() string) *FieldString {
|
||||
return &FieldString{ partialField : makePartialFieldOnce[string](name,valueFn) } }
|
||||
|
||||
|
||||
func (f FieldString) Kind () Kind {
|
||||
return KindString | f.valuerKind() }
|
||||
|
||||
func (f FieldString) AsString() (string,bool) {
|
||||
return f.Native(),true }
|
||||
|
||||
func (f FieldString) AppendAsString (dest []byte) []byte {
|
||||
return append (dest,[]byte(f.Native())...)}
|
||||
|
||||
|
||||
func (f FieldString) Build (builder blds.Builder) {
|
||||
builder.Object(func(b blds.ObjectBuilder){ f.BuildField(b) }) }
|
||||
|
||||
func (f FieldString) BuildField (obuilder blds.ObjectBuilder) {
|
||||
obuilder.Field(f.name).String(f.Native()) }
|
||||
@ -1,65 +0,0 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// 🚀 Project active3
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name field_time.go
|
||||
// ✍️ Created by DEV
|
||||
// 📅 Modified 01/05/2024
|
||||
//
|
||||
// 🔒 COPYRIGHT Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package flds
|
||||
|
||||
import (
|
||||
"blds"
|
||||
"time"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
FieldTime struct {
|
||||
|
||||
partialField[time.Time]
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
func NewFieldTime (name string, value time.Time) *FieldTime {
|
||||
return &FieldTime{ partialField : makePartialFieldLocal[time.Time](name,value) } }
|
||||
|
||||
func NewDFieldTime (name string, valueFn func() time.Time) *FieldTime {
|
||||
return &FieldTime{ partialField : makePartialFieldDefer[time.Time](name,valueFn) } }
|
||||
|
||||
func NewDOFieldTime (name string, valueFn func() time.Time) *FieldTime {
|
||||
return &FieldTime{ partialField : makePartialFieldOnce[time.Time](name,valueFn) } }
|
||||
|
||||
|
||||
func (f FieldTime) Kind () Kind {
|
||||
return KindTime | f.valuerKind() }
|
||||
|
||||
|
||||
func (f FieldTime) AsTime() (time.Time,bool) {
|
||||
return f.Native(),true }
|
||||
|
||||
func (f FieldTime) AppendAsString (dest []byte) []byte {
|
||||
return append (dest,[]byte(f.Native().String())...)}
|
||||
|
||||
|
||||
func (f FieldTime) Build (builder blds.Builder) {
|
||||
builder.Object(func(b blds.ObjectBuilder){ f.BuildField(b) }) }
|
||||
|
||||
func (f FieldTime) BuildField (obuilder blds.ObjectBuilder) {
|
||||
obuilder.Field(f.name).Time(f.Native()) }
|
||||
@ -1,69 +0,0 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// 🚀 Project active3
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name field_unuint.go
|
||||
// ✍️ Created by DEV
|
||||
// 📅 Modified 01/05/2024
|
||||
//
|
||||
// 🔒 COPYRIGHT Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package flds
|
||||
|
||||
import (
|
||||
"blds"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
FieldUint struct {
|
||||
|
||||
partialField[uint]
|
||||
}
|
||||
)
|
||||
|
||||
func NewFieldUint (name string, value uint) *FieldUint {
|
||||
return &FieldUint{ partialField : makePartialFieldLocal[uint](name,value) }}
|
||||
|
||||
func NewDFieldUint (name string, valueFn func() uint) *FieldUint {
|
||||
return &FieldUint{ partialField : makePartialFieldDefer[uint](name,valueFn) }}
|
||||
|
||||
func NewDOFieldUint (name string, valueFn func() uint) *FieldUint {
|
||||
return &FieldUint{ partialField : makePartialFieldOnce[uint](name,valueFn) }}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func (f FieldUint) Kind () Kind {
|
||||
return KindUint | f.valuerKind() }
|
||||
|
||||
|
||||
func (f FieldUint) AsUint() (uint,bool) {
|
||||
return f.Native(),true }
|
||||
|
||||
|
||||
func (f FieldUint) AppendAsString (dest []byte) []byte {
|
||||
return strconv.AppendUint (dest,uint64(f.Native()),10) }
|
||||
|
||||
|
||||
func (f FieldUint) Build (builder blds.Builder) {
|
||||
builder.Object(func(b blds.ObjectBuilder){
|
||||
b.Field(f.name).Uint(f.Native()) }) }
|
||||
|
||||
func (f FieldUint) BuildField (obuilder blds.ObjectBuilder) {
|
||||
obuilder.Field(f.name).Uint(f.Native()) }
|
||||
@ -1,80 +0,0 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// 🚀 Project active3
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name partial_field.go
|
||||
// ✍️ Created by DEV
|
||||
// 📅 Modified 01/05/2024
|
||||
//
|
||||
// 🔒 COPYRIGHT Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package flds
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"time"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
|
||||
// partialField representa un Field parcialmente definido con solo el nombre.
|
||||
// Implementa el interface typeResolver de forma nula para proporcionar valores
|
||||
// predeterminados para los tipos de datos comunes. Cuando un objeto Field
|
||||
// sobrescribe alguno de estos métodos, se produce shadowing, lo que significa
|
||||
// que la implementación en Field prevalecerá sobre la implementación nula de
|
||||
// partialField.
|
||||
partialField[T any] struct {
|
||||
valuer[T]
|
||||
name string
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
|
||||
func makePartialFieldLocal[T any] (name string, value T) partialField[T]{
|
||||
return partialField[T]{
|
||||
name : name,
|
||||
valuer: makeValueValuer[T](value) }}
|
||||
|
||||
func makePartialFieldDefer[T any] (name string, valueFn func() T) partialField[T] {
|
||||
return partialField[T]{
|
||||
name : name,
|
||||
valuer: makeDeferValuer[T](valueFn) }}
|
||||
|
||||
func makePartialFieldOnce [T any] (name string, valueFn func() T) partialField[T] {
|
||||
return partialField[T]{
|
||||
name : name,
|
||||
valuer: newOnceValuer[T](valueFn) }}
|
||||
|
||||
|
||||
func (f partialField[T]) Name() string {
|
||||
return f.name }
|
||||
|
||||
|
||||
func (f partialField[T]) AsBool() (bool, bool) { return false, false }
|
||||
func (f partialField[T]) AsString() (string, bool) { return "", false }
|
||||
func (_ partialField[T]) AsBinary() ([]byte, bool) { return nil, false }
|
||||
func (_ partialField[T]) AsInt() (int, bool) { return 0, false }
|
||||
func (_ partialField[T]) AsUint() (uint, bool) { return 0, false }
|
||||
func (_ partialField[T]) AsFloat() (float64, bool) { return 0, false }
|
||||
func (_ partialField[T]) AsTime() (time.Time, bool){ return g.timeZero, false }
|
||||
func (_ partialField[T]) AsDuration() (time.Duration, bool){ return 0, false }
|
||||
func (_ partialField[T]) AsError() (error, bool) { return nil, false }
|
||||
func (_ partialField[T]) AsReflect() (reflect.Value, bool) { return g.reflectZero, false }
|
||||
|
||||
|
||||
|
||||
@ -1,36 +0,0 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// 🚀 Project active3
|
||||
// 🔗 Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name string_appender.go
|
||||
// ✍️ Created by DEV
|
||||
// 📅 Modified 06/05/2024
|
||||
//
|
||||
// 🔒 Copyright 2024 activething.com
|
||||
//
|
||||
// 📜 LICENSE --------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package flds
|
||||
|
||||
|
||||
type (
|
||||
|
||||
StringAppender interface {
|
||||
|
||||
AppendAsString (dest []byte) []byte
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@ -1,81 +0,0 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// 🚀 Project active3
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name value_resolver.go
|
||||
// ✍️ Created by DEV
|
||||
// 📅 Modified 01/05/2024
|
||||
//
|
||||
// 🔒 COPYRIGHT Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package flds
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"time"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
// typeResolver es una interfaz que define métodos para resolver
|
||||
// y obtener valores nativos de diferentes tipos, junto con un indicador
|
||||
// de éxito para indicar si la resolución fue exitosa o no.
|
||||
typeResolver interface {
|
||||
|
||||
|
||||
|
||||
|
||||
// AsBool intenta resolver y devolver el valor como un booleano.
|
||||
// Retorna el valor booleano y un indicador de éxito.
|
||||
AsBool() (bool, bool)
|
||||
|
||||
// AsBinary intenta resolver y devolver el valor como un slice de bytes.
|
||||
// Retorna el slice de bytes y un indicador de éxito.
|
||||
AsBinary() ([]byte, bool)
|
||||
|
||||
// AsString intenta resolver y devolver el valor como una cadena de texto.
|
||||
// Retorna la cadena de texto y un indicador de éxito.
|
||||
AsString() (string, bool)
|
||||
|
||||
// AsInt intenta resolver y devolver el valor como un entero.
|
||||
// Retorna el entero y un indicador de éxito.
|
||||
AsInt() (int, bool)
|
||||
|
||||
// AsUint intenta resolver y devolver el valor como un entero sin signo.
|
||||
// Retorna el entero sin signo y un indicador de éxito.
|
||||
AsUint() (uint, bool)
|
||||
|
||||
// AsFloat intenta resolver y devolver el valor como un número flotante de punto flotante de 64 bits.
|
||||
// Retorna el número flotante y un indicador de éxito.
|
||||
AsFloat() (float64, bool)
|
||||
|
||||
// AsTime intenta resolver y devolver el valor como una marca de tiempo.
|
||||
// Retorna la marca de tiempo y un indicador de éxito.
|
||||
AsTime() (time.Time, bool)
|
||||
|
||||
// AsDuration intenta resolver y devolver el valor como una duración de tiempo
|
||||
// Retorna la duración y un indicador de éxito.
|
||||
AsDuration() (time.Duration, bool)
|
||||
|
||||
// AsError intenta resolver y devolver el valor como un error.
|
||||
// Retorna el error y un indicador de éxito.
|
||||
AsError() (error, bool)
|
||||
|
||||
// AsReflect intenta resolver y devolver el valor como un reflect.Value.
|
||||
// Retorna el reflect.Value y un indicador de éxito.
|
||||
AsReflect() (reflect.Value, bool)
|
||||
}
|
||||
)
|
||||
Loading…
Reference in new issue