MCPcopy Create free account
hub / github.com/OpenPrinting/goipp / encodeCollection

Method encodeCollection

encoder.go:205–225  ·  view source on GitHub ↗

Encode collection

(tag Tag, collection Collection)

Source from the content-addressed store, hash-verified

203
204// Encode collection
205func (me *messageEncoder) encodeCollection(tag Tag, collection Collection) error {
206 for _, attr := range collection {
207 if attr.Name == "" {
208 return errors.New("Collection member without name")
209 }
210
211 attrName := MakeAttribute("", TagMemberName, String(attr.Name))
212
213 err := me.encodeAttr(attrName, false)
214 if err == nil {
215 err = me.encodeAttr(
216 Attribute{Name: "", Values: attr.Values}, true)
217 }
218
219 if err != nil {
220 return err
221 }
222 }
223
224 return me.encodeAttr(MakeAttribute("", TagEndCollection, Void{}), false)
225}
226
227// Write a piece of raw data to output stream
228func (me *messageEncoder) write(data []byte) error {

Callers 1

encodeValueMethod · 0.95

Calls 3

encodeAttrMethod · 0.95
MakeAttributeFunction · 0.85
StringTypeAlias · 0.85

Tested by

no test coverage detected