當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Decoder.Text方法代碼示例

本文整理匯總了Golang中github.com/ermine/bullxmpp/xmlencoder.Decoder.Text方法的典型用法代碼示例。如果您正苦於以下問題:Golang Decoder.Text方法的具體用法?Golang Decoder.Text怎麽用?Golang Decoder.Text使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/ermine/bullxmpp/xmlencoder.Decoder的用法示例。


在下文中一共展示了Decoder.Text方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Decode

func (elm *Error) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "text":
				if err = elm.Text.Decode(d, &t); err != nil {
					return err
				}
			default:
				if t.Name.Space == NS {
					var s string
					if s, err = d.Text(); err != nil {
						return err
					}
					*elm.Condition.Extra = s
				}
			}
		}
	}
	return err
}
開發者ID:oxpa,項目名稱:bullxmpp,代碼行數:30,代碼來源:stream_data.go

示例2: Decode

func (elm *Mood) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "text":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Text = s
			default:
				if t.Name.Space == NS {
					*elm.Mood = MoodMood(t.Name.Local)
					if err = d.Skip(); err != nil {
						return err
					}
				}
			}
		}
	}
	return err
}
開發者ID:oxpa,項目名稱:bullxmpp,代碼行數:31,代碼來源:mood_data.go

示例3: Decode

func (elm *Invite) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
var err error
for _, x := range tag.Attr {
switch {
case x.Name.Space == "" && x.Name.Local == "from":
var j *jid.JID
if j, err = jid.New(x.Value); err != nil { return err }
elm.From = j
case x.Name.Space == "" && x.Name.Local == "to":
var j *jid.JID
if j, err = jid.New(x.Value); err != nil { return err }
elm.To = j
}
}
var t xml.Token
Loop:
for {
if t, err = d.Token(); err != nil { return err }
switch t := t.(type) {
case xml.EndElement:
break Loop
case xml.StartElement:
switch {
case t.Name.Space == NS && t.Name.Local == "reason":
var s string
if s, err = d.Text(); err != nil { return err }
*elm.Reason = s
}
}
}
return err
}
開發者ID:oxpa,項目名稱:bullxmpp,代碼行數:32,代碼來源:user_data.go

示例4: Decode

func (elm *Vcard) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "VERSION":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.VERSION = s
			case t.Name.Space == NS && t.Name.Local == "FN":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.FN = s
			}
		}
	}
	return err
}
開發者ID:oxpa,項目名稱:bullxmpp,代碼行數:30,代碼來源:vcard_data.go

示例5: Decode

func (elm *Option) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	for _, x := range tag.Attr {
		switch {
		case x.Name.Space == "" && x.Name.Local == "label":
			elm.Label = xmlencoder.Copystring(x.Value)
		}
	}
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "value":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Value = s
			}
		}
	}
	return err
}
開發者ID:oxpa,項目名稱:bullxmpp,代碼行數:30,代碼來源:xdata_data.go

示例6: Decode

func (elm *Bind) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "resource":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Resource = s
			case t.Name.Space == NS && t.Name.Local == "jid":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				var j *jid.JID
				if j, err = jid.New(s); err != nil {
					return err
				}
				elm.Jid = j
			}
		}
	}
	return err
}
開發者ID:oxpa,項目名稱:bullxmpp,代碼行數:34,代碼來源:bind_data.go

示例7: Decode

func (elm *Item) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	for _, x := range tag.Attr {
		switch {
		case x.Name.Space == "" && x.Name.Local == "affiliation":
			value := ItemAffiliation(x.Value)
			elm.Affiliation = &value
		case x.Name.Space == "" && x.Name.Local == "jid":
			var j *jid.JID
			if j, err = jid.New(x.Value); err != nil {
				return err
			}
			elm.Jid = j
		case x.Name.Space == "" && x.Name.Local == "nick":
			elm.Nick = xmlencoder.Copystring(x.Value)
		case x.Name.Space == "" && x.Name.Local == "role":
			value := ItemRole(x.Value)
			elm.Role = &value
		}
	}
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "actor":
				for _, x := range tag.Attr {
					switch {
					case x.Name.Space == "" && x.Name.Local == "jid":
						var j *jid.JID
						if j, err = jid.New(x.Value); err != nil {
							return err
						}
						elm.Actor.Jid = j
					}
				}
			case t.Name.Space == NS && t.Name.Local == "reason":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Reason = s
			}
		}
	}
	return err
}
開發者ID:oxpa,項目名稱:bullxmpp,代碼行數:53,代碼來源:admin_data.go

示例8: Decode

func (elm *Enter) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "history":
				for _, x := range tag.Attr {
					switch {
					case x.Name.Space == "" && x.Name.Local == "maxchars":
						var i int64
						i, err = strconv.ParseInt(x.Value, 10, 0)
						if err == nil {
							*elm.History.Maxchars = int(i)
						}
					case x.Name.Space == "" && x.Name.Local == "maxstanzas":
						var i int64
						i, err = strconv.ParseInt(x.Value, 10, 0)
						if err == nil {
							*elm.History.Maxstanzas = int(i)
						}
					case x.Name.Space == "" && x.Name.Local == "seconds":
						var i int64
						i, err = strconv.ParseInt(x.Value, 10, 0)
						if err == nil {
							*elm.History.Seconds = int(i)
						}
					case x.Name.Space == "" && x.Name.Local == "since":
						*elm.History.Since, err = time.Parse(time.RFC3339, x.Value)
						if err != nil {
							return err
						}
					}
				}
			case t.Name.Space == NS && t.Name.Local == "password":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Password = s
			}
		}
	}
	return err
}
開發者ID:oxpa,項目名稱:bullxmpp,代碼行數:52,代碼來源:muc_data.go

示例9: Decode

func (elm *Default) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	for _, x := range tag.Attr {
		switch {
		case x.Name.Space == "" && x.Name.Local == "name":
			elm.Name = xmlencoder.Copystring(x.Value)
		}
	}
	var s string
	if s, err = d.Text(); err != nil {
		return err
	}
	*elm.Extra = s
	return err
}
開發者ID:oxpa,項目名稱:bullxmpp,代碼行數:15,代碼來源:privacy_data.go

示例10: Decode

func (elm *Item) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	for _, x := range tag.Attr {
		switch {
		case x.Name.Space == "" && x.Name.Local == "approved":
			var b bool
			b, err = strconv.ParseBool(x.Value)
			if err == nil {
				elm.Approved = b
			}
		case x.Name.Space == "" && x.Name.Local == "ask":
			value := ItemAsk(x.Value)
			elm.Ask = &value
		case x.Name.Space == "" && x.Name.Local == "jid":
			var j *jid.JID
			if j, err = jid.New(x.Value); err != nil {
				return err
			}
			elm.Jid = j
		case x.Name.Space == "" && x.Name.Local == "name":
			elm.Name = xmlencoder.Copystring(x.Value)
		case x.Name.Space == "" && x.Name.Local == "subscription":
			value := ItemSubscription(x.Value)
			elm.Subscription = &value
		}
	}
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "group":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				elm.Group = append(elm.Group, s)
			}
		}
	}
	return err
}
開發者ID:oxpa,項目名稱:bullxmpp,代碼行數:48,代碼來源:roster_data.go

示例11: Decode

func (elm *Last) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	for _, x := range tag.Attr {
		switch {
		case x.Name.Space == "" && x.Name.Local == "seconds":
			var i uint64
			i, err = strconv.ParseUint(x.Value, 10, 0)
			if err == nil {
				*elm.Seconds = uint(i)
			}
		}
	}
	var s string
	if s, err = d.Text(); err != nil {
		return err
	}
	*elm.Extra = s
	return err
}
開發者ID:oxpa,項目名稱:bullxmpp,代碼行數:19,代碼來源:iqlast_data.go

示例12: Decode

func (elm *Version) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "name":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Name = s
			case t.Name.Space == NS && t.Name.Local == "version":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Version = s
			case t.Name.Space == NS && t.Name.Local == "os":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Os = s
			}
		}
	}
	return err
}
開發者ID:oxpa,項目名稱:bullxmpp,代碼行數:36,代碼來源:iqversion_data.go

示例13: Decode

func (elm *Time) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "utc":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Utc = s
			case t.Name.Space == NS && t.Name.Local == "tz":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Tz = s
			case t.Name.Space == NS && t.Name.Local == "display":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Display = s
			}
		}
	}
	return err
}
開發者ID:oxpa,項目名稱:bullxmpp,代碼行數:36,代碼來源:iqtime_data.go

示例14: Decode

func (elm *Query) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "registered":
				if err = d.Skip(); err != nil {
					return err
				}
			case t.Name.Space == NS && t.Name.Local == "instructions":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Fields.Instructions = s
			case t.Name.Space == NS && t.Name.Local == "username":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Fields.Username = s
			case t.Name.Space == NS && t.Name.Local == "nick":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Fields.Nick = s
			case t.Name.Space == NS && t.Name.Local == "password":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Fields.Password = s
			case t.Name.Space == NS && t.Name.Local == "name":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Fields.Name = s
			case t.Name.Space == NS && t.Name.Local == "first":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Fields.First = s
			case t.Name.Space == NS && t.Name.Local == "last":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Fields.Last = s
			case t.Name.Space == NS && t.Name.Local == "email":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Fields.Email = s
			case t.Name.Space == NS && t.Name.Local == "address":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Fields.Address = s
			case t.Name.Space == NS && t.Name.Local == "city":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Fields.City = s
			case t.Name.Space == NS && t.Name.Local == "state":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Fields.State = s
			case t.Name.Space == NS && t.Name.Local == "zip":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Fields.Zip = s
			case t.Name.Space == NS && t.Name.Local == "phone":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Fields.Phone = s
			case t.Name.Space == NS && t.Name.Local == "url":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
//.........這裏部分代碼省略.........
開發者ID:oxpa,項目名稱:bullxmpp,代碼行數:101,代碼來源:iqregister_data.go

示例15: Decode

func (elm *Message) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	for _, x := range tag.Attr {
		switch {
		case x.Name.Space == "" && x.Name.Local == "from":
			var j *jid.JID
			if j, err = jid.New(x.Value); err != nil {
				return err
			}
			elm.From = j
		case x.Name.Space == "" && x.Name.Local == "to":
			var j *jid.JID
			if j, err = jid.New(x.Value); err != nil {
				return err
			}
			elm.To = j
		case x.Name.Space == "" && x.Name.Local == "id":
			elm.Id = xmlencoder.Copystring(x.Value)
		case x.Name.Space == "" && x.Name.Local == "type":
			value := MessageType(x.Value)
			elm.Type = &value
		case x.Name.Space == "http://www.w3.org/XML/1998/namespace" && x.Name.Local == "lang":
			elm.Lang = &x.Value
		}
	}
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "thread":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Thread = s
			case t.Name.Space == NS && t.Name.Local == "subject":
				if err = elm.Subject.Decode(d, &t); err != nil {
					return err
				}
			case t.Name.Space == NS && t.Name.Local == "body":
				if err = elm.Body.Decode(d, &t); err != nil {
					return err
				}
			default:
				if newel, ok := xmlencoder.GetExtension(t.Name); ok {
					if err = newel.(xmlencoder.Extension).Decode(d, &t); err != nil {
						return err
					}
					elm.X = append(elm.X, newel)
				} else {
					if err = d.Skip(); err != nil {
						return err
					}
				}
			case t.Name.Space == "urn:ietf:params:xml:ns:xmpp-stanzas" && t.Name.Local == "error":
				newel := &stanza.Error{}
				if err = newel.Decode(d, &t); err != nil {
					return err
				}
				elm.Error = newel
			}
		}
	}
	return err
}
開發者ID:oxpa,項目名稱:bullxmpp,代碼行數:72,代碼來源:client_data.go


注:本文中的github.com/ermine/bullxmpp/xmlencoder.Decoder.Text方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。