Simple roundtrip from ipptool works.
This commit is contained in:
47
packages/ipp/charsetvalue.go
Normal file
47
packages/ipp/charsetvalue.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package ipp
|
||||
|
||||
import (
|
||||
"io"
|
||||
)
|
||||
|
||||
type charSetValue struct {
|
||||
name string
|
||||
value string
|
||||
}
|
||||
|
||||
func NewCharSetValue(name string, value string) *charSetValue {
|
||||
c := new(charSetValue)
|
||||
c.name = name
|
||||
c.value = value
|
||||
return c
|
||||
}
|
||||
|
||||
func (c charSetValue) String() string {
|
||||
return c.name + ":" + c.value
|
||||
}
|
||||
func (c *charSetValue) valueTag() tag {
|
||||
return charsetValueTag
|
||||
}
|
||||
|
||||
func (c *charSetValue) unmarshal(byteStream io.Reader) {
|
||||
c.name, c.value = unmarshalSingleValue(byteStream)
|
||||
}
|
||||
|
||||
func (c *charSetValue) marshal() []byte {
|
||||
l := 5 + len(c.name) + len(c.value)
|
||||
b := make([]byte, l, l)
|
||||
b[0] = byte(charsetValueTag)
|
||||
marshalNameValue(c.name, c.value, b[1:])
|
||||
return b
|
||||
}
|
||||
|
||||
func (c *charSetValue) marshalInto([]byte) int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (c *charSetValue) size() int {
|
||||
l := 1 + 4 // The attribute tag + 2 lengths
|
||||
l += len(c.name)
|
||||
l += len(c.value)
|
||||
return l
|
||||
}
|
||||
Reference in New Issue
Block a user