// ------------------------------------------------------------------------ // 🚀 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 erdata import ( "blds" "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(G.ErrExpectedValue) } 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) Uintptr(value uintptr){ 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) }