// unmarshalAttr unmarshals a single XML attribute into val.
347818
func (p *Decoder) unmarshalAttr(val reflect.Value, attr Attr) error {
	if val.Kind() == reflect.Ptr {
		if val.IsNil() {
			val.Set(reflect.New(val.Type().Elem()))
		}
		val = val.Elem()
	}

	if val.CanInterface() && val.Type().Implements(unmarshalerAttrType) {
		// This is an unmarshaler with a non-pointer receiver,
		// so it's likely to be incorrect, but we do what we're told.
		return val.Interface().(UnmarshalerAttr).UnmarshalXMLAttr(attr)
	}
	if val.CanAddr() {
		pv := val.Addr()
		if pv.CanInterface() && pv.Type().Implements(unmarshalerAttrType) {
			return pv.Interface().(UnmarshalerAttr).UnmarshalXMLAttr(attr)
		}
	}

	// Not an UnmarshalerAttr; try encoding.TextUnmarshaler.
	if val.CanInterface() && val.Type().Implements(textUnmarshalerType) {
		// This is an unmarshaler with a non-pointer receiver,
		// so it's likely to be incorrect, but we do what we're told.
		return val.Interface().(encoding.TextUnmarshaler).UnmarshalText([]byte(attr.Value))
	}
	if val.CanAddr() {
		pv := val.Addr()
		if pv.CanInterface() && pv.Type().Implements(textUnmarshalerType) {
			return pv.Interface().(encoding.TextUnmarshaler).UnmarshalText([]byte(attr.Value))
		}
	}

	copyValue(val, []byte(attr.Value))
	return nil
}
1330907
func (v *SimpleType) UnmarshalText(value []byte) error {
	switch s := string(value); s {
	case "BOOL":
		*v = SimpleTypeBool
		return nil
	case "BYTE":
		*v = SimpleTypeByte
		return nil
	case "INT8":
		*v = SimpleTypeInt8
		return nil
	case "INT16":
		*v = SimpleTypeInt16
		return nil
	case "INT32":
		*v = SimpleTypeInt32
		return nil
	case "INT64":
		*v = SimpleTypeInt64
		return nil
	case "FLOAT64":
		*v = SimpleTypeFloat64
		return nil
	case "STRING":
		*v = SimpleTypeString
		return nil
	case "STRUCT_EMPTY":
		*v = SimpleTypeStructEmpty
		return nil
	default:
		val, err := strconv.ParseInt(s, 10, 32)
		if err != nil {
			return fmt.Errorf("unknown enum value %q for %q: %v", s, "SimpleType", err)
		}
		*v = SimpleType(val)
		return nil
	}
}
9266
func UnmarshalMap(m map[string]*dynamodb.AttributeValue, out interface{}) error {
	return NewDecoder().Decode(&dynamodb.AttributeValue{M: m}, out)
}
1164171
func (s *DLSettings) UnmarshalText(text []byte) error {
	b, err := hex.DecodeString(string(text))
	if err != nil {
		return err
	}

	return s.UnmarshalBinary(b)
}
1325233
func (u *Array) UnmarshalText(data []byte) error {
	id, err := guuid.ParseBytes(data)
	if err != nil {
		return err
	}
	*u = Array(id)
	return nil
}
249661
func (j *JSONText) Unmarshal(v interface{}) error {
	if len(*j) == 0 {
		*j = emptyJSON
	}
	return json.Unmarshal([]byte(*j), v)
}
68156
func (s *Story) Unmarshal(ss string) error {
	return json.Unmarshal([]byte(ss), s)
}
593649
func (j *JSONBuiltin) Unmarshal(data []byte, v interface{}) error {
	return json.Unmarshal(data, v)
}
433638
func (e *GT) Unmarshal(m []byte) (*GT, bool) {
	// Each value is a 256-bit number.
	const numBytes = 256 / 8

	if len(m) != 12*numBytes {
		return nil, false
	}

	if e.p == nil {
		e.p = newGFp12(nil)
	}

	e.p.x.x.x.SetBytes(m[0*numBytes : 1*numBytes])
	e.p.x.x.y.SetBytes(m[1*numBytes : 2*numBytes])
	e.p.x.y.x.SetBytes(m[2*numBytes : 3*numBytes])
	e.p.x.y.y.SetBytes(m[3*numBytes : 4*numBytes])
	e.p.x.z.x.SetBytes(m[4*numBytes : 5*numBytes])
	e.p.x.z.y.SetBytes(m[5*numBytes : 6*numBytes])
	e.p.y.x.x.SetBytes(m[6*numBytes : 7*numBytes])
	e.p.y.x.y.SetBytes(m[7*numBytes : 8*numBytes])
	e.p.y.y.x.SetBytes(m[8*numBytes : 9*numBytes])
	e.p.y.y.y.SetBytes(m[9*numBytes : 10*numBytes])
	e.p.y.z.x.SetBytes(m[10*numBytes : 11*numBytes])
	e.p.y.z.y.SetBytes(m[11*numBytes : 12*numBytes])

	return e, true
}
699293
func Unmarshal(bs []byte, v interface{}) error {
	bs, err := yaml.YAMLToJSON(bs)
	if err != nil {
		return err
	}
	return UnmarshalJSON(bs, v)
}
63857
func (self *Coder) Unmarshal(in []byte, data interface{}) error {
	return self.unmarshaller(in, data)
}
197879
func (z *Big) UnmarshalText(data []byte) error {
	return z.scan(bytes.NewReader(data))
}
489524
func (u UnmarshalerFunc) Unmarshal(data []byte, v interface{}) error {
	return u(data, v)
}
932963
func (j *JSONMarshaler) Unmarshal(data []byte, v interface{}) error {
	return json.Unmarshal(data, v)
}
400950
func Unmarshal(data []byte, v interface{}) error {
	rv := reflect.ValueOf(v)
	if rv.Kind() != reflect.Ptr {
		return fmt.Errorf("not a pointer: %v", v)
	}

	rv = rv.Elem()
	if rv.Kind() != reflect.Struct && rv.Kind() != reflect.Map {
		return fmt.Errorf("not a pointer to a struct/map: %v", v)
	}

	l, err := data2map(data)
	if err != nil {
		return err
	}
	if rv.Kind() == reflect.Map {
		kt := rv.Type().Key()
		vt := rv.Type().Elem()
		if kt.Kind() != reflect.String || vt.Kind() != reflect.String {
			return fmt.Errorf("not a map[string]string")
		}
		for k, v := range l {
			kv := reflect.ValueOf(k).Convert(kt)
			vv := reflect.ValueOf(v).Convert(vt)
			rv.SetMapIndex(kv, vv)
		}
		return nil
	}

	t := rv.Type()
	errs := UnmarshalError{}
	for i := 0; i < t.NumField(); i++ {
		ft := t.Field(i)
		fv := rv.Field(i)

		tag := ft.Tag.Get("ltsv")
		tags := strings.Split(tag, ",")
		key := tags[0]
		if key == "-" {
			continue
		}
		if key == "" {
			key = strings.ToLower(ft.Name)
		}
		s, ok := l[key]
		if !ok {
			continue
		}
		potentiallyNull := s == "-" || s == ""
		if fv.Kind() == reflect.Ptr {
			if fv.IsNil() {
				if potentiallyNull {
					switch fv.Type().Elem().Kind() {
					case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Float32, reflect.Float64:
						continue
					}
				}
				fv.Set(reflect.New(fv.Type().Elem()))
			}
			fv = fv.Elem()
		}
		if !fv.CanSet() {
			continue
		}

		switch fv.Kind() {
		case reflect.String:
			fv.SetString(s)
		case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
			if potentiallyNull {
				continue
			}
			i, err := strconv.ParseInt(s, 10, 64)
			if err != nil || fv.OverflowInt(i) {
				errs[ft.Name] = &UnmarshalTypeError{"number " + s, fv.Type()}
				continue
			}
			fv.SetInt(i)
		case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
			if potentiallyNull {
				continue
			}
			i, err := strconv.ParseUint(s, 10, 64)
			if err != nil || fv.OverflowUint(i) {
				errs[ft.Name] = &UnmarshalTypeError{"number " + s, fv.Type()}
				continue
			}
			fv.SetUint(i)
		case reflect.Float32, reflect.Float64:
			if potentiallyNull {
				continue
			}
			n, err := strconv.ParseFloat(s, fv.Type().Bits())
			if err != nil || fv.OverflowFloat(n) {
				errs[ft.Name] = &UnmarshalTypeError{"number " + s, fv.Type()}
				continue
			}
			fv.SetFloat(n)
		default:
			u := indirect(fv)
			if u == nil {
				errs[ft.Name] = &UnmarshalTypeError{s, fv.Type()}
			} else {
				err := u.UnmarshalText([]byte(s))
				if err != nil {
					errs[ft.Name] = err
				}
			}
		}
	}

	if len(errs) < 1 {
		return nil
	}
	return errs
}
1474
func Unmarshal(bs []byte, v interface{}) error {
	root, err := parse(bs)
	if err != nil {
		return err
	}

	return DecodeObject(v, root)
}
60171
func Unmarshal(s string, message proto.Message) error {
	data, err := base64.RawURLEncoding.DecodeString(s)
	if err != nil {
		return err
	}
	return proto.Unmarshal(data, message)
}