// StringArray type asserts to an `array` of `string`
772351
func (j *Json) StringArray() ([]string, error) {
	arr, err := j.Array()
	if err != nil {
		return nil, err
	}
	retArr := make([]string, 0, len(arr))
	for _, a := range arr {
		if a == nil {
			retArr = append(retArr, "")
			continue
		}
		s, ok := a.(string)
		if !ok {
			return nil, err
		}
		retArr = append(retArr, s)
	}
	return retArr, nil
}
523933
func (t *typeName) VisitArray(a *proto.Array) {
	s := &typeName{}
	a.SubType.Accept(s)
	t.Name = fmt.Sprintf("[]%s", s.Name)
}
557616
func parseArray(array string) []string {
	results := []string{}
	matches := arrayExp.FindAllStringSubmatch(array, -1)
	for _, match := range matches {
		s := match[valueIndex]
		// the string _might_ be wrapped in quotes, so trim them:
		s = strings.Trim(s, "\"")
		results = append(results, s)
	}
	return results
}
930607
func (p *parser) typeOfArray(types []confType) confType {
	// Empty arrays are cool.
	if len(types) == 0 {
		return confArray
	}

	theType := types[0]
	for _, t := range types[1:] {
		if !typeEqual(theType, t) {
			p.panicf("Array contains values of type '%s' and '%s', but arrays "+
				"must be homogeneous.", theType, t)
		}
	}
	return confArray
}
828963
func IntArray(name string, values []int) FieldOpt {
	inType := inTypeNull
	var writeItem func(*eventData, int)
	switch unsafe.Sizeof(values[0]) {
	case 4:
		inType = inTypeInt32
		writeItem = func(ed *eventData, item int) { ed.writeInt32(int32(item)) }
	case 8:
		inType = inTypeInt64
		writeItem = func(ed *eventData, item int) { ed.writeInt64(int64(item)) }
	default:
		panic("Unsupported int size")
	}

	return func(em *eventMetadata, ed *eventData) {
		em.writeArray(name, inType, outTypeDefault, 0)
		ed.writeUint16(uint16(len(values)))
		for _, v := range values {
			writeItem(ed, v)
		}
	}
}
32513
func (m *StringArray) Scan(src interface{}) error {

	var srcBytes []byte
	switch val := src.(type) {
	case string:
		srcBytes = []byte(val)
	case []byte:
		srcBytes = val
	default:
		return fmt.Errorf("Incompatible type for StringArray got %T", src)
	}
	sa := make([]string, 0)
	if u.IsJsonArray(srcBytes) {
		err := json.Unmarshal(srcBytes, &sa)
		if err != nil {
			return err
		}
	} else if parts := strings.Split(string(srcBytes), ","); len(parts) > 0 {
		sa = parts
	}

	*m = StringArray(sa)
	return nil
}
334839
func flagTypeArrayVal(a *design.AttributeDefinition, field string) string {
	switch a.Type.ToArray().ElemType.Type {
	case design.Number, design.Boolean, design.UUID, design.DateTime, design.Any:
		return "%s"
	}
	return field
}
1088307
func ContainsString(array []string, element string) bool {
	for _, e := range array {
		if element == e {
			return true
		}
	}
	return false
}
1194536
func pcfArray(val []interface{}) (string, error) {
	items := make([]string, len(val))
	for i, el := range val {
		p, err := parsingCanonicalForm(el)
		if err != nil {
			return "", err
		}
		items[i] = p
	}
	return "[" + strings.Join(items, ",") + "]", nil
}
217949
func (sd *structDef) buildArray() {
	sd.buildOneLine(convertToGoType(sd.T.Type.(string), ""))
}
1348292
func (c *Context) PostFormArray(key string) []string {
	values, _ := c.GetPostFormArray(key)
	return values
}
692168
func IsArrayType(t string) bool {
	tip := raml.Type{
		Type: t,
	}
	return tip.IsArray()
}
955952
func (self *StringTypeDef) UnmarshalJSON(b []byte) error {
	var m rawStringTypeDef
	err := json.Unmarshal(b, &m)
	if err == nil {
		o := StringTypeDef(m)
		*self = o
		err = self.Validate()
	}
	return err
}
754093
func (t Type) IsArray() bool {
	if t.IsJSONType() {
		return false
	}
	return t.TypeString() == arrayType || strings.HasSuffix(t.TypeString(), "[]")
}
1359344
func (a *StringArray) Scan(value interface{}) error {
	if value == nil {
		*a = nil
		return nil
	}

	var b []byte
	switch v := value.(type) {
	case []byte:
		b = v
	case string:
		b = []byte(v)
	default:
		return fmt.Errorf("StringArray.Scan: expected []byte or string, got %T (%q)", value, value)
	}

	if len(b) < 2 || b[0] != '{' || b[len(b)-1] != '}' {
		return fmt.Errorf("StringArray.Scan: unexpected data %q", b)
	}

	// reuse underlying array if present
	if *a == nil {
		*a = make(StringArray, 0)
	}
	*a = (*a)[:0]

	if len(b) == 2 { // '{}'
		return nil
	}

	reader := bytes.NewReader(b[1 : len(b)-1]) // skip '{' and '}'

	// helper function to read next rune and check if it valid
	readRune := func() (rune, error) {
		r, _, err := reader.ReadRune()
		if err != nil {
			return 0, err
		}
		if r == unicode.ReplacementChar {
			return 0, fmt.Errorf("StringArray.Scan: invalid rune")
		}
		return r, nil
	}

	var q bool
	var e []rune
	for {
		// read next rune and check if we are done
		r, err := readRune()
		if err == io.EOF {
			break
		}
		if err != nil {
			return err
		}

		switch r {
		case '"':
			// enter or leave quotes
			q = !q
			continue
		case ',':
			// end of element unless in we are in quotes
			if !q {
				*a = append(*a, string(e))
				e = e[:0]
				continue
			}
		case '\\':
			// skip to next rune, it should be present
			n, err := readRune()
			if err != nil {
				return err
			}
			r = n
		}

		e = append(e, r)
	}

	// we should not be in quotes at this point
	if q {
		panic("StringArray.Scan bug")
	}

	// add last element
	*a = append(*a, string(e))
	return nil
}
246999
func (rp *Reply) BytesArrayValue() ([][]byte, error) {
	if rp.Type == ErrorReply {
		return nil, errors.New(rp.Error)
	}
	if rp.Type != MultiReply {
		return nil, errors.New("invalid reply type, not multi bulk")
	}
	var result [][]byte
	if rp.Multi != nil {
		for _, subrp := range rp.Multi {
			b, err := subrp.BytesValue()
			if err != nil {
				return nil, err
			}
			result = append(result, b)
		}
	}
	return result, nil
}
256520
func bindArray(bindType int, query string, arg interface{}, m *reflectx.Mapper) (string, []interface{}, error) {
	// do the initial binding with QUESTION;  if bindType is not question,
	// we can rebind it at the end.
	bound, names, err := compileNamedQuery([]byte(query), QUESTION)
	if err != nil {
		return "", []interface{}{}, err
	}
	arrayValue := reflect.ValueOf(arg)
	arrayLen := arrayValue.Len()
	if arrayLen == 0 {
		return "", []interface{}{}, fmt.Errorf("length of array is 0: %#v", arg)
	}
	var arglist []interface{}
	for i := 0; i < arrayLen; i++ {
		elemArglist, err := bindArgs(names, arrayValue.Index(i).Interface(), m)
		if err != nil {
			return "", []interface{}{}, err
		}
		arglist = append(arglist, elemArglist...)
	}
	if arrayLen > 1 {
		bound = fixBound(bound, arrayLen)
	}
	// adjust binding type if we weren't on question
	if bindType != QUESTION {
		bound = Rebind(bindType, bound)
	}
	return bound, arglist, nil
}