You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
3.6 KiB
81 lines
3.6 KiB
// ------------------------------------------------------------------------
|
|
// 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 pjson
|
|
|
|
import (
|
|
"packs"
|
|
"time"
|
|
)
|
|
|
|
func (p *JSONPacker) ItemAny (value any, flags proteus.Flags) { p.addItem(func(){ p.PackAny(value,flags) }) }
|
|
|
|
|
|
func (p *JSONPacker) ItemRaw (value []byte, flags proteus.Flags) { p.addItem(func() { p.PackRaw(value,flags) }) }
|
|
|
|
func (p *JSONPacker) ItemBinary (value []byte, flags proteus.Flags) { p.addItem(func (){ p.PackBinary(value,flags) }) }
|
|
|
|
func (p *JSONPacker) ItemString (value string, flags proteus.Flags) { p.addItem(func (){ p.PackString(value,flags) }) }
|
|
|
|
|
|
func (p *JSONPacker) ItemBool (value bool, flags proteus.Flags) { p.addItem(func (){ p.PackBool(value,flags) }) }
|
|
|
|
func (p *JSONPacker) ItemInt8 (value int8 , flags proteus.Flags) { p.addItem(func (){ packInt(p.state,int64(value),flags) }) }
|
|
func (p *JSONPacker) ItemInt16 (value int16, flags proteus.Flags) { p.addItem(func (){ packInt(p.state,int64(value),flags) }) }
|
|
func (p *JSONPacker) ItemInt32 (value int32, flags proteus.Flags) { p.addItem(func (){ packInt(p.state,int64(value),flags) }) }
|
|
func (p *JSONPacker) ItemInt64 (value int64, flags proteus.Flags) { p.addItem(func (){ packInt(p.state,value,flags) }) }
|
|
|
|
func (p *JSONPacker) ItemUInt8 (value uint8 , flags proteus.Flags){ p.addItem(func (){ packUInt(p.state,uint64(value),flags) }) }
|
|
func (p *JSONPacker) ItemUInt16 (value uint16, flags proteus.Flags){ p.addItem(func (){ packUInt(p.state,uint64(value),flags) }) }
|
|
func (p *JSONPacker) ItemUInt32 (value uint32, flags proteus.Flags){ p.addItem(func (){ packUInt(p.state,uint64(value),flags) }) }
|
|
func (p *JSONPacker) ItemUInt64 (value uint64, flags proteus.Flags){ p.addItem(func (){ packUInt(p.state,uint64(value),flags) }) }
|
|
|
|
func (p *JSONPacker) ItemFloat32 (value float32, flags proteus.Flags){ p.addItem(func (){ packFloatString(p.state,float64(value),flags,32)})}
|
|
func (p *JSONPacker) ItemFloat64 (value float64, flags proteus.Flags){ p.addItem(func (){ packFloatString(p.state,value,flags,64) })}
|
|
|
|
func (p *JSONPacker) ItemDate (value time.Time, flags proteus.Flags) { p.addItem(func(){ packDate(p.state,value,flags); p.state.Inc() })}
|
|
|
|
|
|
func (p *JSONPacker) ItemList (builder func(proteus.ListPackBuilder, proteus.Flags), flags proteus.Flags) {
|
|
p.addItem(func(){ p.PackList(builder,flags) }) }
|
|
|
|
func (p *JSONPacker) ItemMap (builder func(proteus.MapPackBuilder, proteus.Flags), flags proteus.Flags) {
|
|
p.addItem(func(){ p.PackMap(builder,flags) }) }
|
|
|
|
func (p *JSONPacker) ItemObject(builder func(proteus.ObjectPackBuilder, proteus.Flags), flags proteus.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()
|
|
}
|
|
}
|
|
|
|
|