q5/mutable_xobject.go
aozhiwei f62a41fba7 1
2020-10-23 17:51:35 +08:00

48 lines
1.0 KiB
Go

package q5
type MutableXObject struct {
XObject
}
func NewMxoArray() *MutableXObject {
p := new(MutableXObject)
return p
}
func NewMxoObject() *MutableXObject {
p := new(MutableXObject)
return p
}
func (this *MutableXObject) PushXValue(val *XValue) *MutableXObject{
this.PushXObject(val.AsXObject())
return this
}
func (this *MutableXObject) PushXObject(val *XObject) *MutableXObject{
if this.XObject.GetType() != XOT_ARRAY {
panic("MutableXObject.PushXvalue type error")
}
array := this.XObject._val.(*[]*XObject)
this.XObject._val = append(*array, val)
return this
}
func (this *MutableXObject) SetXValue(key string, val *XValue) *MutableXObject{
this.SetXObject(key, val.AsXObject())
return this
}
func (this *MutableXObject) SetXObject(key string, val *XObject) *MutableXObject{
if this.XObject.GetType() != XOT_OBJECT {
panic("MutableXObject.PushXvalue type error")
}
kvObj := this.XObject._val.(*(map[string]*XObject))
(*kvObj)[key] = val
return this
}
func (this *MutableXObject) AsXObject() *XObject{
return &this.XObject
}