// DecodeList alters the list in place, attempting to decode any objects found in
// the list that have the runtime.Unknown type. Any errors that occur are returned
// after the entire list is processed. Decoders are tried in order.
425886
func DecodeList(objects []Object, decoders ...ObjectDecoder) []error {
	errs := []error(nil)
	for i, obj := range objects {
		switch t := obj.(type) {
		case *Unknown:
			for _, decoder := range decoders {
				gv, err := unversioned.ParseGroupVersion(t.APIVersion)
				if err != nil {
					errs = append(errs, err)
					break
				}

				if !decoder.Recognizes(gv.WithKind(t.Kind)) {
					continue
				}
				obj, err := Decode(decoder, t.RawJSON)
				if err != nil {
					errs = append(errs, err)
					break
				}
				objects[i] = obj
				break
			}
		}
	}
	return errs
}
483404
func DecodeVarint(in io.Reader) (int, error) {
	u, err := DecodeUvarint(in)
	n := int(u)
	return (n >> 1) ^ -(n & 1), err
}
472488
func Decode(reader io.Reader) (*CachedResponseDecoder, error) {
	dec := gob.NewDecoder(reader)
	res := &CachedResponse{}
	if err := dec.Decode(&res); err != nil {
		return nil, err
	}

	return &CachedResponseDecoder{CachedResponse: res}, nil
}
526607
func (d *decoder) Decode(v interface{}) error {
	rv := reflect.ValueOf(v)
	if rv.Kind() != reflect.Ptr {
		return fmt.Errorf("cannot decode into non-pointer %T", v)
	}
	d.vs = [][]reflect.Value{{rv.Elem()}}
	return d.decode()
}
1075389
func (p *Proto) NewDecoder(reader io.Reader) runtime.Decoder {
	return runtime.DecoderFunc(func(value interface{}) error {
		buffer, err := ioutil.ReadAll(reader)
		if err != nil {
			return err
		}
		return p.Unmarshal(buffer, value)
	})
}
300406
func newDecoder(h Handle) *Decoder {
	d := &Decoder{h: basicHandle(h), err: errDecoderNotInitialized}
	d.bytes = true
	if useFinalizers {
		runtime.SetFinalizer(d, (*Decoder).finalize)
		// xdebugf(">>>> new(Decoder) with finalizer")
	}
	d.r = &d.decReaderSwitch
	d.hh = h
	d.be = h.isBinary()
	// NOTE: do not initialize d.n here. It is lazily initialized in d.naked()
	var jh *JsonHandle
	jh, d.js = h.(*JsonHandle)
	if d.js {
		d.jsms = jh.MapKeyAsString
	}
	d.esep = d.hh.hasElemSeparators()
	if d.h.InternString {
		d.is = make(map[string]string, 32)
	}
	d.d = h.newDecDriver(d)
	// d.cr, _ = d.d.(containerStateRecv)
	return d
}
665629
func NewDecoder(r io.Reader) *decoder {
	d := &decoder{
		scanner:  bufio.NewScanner(r),
		nextFn:   decodeInit,
		line:     0,
		buffered: "",
	}
	return d
}
633344
func decodeItem(data []byte, i int) (
	result interface{}, index int, err error) {

	var decodeFunc = []func([]byte, int) (interface{}, int, error){
		DecodeString, DecodeInt, DecodeList, DecodeDict,
	}

	for _, f := range decodeFunc {
		result, index, err = f(data, i)
		if err == nil {
			return
		}
	}

	err = errors.New("invalid bencode when decode item")
	return
}
354768
func NewDecoder(data []byte) *Decoder {
	return &Decoder{
		data: data,
		end:  len(data),
	}
}
842319
func (d *Decoder) decodeScalefactors1() error {
	for sb := 0; sb < 32; sb++ {
		for ch := 0; ch < d.nChannels; ch++ {
			if d.allocation[ch][sb] != 0 {
				sf, err := d.stream.readBits(6)
				if err != nil {
					return err
				}
				d.scalefactor12[ch][sb][0] = sf
			}
		}
	}
	return nil
}
486109
func decodeSlice(elemType reflect.Type, slice reflect.Value, input map[string]interface{}) error {
	var v reflect.Value
	if elemType.Kind() == reflect.Ptr {
		v = reflect.New(elemType.Elem())
	} else {
		v = reflect.New(elemType)
	}

	if !v.CanInterface() {
		return fmt.Errorf("can't interface %#v", v)
	}

	if err := decodeMap(input, v.Interface()); err != nil {
		return err
	}

	if elemType.Kind() == reflect.Struct {
		v = v.Elem()
	}
	slice.Set(reflect.Append(slice, v))

	return nil
}
1124181
func (d *Decoder) DecodeArray() ([]interface{}, error) {
	if c := d.skipSpaces(); c != '[' {
		return nil, d.error(c, "looking for beginning of array")
	}
	val, err := d.array()
	if err != nil {
		return nil, err
	}
	if c := d.skipSpaces(); d.pos < d.end {
		return nil, d.error(c, "after top-level value")
	}
	return val, nil
}
686621
func NewDecoder(r io.Reader) *Decoder {
	d := &Decoder{
		ns:       make(map[string]string),
		nextByte: -1,
		line:     1,
		Strict:   true,
	}
	d.switchToReader(r)
	return d
}
820849
func (s *Semaphore) decodeLock(pair *KVPair) (*semaphoreLock, error) {
	// Handle if there is no lock
	if pair == nil || pair.Value == nil {
		return &semaphoreLock{
			Limit:   s.opts.Limit,
			Holders: make(map[string]bool),
		}, nil
	}

	l := &semaphoreLock{}
	if err := json.Unmarshal(pair.Value, l); err != nil {
		return nil, fmt.Errorf("lock decoding failed: %v", err)
	}
	return l, nil
}
230569
func (marshaller *ProtoMarshaller) NewDecoder(reader io.Reader) Decoder {
	return DecoderFunc(func(value interface{}) error {
		buffer, err := ioutil.ReadAll(reader)
		if err != nil {
			return err
		}
		return marshaller.Unmarshal(buffer, value)
	})
}
659920
func NewDecoder(r io.Reader, format Format) Decoder {
	switch format {
	case FmtProtoDelim:
		return &protoDecoder{r: r}
	}
	return &textDecoder{r: r}
}
366668
func unmarshalerDecoder(d *decodeState, v reflect.Value, opts decOpts) int {
	um, ok := v.Interface().(Unmarshaler)
	if !ok {
		panic(fmt.Errorf("Non-Unmarshaler passed to unmarshalerEncoder"))
	}

	read, err := um.UnmarshalTLS(d.Bytes())
	if err != nil {
		panic(err)
	}

	if read > d.Len() {
		panic(fmt.Errorf("Invalid return value from UnmarshalTLS"))
	}

	d.Next(read)
	return read
}