// ------------------------------------------------------------------------ // Project atila // Active Thing (activething.com) git.activething.com/go // // File name builder_list.go // Created by DEV // Modified 06/02/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 pkjson import ( "apacks" "time" ) func (p *JSONPacker) ItemAny (value any, flags apacks.Flags) { p.addItem(func(){ p.PackAny(value,flags) }) } func (p *JSONPacker) ItemRaw (value []byte, flags apacks.Flags) { p.addItem(func() { p.PackRaw(value,flags) }) } func (p *JSONPacker) ItemBinary (value []byte, flags apacks.Flags) { p.addItem(func (){ p.PackBinary(value,flags) }) } func (p *JSONPacker) ItemString (value string, flags apacks.Flags) { p.addItem(func (){ p.PackString(value,flags) }) } func (p *JSONPacker) ItemBool (value bool, flags apacks.Flags) { p.addItem(func (){ p.PackBool(value,flags) }) } func (p *JSONPacker) ItemInt8 (value int8 , flags apacks.Flags) { p.addItem(func (){ packInt(p.state,int64(value),flags) }) } func (p *JSONPacker) ItemInt16 (value int16, flags apacks.Flags) { p.addItem(func (){ packInt(p.state,int64(value),flags) }) } func (p *JSONPacker) ItemInt32 (value int32, flags apacks.Flags) { p.addItem(func (){ packInt(p.state,int64(value),flags) }) } func (p *JSONPacker) ItemInt64 (value int64, flags apacks.Flags) { p.addItem(func (){ packInt(p.state,value,flags) }) } func (p *JSONPacker) ItemUInt8 (value uint8 , flags apacks.Flags){ p.addItem(func (){ packUInt(p.state,uint64(value),flags) }) } func (p *JSONPacker) ItemUInt16 (value uint16, flags apacks.Flags){ p.addItem(func (){ packUInt(p.state,uint64(value),flags) }) } func (p *JSONPacker) ItemUInt32 (value uint32, flags apacks.Flags){ p.addItem(func (){ packUInt(p.state,uint64(value),flags) }) } func (p *JSONPacker) ItemUInt64 (value uint64, flags apacks.Flags){ p.addItem(func (){ packUInt(p.state,uint64(value),flags) }) } func (p *JSONPacker) ItemFloat32 (value float32, flags apacks.Flags){ p.addItem(func (){ packFloatString(p.state,float64(value),flags,32)})} func (p *JSONPacker) ItemFloat64 (value float64, flags apacks.Flags){ p.addItem(func (){ packFloatString(p.state,value,flags,64) })} func (p *JSONPacker) ItemDate (value time.Time, flags apacks.Flags) { p.addItem(func(){ packDate(p.state,value,flags); p.state.Inc() })} func (p *JSONPacker) ItemList (builder func(apacks.ListPackBuilder, apacks.Flags), flags apacks.Flags) { p.addItem(func(){ p.PackList(builder,flags) }) } func (p *JSONPacker) ItemMap (builder func(apacks.MapPackBuilder, apacks.Flags), flags apacks.Flags) { p.addItem(func(){ p.PackMap(builder,flags) }) } func (p *JSONPacker) ItemObject(builder func(apacks.ObjectPackBuilder, apacks.Flags), flags apacks.Flags) { p.addItem(func(){ p.PackObject(builder,flags) }) } func (p *JSONPacker) addItem (caller func()) { if p.state.Count() > 0 { p.state.WriteByte(',') } caller() if p.state != nil { p.state.Inc() } }