Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(425)

Delta Between Two Patch Sets: src/pkg/encoding/xml/read.go

Issue 12556043: code review 12556043: encoding/xml: add, support Unmarshaler interface (Closed)
Left Patch Set: diff -r b20db4bc66df https://code.google.com/p/go/ Created 10 years, 7 months ago
Right Patch Set: diff -r 117ed8ab3db0 https://code.google.com/p/go/ Created 10 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | src/pkg/encoding/xml/read_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package xml 5 package xml
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "errors" 9 "errors"
10 "fmt" 10 "fmt"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // beginning with the given start element. 145 // beginning with the given start element.
146 // If it returns an error, the outer call to Unmarshal stops and 146 // If it returns an error, the outer call to Unmarshal stops and
147 // returns that error. 147 // returns that error.
148 // UnmarshalXML must consume exactly one XML element. 148 // UnmarshalXML must consume exactly one XML element.
149 // One common implementation strategy is to unmarshal into 149 // One common implementation strategy is to unmarshal into
150 // a separate value with a layout matching the expected XML 150 // a separate value with a layout matching the expected XML
151 // using d.DecodeElement, and then to copy the data from 151 // using d.DecodeElement, and then to copy the data from
152 // that value into the receiver. 152 // that value into the receiver.
153 // Another common strategy is to use d.Token to process the 153 // Another common strategy is to use d.Token to process the
154 // XML object one token at a time. 154 // XML object one token at a time.
155 // UnmarshalXML may not use d.RawToken.
155 type Unmarshaler interface { 156 type Unmarshaler interface {
156 UnmarshalXML(d *Decoder, start StartElement) error 157 UnmarshalXML(d *Decoder, start StartElement) error
157 } 158 }
158 159
159 // Unmarshaler is the interface implemented by objects that can unmarshal 160 // UnmarshalerAttr is the interface implemented by objects that can unmarshal
Dominik Honnef 2013/08/09 16:21:45 UnmarshalerAttr
160 // an XML attribute description of themselves. 161 // an XML attribute description of themselves.
161 // 162 //
162 // UnmarshalXMLAttr decodes a single XML attribute. 163 // UnmarshalXMLAttr decodes a single XML attribute.
163 // If it returns an error, the outer call to Unmarshal stops and 164 // If it returns an error, the outer call to Unmarshal stops and
164 // returns that error. 165 // returns that error.
165 // UnmarshalXMLAttr is used only for struct fields with the 166 // UnmarshalXMLAttr is used only for struct fields with the
166 // "attr" option in the field tag. 167 // "attr" option in the field tag.
167 type UnmarshalerAttr interface { 168 type UnmarshalerAttr interface {
168 UnmarshalXMLAttr(attr Attr) error 169 UnmarshalXMLAttr(attr Attr) error
169 } 170 }
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 switch tok.(type) { 622 switch tok.(type) {
622 case StartElement: 623 case StartElement:
623 if err := d.Skip(); err != nil { 624 if err := d.Skip(); err != nil {
624 return err 625 return err
625 } 626 }
626 case EndElement: 627 case EndElement:
627 return nil 628 return nil
628 } 629 }
629 } 630 }
630 } 631 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b