2-add-keyword-support (#6)
More development. More types. Fixed attribute groups in requests. Started on client. Saving data to file. More types. Printing from chromeos works a little bit. More types. Spelling corrections. WIP: Fix keyword handling Move request to a separate file and add test. Co-authored-by: Henrik Sölver <henrik.solver@gmail.com> Reviewed-on: #6 Co-Authored-By: henrik <henrik.solver@gmail.com> Co-Committed-By: henrik <henrik.solver@gmail.com>
This commit was merged in pull request #6.
This commit is contained in:
43
packages/ipp/naturallanguage.go
Normal file
43
packages/ipp/naturallanguage.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package ipp
|
||||
|
||||
import (
|
||||
"io"
|
||||
)
|
||||
|
||||
type naturalLanguage struct {
|
||||
name string
|
||||
value string
|
||||
}
|
||||
|
||||
func NewNaturalLanguage(name, value string) *naturalLanguage {
|
||||
c := new(naturalLanguage)
|
||||
c.name = name
|
||||
c.value = value
|
||||
return c
|
||||
}
|
||||
|
||||
func (c naturalLanguage) String() string {
|
||||
return c.name + ":" + c.value
|
||||
}
|
||||
func (c *naturalLanguage) valueTag() tag {
|
||||
return naturalLanguageValueTag
|
||||
}
|
||||
|
||||
func (c *naturalLanguage) unmarshal(byteStream io.Reader) {
|
||||
c.name, c.value = unmarshalSingleValue(byteStream)
|
||||
}
|
||||
|
||||
func (c *naturalLanguage) marshal() []byte {
|
||||
l := 5 + len(c.name) + len(c.value)
|
||||
b := make([]byte, l, l)
|
||||
b[0] = byte(naturalLanguageValueTag)
|
||||
marshalNameValue(c.name, c.value, b[1:])
|
||||
return b
|
||||
}
|
||||
|
||||
func (c *naturalLanguage) 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