// ChannelPositionFromString returns the ChannelPosition described
// by the given string.
//
// The string should be as returned by ChannelPosition.String().
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))
}
718779
func TypeFromString(str string) Type {
	for t, d := range definitions {
		if d.name == str {
			return t
		}
	}

	panic("Type not registered")
}
1090185
func FormatFromString(formatStr string) Format {
	formatStr = strings.ToLower(formatStr)
	if strings.Contains(formatStr, ".") {
		// Assume a filename
		formatStr = strings.TrimPrefix(filepath.Ext(formatStr), ".")

	}
	switch formatStr {
	case "yaml", "yml":
		return YAML
	case "json":
		return JSON
	case "toml":
		return TOML
	case "org":
		return ORG
	case "csv":
		return CSV
	}

	return ""

}
368074
func MountPointFromString(mp string) (*MountPoint, error) {
	var mount MountPoint

	mp = "name=" + mp
	mpQuery, err := common.MakeQueryString(mp)
	if err != nil {
		return nil, err
	}

	v, err := url.ParseQuery(mpQuery)
	if err != nil {
		return nil, err
	}
	for key, val := range v {
		if len(val) > 1 {
			return nil, fmt.Errorf("label %s with multiple values %q", key, val)
		}

		switch key {
		case "name":
			acn, err := NewACName(val[0])
			if err != nil {
				return nil, err
			}
			mount.Name = *acn
		case "path":
			mount.Path = val[0]
		case "readOnly":
			ro, err := strconv.ParseBool(val[0])
			if err != nil {
				return nil, err
			}
			mount.ReadOnly = ro
		default:
			return nil, fmt.Errorf("unknown mountpoint parameter %q", key)
		}
	}
	err = mount.assertValid()
	if err != nil {
		return nil, err
	}

	return &mount, nil
}
683788
func (r Render) AddFromStringsFuncs(name string, funcMap template.FuncMap, templateStrings ...string) *template.Template {
	tmpl := template.New(name).Funcs(funcMap)

	for _, ts := range templateStrings {
		tmpl = template.Must(tmpl.Parse(ts))
	}

	r.Add(name, tmpl)
	return tmpl
}
1265889
func DataTypeFromString(s string) DataType {
	switch s {
	case "float":
		return Float
	case "integer":
		return Integer
	case "unsigned":
		return Unsigned
	case "string":
		return String
	case "boolean":
		return Boolean
	case "time":
		return Time
	case "duration":
		return Duration
	case "tag":
		return Tag
	case "field":
		return AnyField
	default:
		return Unknown
	}
}
1206197
func NewFromString(encoded string) (*Value, error) {
	out, err := base64.RawURLEncoding.DecodeString(encoded)
	if err != nil {
		return nil, err
	}

	return New(out), nil
}
387254
func LevelFromString(lvl string) level {
	// Determine if lvl includes "level"
	lvl = strings.ToLower(lvl)
	if len(lvl) > 4 && lvl[0:5] != "level" {
		lvl = "level_" + lvl
	} else if len(lvl) < 5 {
		lvl = "level_" + lvl
	}
	for num, llvl := range levels {
		if lvl == strings.ToLower(llvl) {
			return level(num)
		}
	}
	return LEVEL_PRINT
}
16588
func LevelFromString(levelStr string) Level {
	// We don't care about case. Accept both "INFO" and "info".
	levelStr = strings.ToLower(strings.TrimSpace(levelStr))
	switch levelStr {
	case "trace":
		return Trace
	case "debug":
		return Debug
	case "info":
		return Info
	case "warn":
		return Warn
	case "error":
		return Error
	default:
		return NoLevel
	}
}
36752
func ChannelPoint(op wire.OutPoint) OptionalMsgField {
	return func(f *optionalMsgFields) {
		f.channelPoint = &op
	}
}
1172645
func (p Pos) String() string {
	return fmt.Sprintf("%d:%d", p.Line, p.Offset)
}
1188264
func (p *param) SetFromString(s string) error {
	parts := strings.SplitN(s, "=", 2)
	if len(parts) <= 1 {
		return errors.New("Unable to convert to param: " + s)
	}

	p.name = strings.TrimSpace(parts[0])
	p.value = fmt.Sprintf(`"%s"`, strings.TrimSpace(parts[1]))

	return nil
}
1037719
func OpTypeFromString(s string) Op {
	switch s[0] {
	case 'i':
		return Insert
	case 'u':
		return Update
	case 'd':
		return Delete
	case 'c':
		return Command
	case 'n':
		return Noop
	case 's':
		return Skip
	default:
		return Unknown
	}
}
331724
func makeMapKeyFromString(mapKeyType reflect.Type, pointer string) (reflect.Value, bool) {
	valp := reflect.New(mapKeyType)
	val := reflect.Indirect(valp)
	switch mapKeyType.Kind() {
	case reflect.String:
		return reflect.ValueOf(pointer), true
	case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
		iv, err := strconv.ParseInt(pointer, 10, mapKeyType.Bits())
		if err == nil {
			val.SetInt(iv)
			return val, true
		}
	case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:
		iv, err := strconv.ParseUint(pointer, 10, mapKeyType.Bits())
		if err == nil {
			val.SetUint(iv)
			return val, true
		}
	case reflect.Float32, reflect.Float64:
		fv, err := strconv.ParseFloat(pointer, mapKeyType.Bits())
		if err == nil {
			val.SetFloat(fv)
			return val, true
		}
	}

	return reflect.ValueOf(nil), false
}
634
func SelectFromStrings(messageToPrint string, options []string) (string, error) {
	return SelectFromStringsFromReader(messageToPrint, options, os.Stdin)
}
1364293
func Uint32ToString(from uint32) (string, error) {
	return strconv.FormatUint(uint64(from), DefeultNumericBase), nil
}
970147
func StringFromCLSID(clsid *GUID) (str string, err error) {
	var p *uint16
	hr, _, _ := procStringFromCLSID.Call(uintptr(unsafe.Pointer(clsid)), uintptr(unsafe.Pointer(&p)))
	if hr != 0 {
		err = NewError(hr)
	}
	str = LpOleStrToString(p)
	return
}