48 lines
1.0 KiB
Go
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
|
|
}
|