// encodeAttr converts a key/value pair into an Attr internal representation.
760778
func encodeAttr(key string, value interface{}) *internal.Attr {
	pb := &internal.Attr{Key: key}
	switch value := value.(type) {
	case string:
		pb.Type = attrTypeString
		pb.StringValue = value
	case float64:
		pb.Type = attrTypeFloat
		pb.FloatValue = value
	case uint64:
		pb.Type = attrTypeInt
		pb.IntValue = int64(value)
	case int64:
		pb.Type = attrTypeInt
		pb.IntValue = value
	case bool:
		pb.Type = attrTypeBool
		pb.BoolValue = value
	}
	return pb
}
1079527
func (l *Logger) SetAttr(name string, val interface{}) {
	l.attrs[name] = val
}
658538
func (extension *DummyExtension) DecorateEncoder(typ reflect2.Type, encoder ValEncoder) ValEncoder {
	return encoder
}
77094
func NewEncoder(r io.Writer) Encoder {
	enc := gob.NewEncoder(r)
	return func(r *Result) error { return enc.Encode(r) }
}
949891
func NewEncoder(s encoding.Sink) encoding.Encoder {
	w := s()
	return encoding.EncoderFunc(func(m encoding.Marshaler) error {
		b, err := json.Marshal(m)
		if err != nil {
			return err
		}
		return w.WriteFrame(b)
	})
}
795749
func (e *Encoder) Encode(db *Database) error {
	// Calculate transformed key to make HMAC and encrypt
	transformedKey, err := db.getTransformedKey()
	if err != nil {
		return err
	}

	// Write header then hashes before decode content (necessary to update HeaderHash)
	// db.Header writeTo will change its hash
	if err = db.Header.writeTo(e.w); err != nil {
		return err
	}

	// Update header hash into db.Hashes then write the data
	hash := db.Header.GetSha256()
	if db.Header.IsKdbx4() {
		db.Hashes.Sha256 = hash

		hmacKey := buildHmacKey(db, transformedKey)
		hmacHash := db.Header.GetHmacSha256(hmacKey)
		db.Hashes.Hmac = hmacHash

		if err = db.Hashes.writeTo(e.w); err != nil {
			return err
		}
	} else {
		db.Content.Meta.HeaderHash = base64.StdEncoding.EncodeToString(hash[:])
	}

	// Encode xml and append header to the top
	rawContent, err := xml.MarshalIndent(db.Content, "", "\t")
	if err != nil {
		return err
	}
	rawContent = append(xmlHeader, rawContent...)

	// Write InnerHeader (Kdbx v4)
	if db.Header.IsKdbx4() {
		var ih bytes.Buffer
		if err = db.Content.InnerHeader.writeTo(&ih); err != nil {
			return err
		}

		rawContent = append(ih.Bytes(), rawContent...)
	}

	// Encode raw content
	encodedContent, err := encodeRawContent(db, rawContent, transformedKey)
	if err != nil {
		return err
	}

	// Writes the encrypted database content
	_, err = e.w.Write(encodedContent)
	return err
}
1319533
func (n *Node) SelectAttr(name string) string {
	if n.Type == AttributeNode {
		if n.Data == name {
			return n.InnerText()
		}
		return ""
	}
	var local, space string
	local = name
	if i := strings.Index(name, ":"); i > 0 {
		space = name[:i]
		local = name[i+1:]
	}
	for _, attr := range n.Attr {
		if attr.Name.Local == local && attr.Name.Space == space {
			return attr.Value
		}
	}
	return ""
}
70039
func GetAttrs(e Markup, f, val string) []*Attribute {

	var found []*Attribute

	for _, as := range e.Attributes() {
		if as.Name != f {
			continue
		}

		if val != "" {
			if !strings.Contains(as.Value, val) {
				continue
			}
		}

		found = append(found, as)
	}

	return found
}
64924
func NewEncoder(w io.Writer) *Encoder {
	bw, ok := w.(writer)
	if !ok {
		bw = newByteWriter(w)
	}
	return &Encoder{
		w:   bw,
		buf: make([]byte, 9),
	}
}
883376
func NewEncoder(w io.Writer) *Encoder {
	h := sha1.New()
	mw := io.MultiWriter(w, h)
	return &Encoder{mw, h}
}
1042054
func NewEncoder(w io.Writer, codec runtime.Codec) *Encoder {
	return &Encoder{
		w:       w,
		encoder: json.NewEncoder(w),
		codec:   codec,
	}
}
169314
func (u *User) Encode() string {
	values := url.Values{}

	// add custom attributes
	if u.Attrs != nil {
		for key, val := range u.Attrs {
			values.Set(key, val)
		}
	}

	values.Set("id", u.Id)
	values.Set("name", u.Name)
	values.Set("email", u.Email)
	values.Set("photo", u.Photo)
	return values.Encode()
}
556508
func (ae *AttributeEncoder) Uint8(typ uint16, v uint8) {
	if ae.err != nil {
		return
	}

	ae.attrs = append(ae.attrs, Attribute{
		Type: typ,
		Data: []byte{v},
	})
}
393873
func NewEncoder(w io.Writer) *Encoder {
	return &Encoder{w, make([]byte, minEncode)}
}
606145
func NewEncoder(w io.Writer) *Encoder {
	return &Encoder{
		enc: codec.NewEncoder(w, new(codec.CborHandle)),
	}
}
1174868
func NewEncoder(w io.Writer) *Encoder {
	return &Encoder{w, defaultDelimiter, defaultEscape, false}
}
808635
func selectionAttr(selection *goquery.Selection, attr string) string {
	var results []string
	selection.Each(func(i int, element *goquery.Selection) {
		res, ok := element.Attr(attr)
		if ok {
			results = append(results, res)
		}
	})
	return strings.Join(results, " ")
}