// ChannelMap.Parse parses a channel position list or well-known mapping name
// into a channel map structure.
//
// Input should be as returned by ChannelMap.Name() or ChannelMap.String().
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))
}
243886
func StringMap(msp map[string]*string) map[string]string {
	ms := make(map[string]string, len(msp))
	for k, sp := range msp {
		if sp != nil {
			ms[k] = *sp
		} else {
			ms[k] = ""
		}
	}
	return ms
}
843366
func parse(ymlContent, env string, subs map[string]string) (SecretsMap, error) {
	if env == "" {
		return parseRegular(ymlContent, subs)
	}

	return parseEnvironment(ymlContent, env, subs)
}
83459
func MatchMap(buf []byte, matchers matchers.Map) types.Type {
	for kind, matcher := range matchers {
		if matcher(buf) {
			return kind
		}
	}
	return types.Unknown
}
1069247
func (p *PlayerInfo) Parse(elem map[string]interface{}) error {
	p.Steamid = elem["steamid"].(string)
	p.Profileurl = elem["profileurl"].(string)

	// profile visibility
	visibility := elem["communityvisibilitystate"].(json.Number).String()
	var vState string

	switch {
	case visibility == "1":
		vState = "private"
	case visibility == "3":
		vState = "public"
	}

	// same as communityvisibilitystate
	// but as string (public or private)
	p.Visibility = vState

	playerV, vErr := strconv.Atoi(visibility)
	if vErr != nil {
		return vErr
	}

	// int as str
	p.Communityvisibilitystate = playerV

	// Logoff
	playerL, pErr := tryParsingNumber(elem["lastlogoff"])
	p.Lastlogoff = playerL
	if pErr != nil {
		p.Lastlogoff = -1
	}

	// if the account has a steam community profile set then this should be 1
	profileState, stErr := tryParsingNumber(elem["profilestate"])
	if stErr != nil {
		return stErr
	}

	p.Profilestate = profileState

	// variables that are only available when
	// the profile visibility is set to public
	if vState == "public" {
		p.Realname = tryParsingString(elem["realname"])

		// user is online, offline...
		playerState, pstErr := tryParsingNumber(elem["personastate"])
		if pstErr != nil {
			return pstErr
		}

		p.Personastate = PersonaState(playerState)

		// timecreated
		playerTC, tcErr := tryParsingNumber(elem["timecreated"])
		if tcErr != nil {
			return tcErr
		}

		p.Timecreated = playerTC

		// location
		p.Loccountrycode = tryParsingString(elem["loccountrycode"])
		p.Locstatecode = tryParsingString(elem["locstatecode"])

		cityId, cErr := tryParsingNumber(elem["loccityid"])
		if cErr != nil {
			cityId = 0
		}

		p.Loccityid = cityId
	}

	// avatar
	p.Avatar = elem["avatar"].(string)
	p.Avatarfull = elem["avatarfull"].(string)
	p.Avatarmedium = elem["avatarmedium"].(string)

	// name
	p.Personaname = elem["personaname"].(string)
	p.Name = p.Personaname // alias

	return nil
}
221317
func parseArgsDataString(stdin io.Reader, args []string) (map[string]string, error) {
	raw, err := parseArgsData(stdin, args)
	if err != nil {
		return nil, err
	}

	var result map[string]string
	if err := mapstructure.WeakDecode(raw, &result); err != nil {
		return nil, errors.Wrap(err, "failed to convert values to strings")
	}
	if result == nil {
		result = make(map[string]string)
	}
	return result, nil
}
432569
func ChannelPositionFromString(s string) ChannelPosition {
	cstr := C.CString(s)
	defer C.free(unsafe.Pointer(cstr))
	return ChannelPosition(C.pa_channel_position_from_string(cstr))
}
544114
func decodeMap(d map[string]interface{}, r interface{}) error {
	cfg := &mapstructure.DecoderConfig{
		WeaklyTypedInput: true,
		TagName:          "ms",
		Result:           r,
		DecodeHook:       timeHookFunc,
	}
	dec, err := mapstructure.NewDecoder(cfg)
	if err != nil {
		return err
	}
	return dec.Decode(d)
}
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
}
1221937
func Parse(v interface{}) ([]string, error) {
	if command, _, err := generateCommand(v, true); err == nil {
		return command, err
	} else {
		return nil, err
	}
}
1328279
func parseSecretMap(secretMap map[string]string) (string, error) {
	if len(secretMap) == 0 {
		return "", fmt.Errorf("empty secret map")
	}
	secret := ""
	for k, v := range secretMap {
		if k == secretKeyName {
			return v, nil
		}
		secret = v
	}
	// If not found, the last secret in the map wins as done before
	return secret, nil
}
946893
func Parse(pair string) (k, v string) {
	parts := strings.SplitN(pair, ":", 2)
	k = parts[0]
	if len(parts) > 1 {
		v = parts[1]
	} else {
		// this pair is invalid. This should not happen in practice.
		// Do not panic because this function is used for externally-supplied
		// data.
	}
	return
}
1013639
func parse(input string) (*PKGBUILD, error) {
	var pkgbuild *PKGBUILD
	var next item

	lexer := lex(input)
Loop:
	for {
		token := lexer.nextItem()

		// strip arch from source_arch like constructs
		witharch := strings.SplitN(token.val, "_", 2)
		if len(witharch) == 2 {
			found := false
			for _, arch := range pkgbuild.Arch {
				if arch == witharch[1] {
					token.val = witharch[0]
					found = true
					break
				}
			}

			if !found {
				return nil, fmt.Errorf("unsupported arch for variable: %s", token.val)
			}
		}

		switch token.typ {
		case itemPkgbase:
			next = lexer.nextItem()
			pkgbuild = &PKGBUILD{Epoch: 0, Pkgbase: next.val}
		case itemPkgname:
			next = lexer.nextItem()
			pkgbuild.Pkgnames = append(pkgbuild.Pkgnames, next.val)
		case itemPkgver:
			next = lexer.nextItem()
			version, err := parseVersion(next.val)
			if err != nil {
				return nil, err
			}
			pkgbuild.Pkgver = version
		case itemPkgrel:
			next = lexer.nextItem()
			rel, err := parseVersion(next.val)
			if err != nil {
				return nil, err
			}
			pkgbuild.Pkgrel = rel
		case itemPkgdir:
			next = lexer.nextItem()
			pkgbuild.Pkgdir = next.val
		case itemEpoch:
			next = lexer.nextItem()
			epoch, err := strconv.ParseInt(next.val, 10, 0)
			if err != nil {
				return nil, err
			}

			if epoch < 0 {
				return nil, fmt.Errorf("invalid epoch: %d", epoch)
			}
			pkgbuild.Epoch = int(epoch)
		case itemPkgdesc:
			next = lexer.nextItem()
			pkgbuild.Pkgdesc = next.val
		case itemArch:
			next = lexer.nextItem()
			pkgbuild.Arch = append(pkgbuild.Arch, next.val)
		case itemURL:
			next = lexer.nextItem()
			pkgbuild.URL = next.val
		case itemLicense:
			next = lexer.nextItem()
			pkgbuild.License = append(pkgbuild.License, next.val)
		case itemGroups:
			next = lexer.nextItem()
			pkgbuild.Groups = append(pkgbuild.Groups, next.val)
		case itemDepends:
			next = lexer.nextItem()
			deps, err := parseDependency(next.val, pkgbuild.Depends)
			if err != nil {
				return nil, err
			}
			pkgbuild.Depends = deps
		case itemOptdepends:
			next = lexer.nextItem()
			pkgbuild.Optdepends = append(pkgbuild.Optdepends, next.val)
		case itemMakedepends:
			next = lexer.nextItem()
			deps, err := parseDependency(next.val, pkgbuild.Makedepends)
			if err != nil {
				return nil, err
			}
			pkgbuild.Makedepends = deps
		case itemCheckdepends:
			next = lexer.nextItem()
			deps, err := parseDependency(next.val, pkgbuild.Checkdepends)
			if err != nil {
				return nil, err
			}
			pkgbuild.Checkdepends = deps
		case itemProvides:
			next = lexer.nextItem()
			pkgbuild.Provides = append(pkgbuild.Provides, next.val)
		case itemConflicts:
			next = lexer.nextItem()
			pkgbuild.Conflicts = append(pkgbuild.Conflicts, next.val)
		case itemReplaces:
			next = lexer.nextItem()
			pkgbuild.Replaces = append(pkgbuild.Replaces, next.val)
		case itemBackup:
			next = lexer.nextItem()
			pkgbuild.Backup = append(pkgbuild.Backup, next.val)
		case itemOptions:
			next = lexer.nextItem()
			pkgbuild.Options = append(pkgbuild.Options, next.val)
		case itemInstall:
			next = lexer.nextItem()
			pkgbuild.Install = next.val
		case itemChangelog:
			next = lexer.nextItem()
			pkgbuild.Changelog = next.val
		case itemSource:
			next = lexer.nextItem()
			pkgbuild.Source = append(pkgbuild.Source, next.val)
		case itemNoextract:
			next = lexer.nextItem()
			pkgbuild.Noextract = append(pkgbuild.Noextract, next.val)
		case itemMd5sums:
			next = lexer.nextItem()
			pkgbuild.Md5sums = append(pkgbuild.Md5sums, next.val)
		case itemSha1sums:
			next = lexer.nextItem()
			pkgbuild.Sha1sums = append(pkgbuild.Sha1sums, next.val)
		case itemSha224sums:
			next = lexer.nextItem()
			pkgbuild.Sha224sums = append(pkgbuild.Sha224sums, next.val)
		case itemSha256sums:
			next = lexer.nextItem()
			pkgbuild.Sha256sums = append(pkgbuild.Sha256sums, next.val)
		case itemSha384sums:
			next = lexer.nextItem()
			pkgbuild.Sha384sums = append(pkgbuild.Sha384sums, next.val)
		case itemSha512sums:
			next = lexer.nextItem()
			pkgbuild.Sha512sums = append(pkgbuild.Sha512sums, next.val)
		case itemValidpgpkeys:
			next = lexer.nextItem()
			pkgbuild.Validpgpkeys = append(pkgbuild.Validpgpkeys, next.val)
		case itemEndSplit:
		case itemError:
			return nil, fmt.Errorf(token.val)
		case itemEOF:
			break Loop
		default:
			return nil, fmt.Errorf("invalid variable: %s", token.val)
		}
	}
	return pkgbuild, nil
}
1107202
func StringMap(src map[string]string) map[string]*string {
	dst := make(map[string]*string)
	for k, val := range src {
		v := val
		dst[k] = &v
	}
	return dst
}
357559
func Parse(input string) (string, error) {
	addrs, err := sockaddr.GetAllInterfaces()
	if err != nil {
		return "", errwrap.Wrapf("unable to query interface addresses: {{err}}", err)
	}

	return ParseIfAddrs(input, addrs)
}
1042398
func (f *File) GetChannelMapInfo() (channels []int32, err error) {
	channels = make([]int32, f.Format.Channels)
	r := GenericCmd(f, C.SFC_GET_CHANNEL_MAP_INFO, unsafe.Pointer(&channels[0]), len(channels)*4)
	if r == C.SF_FALSE {
		err = errors.New(C.GoString(C.sf_strerror(f.s)))
	}
	return
}
639068
func parseMap(r reflect.Value, node *XMLNode, tag reflect.StructTag) error {
	if r.IsNil() {
		r.Set(reflect.MakeMap(r.Type()))
	}

	if tag.Get("flattened") == "" { // look at all child entries
		for _, entry := range node.Children["entry"] {
			parseMapEntry(r, entry, tag)
		}
	} else { // this element is itself an entry
		parseMapEntry(r, node, tag)
	}

	return nil
}