// GetStringFromSysVal converts a given system value to to a string with two decimal
// places of precision.
168559
func (Attr *FloatAttribute) GetStringFromSysVal(rawVal []byte) string {
	f := UnpackBytesToFloat(rawVal)
	formatString := fmt.Sprintf("%%.%df", Attr.Precision)
	return fmt.Sprintf(formatString, f)
}
114562
func (RPCResponse *RPCResponse) GetString() (string, error) {
	val, ok := RPCResponse.Result.(string)
	if !ok {
		return "", fmt.Errorf("could not parse string from %s", RPCResponse.Result)
	}

	return val, nil
}
336075
func (n *NullBool) ParseStringValue(val string) error {
	if val == "" {
		return nil
	}

	boolVal, err := strconv.ParseBool(val)
	if err != nil {
		return err
	}

	n.Value = boolVal
	n.IsSet = true

	return nil
}
246062
func GetString(r *http.Request, name string, value string) string {
	if v := r.FormValue(name); v != "" {
		return v
	}
	return value
}
591489
func GetStringValue(ctx context.Context, key interface{}) (value string) {
	if valuev, ok := ctx.Value(key).(string); ok {
		value = valuev
	}
	return value
}
600266
func SysStringLen(v *int16) uint32 {
	l, _, _ := procSysStringLen.Call(uintptr(unsafe.Pointer(v)))
	return uint32(l)
}
1027569
func getRandValue(dataVal []string) string {
	if !dataCheck(dataVal) {
		return ""
	}
	return data.Data[dataVal[0]][dataVal[1]][rand.Intn(len(data.Data[dataVal[0]][dataVal[1]]))]
}
849082
func NewStringValue(s string) Value {
	value := &Value{}
	value.StoreString(s)
	return *value
}
355892
func (s Slice) CompareString(value string) (int, error) {
	k, err := s.GetStringUTF8()
	if err != nil {
		return 0, WithStack(err)
	}
	return bytes.Compare(k, []byte(value)), nil
}
316164
func (l *Language) GetStringSlice(key string) []string {
	return cast.ToStringSlice(l.Get(key))
}
98218
func HashFromString(dataStr string) (Hash, error) {
	data, err := hex.DecodeString(dataStr)
	if err != nil {
		return Hash{}, errors.WithStack(err)
	}
	return HashFromBytes(data)
}
787747
func (Attr *CategoricalAttribute) GetSysVal(userVal string) []byte {
	for idx, val := range Attr.values {
		if val == userVal {
			return PackU64ToBytes(uint64(idx))
		}
	}
	return nil
}
171164
func MaybeFromString(str string) UUID {
	u, err := FromString(str)
	if err != nil {
		return zero
	}

	return u
}
492460
func RWDFromString(str string) rw.ReadWriteDeleter {
	var res rw.ReadWriteDeleter
	switch str {
	case "file":
		res = &file.File{}
	case "gcs":
		res = &gcs.GCS{}
	case "s3":
		res = &s3.S3{}
	}
	return res
}
334531
func StringToStringValueFunc() mapstructure.DecodeHookFunc {
	return func(
		f reflect.Type,
		t reflect.Type,
		data interface{}) (interface{}, error) {
		if f.Kind() != reflect.String {
			return data, nil
		}

		val := StringValue{}
		if t != reflect.TypeOf(val) {
			return data, nil
		}
		val.v = new(string)
		*(val.v) = data.(string)
		return val, nil
	}
}
805763
func GetString(data []byte, keys ...string) (val string, err error) {
	v, t, _, e := Get(data, keys...)

	if e != nil {
		return "", e
	}

	if t != String {
		return "", fmt.Errorf("Value is not a string: %s", string(v))
	}

	// If no escapes return raw conten
	if bytes.IndexByte(v, '\\') == -1 {
		return string(v), nil
	}

	return ParseString(v)
}
423062
func getStringValue(b []rune) (int, error) {
	if b[0] != '"' {
		return 0, NewParseError("strings must start with '\"'")
	}

	endQuote := false
	i := 1

	for ; i < len(b) && !endQuote; i++ {
		if escaped := isEscaped(b[:i], b[i]); b[i] == '"' && !escaped {
			endQuote = true
			break
		} else if escaped {
			/*c, err := getEscapedByte(b[i])
			if err != nil {
				return 0, err
			}

			b[i-1] = c
			b = append(b[:i], b[i+1:]...)
			i--*/

			continue
		}
	}

	if !endQuote {
		return 0, NewParseError("missing '\"' in string value")
	}

	return i + 1, nil
}