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:
@@ -1,45 +1,33 @@
|
||||
package ipp
|
||||
|
||||
import "io"
|
||||
|
||||
type keyWord struct {
|
||||
name string
|
||||
values []string
|
||||
sos *setOfStrings
|
||||
}
|
||||
|
||||
func newKeyWord() *keyWord {
|
||||
func NewKeyWord(name string, values ...string) *keyWord {
|
||||
|
||||
k := new(keyWord)
|
||||
k.sos = NewSetOfStrings(name, keyWordValueTag, values)
|
||||
return k
|
||||
}
|
||||
|
||||
func (k *keyWord) string() string {
|
||||
return "a uriValue"
|
||||
}
|
||||
func (k *keyWord) valueTag() tag {
|
||||
return keyWordValueTag
|
||||
}
|
||||
|
||||
func (k *keyWord) unmarshal(byteStream io.Reader) {
|
||||
|
||||
}
|
||||
|
||||
func (k *keyWord) marshal() []byte {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
func (k *keyWord) addValue(v string) {
|
||||
k.values = append(k.values, v)
|
||||
func (k keyWord) String() string {
|
||||
return k.sos.String()
|
||||
}
|
||||
|
||||
func (k *keyWord) size() int {
|
||||
l := 1 + 2 // The value tag (0x44) + name-length field (2 bytes)
|
||||
l += len(k.name)
|
||||
l += 2 // value-length field (2 bytes)
|
||||
l += len(k.values[0])
|
||||
// Add all additional values
|
||||
for _, v := range k.values[1:] {
|
||||
l += 1 + 4 // The value tag (0x44) + 2 length fields (2 bytes)
|
||||
l += len(v)
|
||||
}
|
||||
return l
|
||||
return k.sos.size()
|
||||
}
|
||||
|
||||
func (k *keyWord) valueTag() tag {
|
||||
return k.sos.valueTag()
|
||||
}
|
||||
|
||||
func (k *keyWord) marshal() []byte {
|
||||
return k.sos.marshal()
|
||||
}
|
||||
|
||||
func (k *keyWord) addValue(v string) {
|
||||
k.sos.AddValue(v)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user