Simple roundtrip from ipptool works.

This commit is contained in:
2020-11-01 20:05:53 +01:00
parent 83f35d045c
commit cadcedf43c
16 changed files with 744 additions and 152 deletions

View 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
}