// Scan implements the Scanner interface.
434121
func (ns *NullString) Scan(value interface{}) error {
	if value == nil {
		ns.String, ns.Valid = "", false
		return nil
	}
	ns.Valid = true
	return convertAssign(&ns.String, value)
}
589952
func (r *Row) Scan(dest ...interface{}) (err error) {
	rows := (*Rows)(r)

	if rows.Err() != nil {
		return rows.Err()
	}

	if !rows.Next() {
		if rows.Err() == nil {
			return ErrNoRows
		}
		return rows.Err()
	}

	rows.Scan(dest...)
	rows.Close()
	return rows.Err()
}
674242
func (i *Int64) Scan(value interface{}) (err error) {
	if value == nil {
		i.Int64, i.Valid = 0, false
		return nil
	}
	i.Valid = true

	switch v := value.(type) {
	case []byte:
		i.Int64, err = strconv.ParseInt(string(v), 10, 64)
	case string:
		i.Int64, err = strconv.ParseInt(v, 10, 64)
	case int64:
		i.Int64 = v
	default:
		err = fmt.Errorf("ntypes: unsuported type (%T) passed to Int64.Scan", value)
	}

	return
}
468146
func (dst *pguint32) Scan(src interface{}) error {
	if src == nil {
		*dst = pguint32{Status: Null}
		return nil
	}

	switch src := src.(type) {
	case uint32:
		*dst = pguint32{Uint: src, Status: Present}
		return nil
	case int64:
		*dst = pguint32{Uint: uint32(src), Status: Present}
		return nil
	case string:
		return dst.DecodeText(nil, []byte(src))
	case []byte:
		srcCopy := make([]byte, len(src))
		copy(srcCopy, src)
		return dst.DecodeText(nil, srcCopy)
	}

	return errors.Errorf("cannot scan %T", src)
}
428415
func (ls *LineString) Scan(src interface{}) error {
	b, ok := src.([]byte)
	if !ok {
		return ErrExpectedByteSlice{Value: src}
	}
	got, err := Unmarshal(b)
	if err != nil {
		return err
	}
	ls1, ok := got.(*geom.LineString)
	if !ok {
		return wkbcommon.ErrUnexpectedType{Got: ls1, Want: ls}
	}
	ls.LineString = ls1
	return nil
}
962398
func (p *Printer) Scan(r io.Reader, addNewLine bool) (cancel func()) {
	var canceled uint32
	shouldCancel := func() bool {
		return atomic.LoadUint32(&canceled) > 0
	}
	cancel = func() {
		atomic.StoreUint32(&canceled, 1)
	}

	go func() {
		scanner := bufio.NewScanner(r)

		for {
			if shouldCancel() {
				break
			}
			if scanner.Scan() {
				if shouldCancel() {
					// re-store the bytes?
					p.restore(scanner.Bytes())
					break
				}
				text := scanner.Bytes()
				if addNewLine {
					text = append(text, NewLine...)
				}
				p.Print(text)
			}

			if err := scanner.Err(); err != nil {
				// TODO: do something with that or ignore it.
			}
		}
	}()

	return cancel
}
1318176
func (p *Parser) scan() {
	for {
		token, literal := p.l.Lex()
		p.scannedItems = append(p.scannedItems, ScannedItem{token, literal})
		if token == EndOfStringToken {
			break
		}
	}
}
1282247
func (b *Bool) Scan(value interface{}) (err error) {
	if value == nil {
		b.Bool, b.Valid = false, false
		return nil
	}
	b.Valid = true

	switch v := value.(type) {
	case []byte:
		b.Bool, err = strconv.ParseBool(string(v))
	case string:
		b.Bool, err = strconv.ParseBool(v)
	case bool:
		b.Bool = v
	default:
		err = fmt.Errorf("ntypes: unsuported type (%T) passed to Bool.Scan", value)
	}

	return
}
1276584
func (s *scanner) scan() (token, string, error) {
	ch, _, err := s.r.ReadRune()

	if err != nil && err != io.EOF {
		return tokenError, "", err
	}

	switch ch {
	case zeroRune:
		return eof, "", nil
	case ':':
		return colon, string(ch), nil
	case '~':
		return tilde, string(ch), nil
	case '^':
		return caret, string(ch), nil
	case '.':
		return dot, string(ch), nil
	case '/':
		return slash, string(ch), nil
	case '{':
		return obrace, string(ch), nil
	case '}':
		return cbrace, string(ch), nil
	case '-':
		return minus, string(ch), nil
	case '@':
		return at, string(ch), nil
	case '\\':
		return aslash, string(ch), nil
	case '?':
		return qmark, string(ch), nil
	case '*':
		return asterisk, string(ch), nil
	case '[':
		return obracket, string(ch), nil
	case '!':
		return emark, string(ch), nil
	}

	if unicode.IsSpace(ch) {
		return space, string(ch), nil
	}

	if unicode.IsControl(ch) {
		return control, string(ch), nil
	}

	if unicode.IsLetter(ch) {
		return tokenizeExpression(ch, word, unicode.IsLetter, s.r)
	}

	if unicode.IsNumber(ch) {
		return tokenizeExpression(ch, number, unicode.IsNumber, s.r)
	}

	return tokenError, string(ch), nil
}
974698
func (s *Scanner) Scan() bool {
	for s.source.Scan() {
		line := s.source.Text()
		status, fields := s.parseLine(line)
		switch status {
		case qffail:
			continue
		case qfendmultiline:
			s.mlpoped = true
			s.entry = s.qi.qflist[len(s.qi.qflist)-1]
			return true
		case qfignoreline:
			continue
		}
		var lastml *Entry // last multiline entry which isn't poped out
		if !s.mlpoped {
			lastml = s.qi.qflist[len(s.qi.qflist)-1]
		}
		qfl := &Entry{
			Filename: fields.namebuf,
			Lnum:     fields.lnum,
			Col:      fields.col,
			Nr:       fields.enr,
			Pattern:  fields.pattern,
			Text:     fields.errmsg,
			Vcol:     fields.useviscol,
			Valid:    fields.valid,
			Type:     rune(fields.etype),
			Lines:    fields.lines,
		}
		if qfl.Filename == "" && s.qi.currfile != "" {
			qfl.Filename = s.qi.currfile
		}
		s.qi.qflist = append(s.qi.qflist, qfl)
		if s.qi.multiline {
			s.mlpoped = false // mark multiline entry is not poped
			// if there is last multiline entry which isn't poped out yet, pop it out now.
			if lastml != nil {
				s.entry = lastml
				return true
			}
			continue
		}
		// multiline flag doesn't be reset with new entry.
		// %Z or nomach are the only way to reset multiline flag.
		s.entry = qfl
		return true
	}
	// pop last not-ended multiline entry
	if !s.mlpoped {
		s.mlpoped = true
		s.entry = s.qi.qflist[len(s.qi.qflist)-1]
		return true
	}
	return false
}
32339
func (dst *Int8) Scan(src interface{}) error {
	if src == nil {
		*dst = Int8{Status: Null}
		return nil
	}

	switch src := src.(type) {
	case int64:
		*dst = Int8{Int: src, Status: Present}
		return nil
	case string:
		return dst.DecodeText(nil, []byte(src))
	case []byte:
		srcCopy := make([]byte, len(src))
		copy(srcCopy, src)
		return dst.DecodeText(nil, srcCopy)
	}

	return errors.Errorf("cannot scan %T", src)
}
520212
func (r *Redis) Scan(cursor uint64, pattern string, count int) (uint64, []string, error) {
	args := packArgs("SCAN", cursor)
	if pattern != "" {
		args = append(args, "MATCH", pattern)
	}
	if count > 0 {
		args = append(args, "COUNT", count)
	}
	rp, err := r.ExecuteCommand(args...)
	if err != nil {
		return 0, nil, err
	}
	if rp.Type == ErrorReply {
		return 0, nil, errors.New(rp.Error)
	}
	if rp.Type != MultiReply {
		return 0, nil, errors.New("scan protocol error")
	}
	first, err := rp.Multi[0].StringValue()
	if err != nil {
		return 0, nil, err
	}
	next, err := strconv.ParseUint(first, 10, 64)
	if err != nil {
		return 0, nil, err
	}
	list, err := rp.Multi[1].ListValue()
	return next, list, err
}
1283683
func (ss *StringSlice) Scan(src interface{}) error {
	buf, ok := src.([]byte)
	if !ok {
		return errors.New("invalid StringSlice")
	}

	// change quote escapes for csv parser
	str := quoteEscapeRegex.ReplaceAllString(string(buf), `$1""`)
	str = strings.Replace(str, `\\`, `\`, -1)

	// remove braces
	str = str[1 : len(str)-1]

	// bail if only one
	if len(str) == 0 {
		*ss = StringSlice([]string{})
		return nil
	}

	// parse with csv reader
	cr := csv.NewReader(strings.NewReader(str))
	slice, err := cr.Read()
	if err != nil {
		fmt.Printf("exiting!: %v\n", err)
		return err
	}

	*ss = StringSlice(slice)

	return nil
}
836118
func (os *OracleString) Scan(value interface{}) error {
	if value == nil {
		os.String, os.Valid = "", false
		return nil
	}
	os.Valid = true
	return os.NullString.Scan(value)
}
654534
func (s *Scanner) Scan() (r rune) {
	s.tokenIdx = 0
	r, _, err := s.r.ReadRune()
	prevRune := r

	if s.Whitespace.Get(int(r)) {
		s.token[s.tokenIdx] = r
		s.tokenIdx++
		return r
	}

	for ; !s.Whitespace.Get(int(r)); r, _, err = s.r.ReadRune() {
		switch err {
		case nil:
			break
		case io.EOF:
			return EOF
		default:
			s.Error(err)
			return EOF
		}
		s.token[s.tokenIdx] = r
		s.tokenIdx++
		prevRune = r
	}

	// We have to UnreadRune because we went too far of one rune
	err = s.r.UnreadRune()
	if err != nil {
		s.Error(err)
	}

	return prevRune
}
541581
func (ia *Int64Array) Scan(value interface{}) (err error) {
	if value == nil {
		ia.Int64Array, ia.Valid = nil, false
		return
	}
	ia.Valid = true
	ia.Int64Array, err = Int64ArrayScan(value)
	return
}
1068738
func (fa *Float64Array) Scan(value interface{}) (err error) {
	if value == nil {
		fa.Float64Array, fa.Valid = nil, false
		return
	}
	fa.Valid = true
	fa.Float64Array, err = Float64ArrayScan(value)
	return
}