// headerToMap converts a textproto.Header to a map. It looses information.
559213
func headerToMap(h textproto.Header) stdtextproto.MIMEHeader {
	m := make(stdtextproto.MIMEHeader)
	fields := h.Fields()
	for fields.Next() {
		m.Add(fields.Key(), fields.Value())
	}
	return m
}
1369599
func (f ipAddressFunc) toMap() map[Key]ValueSet {
	if !f.k.IsValid() {
		return nil
	}

	values := NewValueSet()
	for _, value := range f.values {
		values.Add(NewStringValue(value.String()))
	}

	return map[Key]ValueSet{
		f.k: values,
	}
}
42821
func tagsToMapIAM(ts []*iam.Tag) map[string]string {
	result := make(map[string]string)
	for _, t := range ts {
		if !tagIgnoredIAM(t) {
			result[aws.StringValue(t.Key)] = aws.StringValue(t.Value)
		}
	}

	return result
}
903523
func (r *vstResponse) Header(key string) string {
	r.metaMutex.Lock()
	defer r.metaMutex.Unlock()

	if r.meta != nil {
		if r.metaMap == nil {
			// Read all headers
			metaMap := make(map[string]string)
			keyCount, err := r.meta.Length()
			if err != nil {
				return ""
			}
			for k := velocypack.ValueLength(0); k < keyCount; k++ {
				key, err := r.meta.KeyAt(k)
				if err != nil {
					continue
				}
				value, err := r.meta.ValueAt(k)
				if err != nil {
					continue
				}
				keyStr, err := key.GetString()
				if err != nil {
					continue
				}
				valueStr, err := value.GetString()
				if err != nil {
					continue
				}
				metaMap[strings.ToLower(keyStr)] = valueStr
			}
			r.metaMap = metaMap
		}
		key = strings.ToLower(key)
		if value, found := r.metaMap[key]; found {
			return value
		}
	}
	return ""
}
1058295
func parseMap(m Map) (map[int]interface{}, map[string]string) {
	var options = make(map[int]interface{})
	var headers = make(map[string]string)

	if m == nil {
		return options, headers
	}

	for k, v := range m {
		// integer is option
		if kInt, ok := k.(int); ok {
			// don't need to validate
			options[kInt] = v
		} else if kString, ok := k.(string); ok {
			kStringUpper := strings.ToUpper(kString)
			if kInt, ok := CONST[kStringUpper]; ok {
				options[kInt] = v
			} else {
				// it should be header, but we still need to validate it's type
				if vString, ok := v.(string); ok {
					headers[kString] = vString
				}
			}
		}
	}

	return options, headers
}
1165785
func toMap(object interface{}) (map[string]interface{}, error) {
	if m, ok := object.(map[string]interface{}); ok {
		return m, nil
	}
	data, err := json.Marshal(object)
	if err != nil {
		return nil, driver.WithStack(err)
	}
	var m map[string]interface{}
	if err := json.Unmarshal(data, &m); err != nil {
		return nil, driver.WithStack(err)
	}
	return m, nil
}
155858
func SMapToIMap(data map[string]string, typs map[string]string) map[string]interface{} {
	r := make(map[string]interface{})
	for k, v := range data {
		typ, _ := typs[k]
		r[k] = ParseString(v, typ)
	}
	return r
}
528918
func toMap(aaps []AliasAccPair) map[string]map[string]AliasAccPair {
	resMap := make(map[string]map[string]AliasAccPair)
	for _, aap := range aaps {
		m, ok := resMap[aap.InAlias]
		if !ok {
			m = make(map[string]AliasAccPair)
			resMap[aap.InAlias] = m
		}
		m[aap.OutAlias] = aap
	}
	return resMap
}
418045
func (b *HttpRequest) Header(key, value string) *HttpRequest {
	b.req.Header.Set(key, value)
	return b
}
1100567
func resultToMap(qr *sqltypes.Result) (map[string]string, error) {
	if len(qr.Rows) == 0 {
		// The query succeeded, but there is no data.
		return nil, nil
	}
	if len(qr.Rows) > 1 {
		return nil, vterrors.Errorf(vtrpc.Code_INTERNAL, "query returned %d rows, expected 1", len(qr.Rows))
	}
	if len(qr.Fields) != len(qr.Rows[0]) {
		return nil, vterrors.Errorf(vtrpc.Code_INTERNAL, "query returned %d column names, expected %d", len(qr.Fields), len(qr.Rows[0]))
	}

	result := make(map[string]string, len(qr.Fields))
	for i, field := range qr.Fields {
		result[field.Name] = qr.Rows[0][i].ToString()
	}
	return result, nil
}
59067
func XMLToMap(r io.Reader) (map[string]string, error) {
	m := make(map[string]string)
	dec := xml.NewDecoder(r)
	var tagName string
	for {
		t, err := dec.Token()
		if err != nil {
			if err == io.EOF {
				break
			}
			return nil, err
		}

		switch v := t.(type) {
		case xml.StartElement:
			tagName = string(v.Name.Local)
		case xml.CharData:
			m[tagName] = string(v)
		}
	}
	return m, nil
}
490699
func (r *RequestConfig) Header(name, value string) *RequestConfig {
	r.HeaderMap.Add(name, value)
	return r
}
352710
func HeaderHandler(headers ...string) func(*http.Request) map[string]interface{} {
	return func(req *http.Request) map[string]interface{} {
		result := map[string]interface{}{}
		for _, header := range headers {
			if val := req.Header.Get(header); val != "" {
				result[header] = val
			}
		}
		return result
	}
}
210458
func (section *Section) ToMap() map[string]interface{} {
	output := make(map[string]interface{})

	for key, value := range section.values {
		if value.GetType() == SECTION {
			output[key] = value.(*Section).ToMap()
		} else {
			output[key] = value.GetValue()
		}
	}
	return output
}
1188134
func parseMetadata(md swift.Headers) (map[string]interface{}, error) {
	m := make(map[string]interface{}, len(md))
	for key, value := range md.ObjectMetadata() {
		m[key] = value
	}
	return m, nil
}
33184
func (o *querySet) RowsToMap(result *Params, keyCol, valueCol string) (int64, error) {
	panic(ErrNotImplement)
}
307386
func optArgsToMap(optArgs OptArgs) map[string]interface{} {
	data, err := encode(optArgs)

	if err == nil && data != nil {
		if m, ok := data.(map[string]interface{}); ok {
			return m
		}
	}

	return map[string]interface{}{}
}