Encode collection
(tag Tag, collection Collection)
| 203 | |
| 204 | // Encode collection |
| 205 | func (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 |
| 228 | func (me *messageEncoder) write(data []byte) error { |
no test coverage detected