// parseMapEntry deserializes a map entry from a XML node.
777795
func parseMapEntry(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
	kname, vname := "key", "value"
	if n := tag.Get("locationNameKey"); n != "" {
		kname = n
	}
	if n := tag.Get("locationNameValue"); n != "" {
		vname = n
	}

	keys, ok := node.Children[kname]
	values := node.Children[vname]
	if ok {
		for i, key := range keys {
			keyR := reflect.ValueOf(key.Text)
			value := values[i]
			valueR := reflect.New(r.Type().Elem()).Elem()

			parse(valueR, value, "")
			r.SetMapIndex(keyR, valueR)
		}
	}
	return nil
}
593666
func ReadMap(rd io.Reader) (m Map, err error) {
	// Just in case of programming mistake. Not intentionally used.
	defer func() {
		if r := recover(); r != nil {
			err = errors.New(fmt.Sprint(r))
		}
	}()

	return decodeMap(rd, "", true)
}
257001
func (poloniex *PoloniexExchange) parseOrderMap(book map[string]interface{}, orders poloniexOrders) error {
	for p, v := range book {
		price, err := strconv.ParseFloat(p, 64)
		if err != nil {
			return fmt.Errorf("Failed to parse float from poloniex orderbook price. given %s: %v", p, err)
		}
		vStr, ok := v.(string)
		if !ok {
			return fmt.Errorf("Failed to cast poloniex orderbook volume to string. given %s", v)
		}
		volume, err := strconv.ParseFloat(vStr, 64)
		if err != nil {
			return fmt.Errorf("Failed to parse float from poloniex orderbook volume string. given %s: %v", p, err)
		}
		binKey := int64(price * 1e8)
		orders[binKey] = &poloniexOrder{
			price:  price,
			volume: volume,
		}
	}
	return nil
}
971560
func ParseProcMaps(rd io.Reader) ([]*Mapping, error) {
	s := bufio.NewScanner(rd)
	return parseProcMapsFromScanner(s)
}
940013
func DeserializeMetadata(metadataBytes []byte) (map[string][]byte, error) {
	if metadataBytes == nil {
		return nil, nil
	}
	metadata := &kvrwset.KVMetadataWrite{}
	if err := proto.Unmarshal(metadataBytes, metadata); err != nil {
		return nil, err
	}
	m := make(map[string][]byte, len(metadata.Entries))
	for _, metadataEntry := range metadata.Entries {
		m[metadataEntry.Name] = metadataEntry.Value
	}
	return m, nil
}
1096892
func (reader PluginConfigReaderWithError) GetMap(key string, defaultValue tcontainer.MarshalMap) (tcontainer.MarshalMap, error) {
	key = reader.config.registerKey(key)
	if reader.HasValue(key) {
		return reader.config.Settings.MarshalMap(key)
	}
	return defaultValue, nil
}
781725
func ParseVMX(contents string) map[string]string {
	results := make(map[string]string)

	lineRe := regexp.MustCompile(`^(.+?)\s*=\s*"?(.*?)"?\s*$`)

	for _, line := range strings.Split(contents, "\n") {
		matches := lineRe.FindStringSubmatch(line)
		if matches == nil {
			continue
		}

		key := strings.ToLower(matches[1])
		results[key] = matches[2]
	}

	return results
}
212694
func Parse(s string) (map[string]interface{}, error) {
	vals := map[string]interface{}{}
	scanner := bytes.NewBufferString(s)
	t := newParser(scanner, vals, false)
	err := t.parse()
	return vals, err
}
298926
func (ctl *Controller) initMapper(c context.Context, j *Job, shardIdx int) (Mapper, error) {
	f, err := ctl.getFactory(j.Config.Mapper)
	if err != nil {
		return nil, errors.Annotate(err, "when initializing mapper").Err()
	}
	m, err := f(c, j, shardIdx)
	if err != nil {
		return nil, errors.Annotate(err, "error from mapper factory %q", j.Config.Mapper).Err()
	}
	return m, nil
}
601919
func ParseGeometry(gi interface{}) (geom Geometry, err error) {
	switch g := gi.(type) {
	case map[string]interface{}:
		coord := g["coordinates"]
		switch typ := g["type"]; typ {
		case "Point":
			return parsePoint(coord)
		case "LineString":
			return parseLineString(coord)
		case "MultiPoint":
			return parseMultiPoint(coord)
		case "MultiLineString":
			return parseMultiLineString(coord)
		case "Polygon":
			return parsePolygon(coord)
		case "MultiPolygon":
			return parseMultiPolygon(coord)
		case "GeometryCollection":
			return parseGeometryCollection(g["geometries"])
		default:
			err = errors.New(fmt.Sprintf("ParseError: Unknown geometry type %s", typ))
			break
		}
	}
	return geom, err
}
322916
func (m *ChannelMap) Parse(s string) {
	cstr := C.CString(s)
	defer C.free(unsafe.Pointer(cstr))
	m.fromC(C.pa_channel_map_parse(m.toC(), cstr))
}
1314943
func parsePAX(r io.Reader) (map[string]string, error) {
	buf, err := ioutil.ReadAll(r)
	if err != nil {
		return nil, err
	}
	// leaving this function for io.Reader makes it more testable
	if tr, ok := r.(*Reader); ok && tr.RawAccounting {
		if _, err = tr.rawBytes.Write(buf); err != nil {
			return nil, err
		}
	}
	sbuf := string(buf)

	// For GNU PAX sparse format 0.0 support.
	// This function transforms the sparse format 0.0 headers into format 0.1
	// headers since 0.0 headers were not PAX compliant.
	var sparseMap []string

	paxHdrs := make(map[string]string)
	for len(sbuf) > 0 {
		key, value, residual, err := parsePAXRecord(sbuf)
		if err != nil {
			return nil, ErrHeader
		}
		sbuf = residual

		switch key {
		case paxGNUSparseOffset, paxGNUSparseNumBytes:
			// Validate sparse header order and value.
			if (len(sparseMap)%2 == 0 && key != paxGNUSparseOffset) ||
				(len(sparseMap)%2 == 1 && key != paxGNUSparseNumBytes) ||
				strings.Contains(value, ",") {
				return nil, ErrHeader
			}
			sparseMap = append(sparseMap, value)
		default:
			paxHdrs[key] = value
		}
	}
	if len(sparseMap) > 0 {
		paxHdrs[paxGNUSparseMap] = strings.Join(sparseMap, ",")
	}
	return paxHdrs, nil
}
594000
func GetOnlyMapEntry(obj map[string]interface{}) (string, interface{}, error) {
	if len(obj) != 1 {
		return "", nil, errutil.InvalidInstanceErrorf(obj, "expected only one entry")
	}

	for key, val := range obj {
		return key, val, nil
	}

	panic("unreachable")
	return "", nil, fmt.Errorf("unreachable")
}
457094
func (s *PolicyParameter) SetMapEntries(v []*ParameterMapEntry) *PolicyParameter {
	s.MapEntries = v
	return s
}
1222184
func InitMapInfo(tcpMaxEntries, anyMaxEntries int) {
	mapInfo = make(map[MapType]mapAttributes)
	natMaps := nat.GlobalMaps(true, true)
	natV4 := natMaps[0]
	natV6 := natMaps[1]

	mapType := MapTypeIPv4TCPLocal
	for _, maxEntries := range []int{MapNumEntriesLocal, tcpMaxEntries} {
		setupMapInfo(MapType(mapType), "CT_MAP_TCP4",
			int(unsafe.Sizeof(tuple.TupleKey4{})), maxEntries,
			ct4DumpParser, natV4)
		mapType++
		setupMapInfo(MapType(mapType), "CT_MAP_TCP6",
			int(unsafe.Sizeof(tuple.TupleKey6{})), maxEntries,
			ct6DumpParser, natV6)
		mapType++
	}
	for _, maxEntries := range []int{MapNumEntriesLocal, anyMaxEntries} {
		setupMapInfo(MapType(mapType), "CT_MAP_ANY4",
			int(unsafe.Sizeof(tuple.TupleKey4{})), maxEntries,
			ct4DumpParser, natV4)
		mapType++
		setupMapInfo(MapType(mapType), "CT_MAP_ANY6",
			int(unsafe.Sizeof(tuple.TupleKey6{})), maxEntries,
			ct6DumpParser, natV6)
		mapType++
	}
}
1135819
func (p *Parser) Parse(data []byte) (interfaces.Mappable, error) {
	r := bytes.NewReader(data)
	decoder := xmlp.NewDecoder(r)
	err := decoder.RootElement()
	if err != nil {
		return nil, err
	}

	var feed Feed
	err = p.decode(decoder, &feed)
	if err != nil {
		return nil, err
	}

	return feed, nil
}
926818
func (parser *IdentityMetricDeconstructor) Parse(originalMetric string) (string, datapoint.MetricType, map[string]string, error) {
	return originalMetric, datapoint.Gauge, map[string]string{}, nil
}