47 lines
769 B
Go
47 lines
769 B
Go
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) Name() string {
|
|
return u.name
|
|
}
|
|
|
|
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
|
|
}
|