// SetField puts the value of src, into fieldName, which must be a member of v.
// The value of src must be assignable to the field.
960714
func SetField(src interface{}, v reflect.Value, fieldName string) error {
	field := v.FieldByName(fieldName)
	if !field.IsValid() {
		return fmt.Errorf("couldn't find %v field in %T", fieldName, v.Interface())
	}
	srcValue := reflect.ValueOf(src)
	if srcValue.Type().AssignableTo(field.Type()) {
		field.Set(srcValue)
		return nil
	}
	if srcValue.Type().ConvertibleTo(field.Type()) {
		field.Set(srcValue.Convert(field.Type()))
		return nil
	}
	return fmt.Errorf("couldn't assign/convert %v to %v", srcValue.Type(), field.Type())
}
214769
func (f *Form) SetFieldTextColor(color tcell.Color) *Form {
	f.fieldTextColor = color
	return f
}
549106
func (s *logger) SetStaticField(name string, value interface{}) {
	s.staticArgs[name] = fmt.Sprintf("%v", value)
}
76060
func (s *XssMatchTuple) SetFieldToMatch(v *FieldToMatch) *XssMatchTuple {
	s.FieldToMatch = v
	return s
}
1081239
func (c *Config) setField(name string, idx int, v value, options []Option) Error {
	opts := makeOptions(options)
	p := parsePathIdx(name, opts.pathSep, idx)

	err := p.SetValue(c, opts, v)
	if err != nil {
		return err
	}

	if opts.meta != nil {
		v.setMeta(opts.meta)
	}
	return nil
}
784253
func SetNestedField(obj map[string]interface{}, value interface{}, fields ...string) error {
	return setNestedFieldNoCopy(obj, runtime.DeepCopyJSONValue(value), fields...)
}
839028
func (s *Resolver) SetFieldName(v string) *Resolver {
	s.FieldName = &v
	return s
}
117185
func (s *GetDocumentVersionInput) SetFields(v string) *GetDocumentVersionInput {
	s.Fields = &v
	return s
}
541401
func (s *TextOptions) SetSourceField(v string) *TextOptions {
	s.SourceField = &v
	return s
}
534620
func (fl *TagFieldList) AddField(field TagField) {
	fl.fields = append(fl.Fields(), field)
}
747833
func (s *SortCriterion) SetField(v string) *SortCriterion {
	s.Field = &v
	return s
}
990908
func (ce CompactEntry) SetFields(target interface{}) {
	for key, value := range ce {
		e := reflect.ValueOf(target).Elem().FieldByNameFunc(func(n string) bool {
			// make this comparison case insensitive
			return strings.ToLower(n) == strings.ToLower(key)
		})
		if e.IsValid() {
			e.SetString(value)
		}
	}
}
1251697
func (s *SqlInjectionMatchTuple) SetFieldToMatch(v *FieldToMatch) *SqlInjectionMatchTuple {
	s.FieldToMatch = v
	return s
}
1263783
func (m *Meta) setField(k string, v starlark.Value) (err error) {
	ptr := m.fieldsMap()[k]
	if ptr == nil {
		return fmt.Errorf("set_meta: no such meta key %q", k)
	}

	// On success, mark the field as modified.
	defer func() {
		if err == nil {
			m.touch(ptr)
		}
	}()

	switch ptr := ptr.(type) {
	case *string:
		if str, ok := v.(starlark.String); ok {
			*ptr = str.GoString()
			return nil
		}
		return fmt.Errorf("set_meta: got %s, expecting string", v.Type())

	case *bool:
		if b, ok := v.(starlark.Bool); ok {
			*ptr = bool(b)
			return nil
		}
		return fmt.Errorf("set_meta: got %s, expecting bool", v.Type())

	case *[]string:
		if iterable, ok := v.(starlark.Iterable); ok {
			iter := iterable.Iterate()
			defer iter.Done()

			var vals []string
			for x := starlark.Value(nil); iter.Next(&x); {
				if str, ok := x.(starlark.String); ok {
					vals = append(vals, str.GoString())
				} else {
					return fmt.Errorf("set_meta: got %s, expecting string", x.Type())
				}
			}

			*ptr = vals
			return nil
		}
		return fmt.Errorf("set_meta: got %s, expecting an iterable", v.Type())

	default:
		panic("impossible")
	}
}
35621
func (f *Field) SetText(text string) FieldInterface {
	if f.fieldType == formcommon.BUTTON ||
		f.fieldType == formcommon.SUBMIT ||
		f.fieldType == formcommon.RESET ||
		f.fieldType == formcommon.STATIC ||
		f.fieldType == formcommon.TEXTAREA {
		f.additionalData["text"] = text
	}
	return f
}
1125124
func (dt *DbfTable) SetFieldValue(row int, fieldIndex int, value string) {
	dt.frozenStruct = true // table structure can not be changed from this point

	b := []byte(value)
	fieldLength := int(dt.fields[fieldIndex].Length)

	// locate the offset of the field in DbfTable dataStore
	offset := dt.getRowOffset(row)
	recordOffset := 1

	//fmt.Println("total fields: ", dt.fields)
	for i := 0; i < len(dt.fields); i++ {
		if i == fieldIndex {
			break
		} else {
			recordOffset += int(dt.fields[i].Length)
		}
	}

	// first fill the field with space values
	for i := 0; i < fieldLength; i++ {
		dt.dataStore[offset+recordOffset+i] = 0x20
	}

	// write new value
	// TODO: this should use copy() or other fast way to move data
	switch dt.fields[fieldIndex].Type {
	case "C", "L", "D":
		for i := 0; i < len(b) && i < fieldLength; i++ {
			dt.dataStore[offset+recordOffset+i] = b[i]
		}
	case "N":
		for i := 0; i < fieldLength; i++ {
			if i < len(b) {
				dt.dataStore[offset+recordOffset+(fieldLength-i-1)] = b[(len(b)-1)-i]
			} else {
				break
			}
		}
	}
}
487404
func (s *Selector) SetFieldName(v string) *Selector {
	s.FieldName = &v
	return s
}