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