// GetXtructs returns the value of Xtructs if it is set or its
// zero value if it is unset.
8850
func (v *Insanity) GetXtructs() (o []*Xtruct) {
	if v != nil && v.Xtructs != nil {
		return v.Xtructs
	}

	return
}
581682
func (s *Search) getMatches(iter memdb.ResultIterator, prefix string) ([]string, bool) {
	var matches []string

	for i := 0; i < truncateLimit; i++ {
		raw := iter.Next()
		if raw == nil {
			break
		}

		var id string
		switch t := raw.(type) {
		case *structs.Job:
			id = raw.(*structs.Job).ID
		case *structs.Evaluation:
			id = raw.(*structs.Evaluation).ID
		case *structs.Allocation:
			id = raw.(*structs.Allocation).ID
		case *structs.Node:
			id = raw.(*structs.Node).ID
		case *structs.Deployment:
			id = raw.(*structs.Deployment).ID
		default:
			matchID, ok := getEnterpriseMatch(raw)
			if !ok {
				s.logger.Error("unexpected type for resources context", "type", fmt.Sprintf("%T", t))
				continue
			}

			id = matchID
		}

		if !strings.HasPrefix(id, prefix) {
			continue
		}

		matches = append(matches, id)
	}

	return matches, iter.Next() != nil
}
1111599
func GetContracts() (*Contracts, error) {
	contracts := NewContracts()
	if err := contracts.GetContracts(); err != nil {
		return nil, err
	}

	return contracts, nil
}
214350
func TableFromStructs(structs Slice) *Table {
	s := reflectSlice(structs)
	st := s.Type()
	if st.Elem().Kind() != reflect.Struct {
		panic(&generic.TypeError{st, nil, "is not a slice of struct"})
	}

	var t Builder
	rows := s.Len()
	var rec func(reflect.Type, []int)
	rec = func(typ reflect.Type, index []int) {
		for fn := 0; fn < typ.NumField(); fn++ {
			field := typ.Field(fn)
			if field.PkgPath != "" {
				continue
			}
			oldIndexLen := len(index)
			index = append(index, field.Index...)
			if field.Anonymous {
				rec(field.Type, index)
			} else {
				col := reflect.MakeSlice(reflect.SliceOf(field.Type), rows, rows)
				for i := 0; i < rows; i++ {
					col.Index(i).Set(s.Index(i).FieldByIndex(index))
				}
				t.Add(field.Name, col.Interface())
			}
			index = index[:oldIndexLen]
		}
	}
	rec(st.Elem(), []int{})
	return t.Done()
}
831793
func (cs ContinuousSeries) GetValues(index int) (float64, float64) {
	return cs.XValues[index], cs.YValues[index]
}
607234
func (ema *EMASeries) GetValues(index int) (x, y float64) {
	if ema.InnerSeries == nil {
		return
	}
	if len(ema.cache) == 0 {
		ema.ensureCachedValues()
	}
	vx, _ := ema.InnerSeries.GetValues(index)
	x = vx
	y = ema.cache[index]
	return
}
99932
func (env *TypeEnv) Get(x interface{}) types.Type {

	if term, ok := x.(*Term); ok {
		x = term.Value
	}

	switch x := x.(type) {

	// Scalars.
	case Null:
		return types.NewNull()
	case Boolean:
		return types.NewBoolean()
	case Number:
		return types.NewNumber()
	case String:
		return types.NewString()

	// Composites.
	case Array:
		static := make([]types.Type, len(x))
		for i := range static {
			tpe := env.Get(x[i].Value)
			static[i] = tpe
		}

		var dynamic types.Type
		if len(static) == 0 {
			dynamic = types.A
		}

		return types.NewArray(static, dynamic)

	case Object:
		static := []*types.StaticProperty{}
		var dynamic *types.DynamicProperty

		x.Foreach(func(k, v *Term) {
			if IsConstant(k.Value) {
				kjson, err := JSON(k.Value)
				if err != nil {
					panic("unreachable")
				}
				tpe := env.Get(v)
				static = append(static, types.NewStaticProperty(kjson, tpe))
			} else {
				typeK := env.Get(k.Value)
				typeV := env.Get(v.Value)
				dynamic = types.NewDynamicProperty(typeK, typeV)
			}
		})

		if len(static) == 0 && dynamic == nil {
			dynamic = types.NewDynamicProperty(types.A, types.A)
		}

		return types.NewObject(static, dynamic)

	case Set:
		var tpe types.Type
		x.Foreach(func(elem *Term) {
			other := env.Get(elem.Value)
			tpe = types.Or(tpe, other)
		})
		if tpe == nil {
			tpe = types.A
		}
		return types.NewSet(tpe)

	// Comprehensions.
	case *ArrayComprehension:
		checker := newTypeChecker()
		cpy, errs := checker.CheckBody(env, x.Body)
		if len(errs) == 0 {
			return types.NewArray(nil, cpy.Get(x.Term))
		}
		return nil
	case *ObjectComprehension:
		checker := newTypeChecker()
		cpy, errs := checker.CheckBody(env, x.Body)
		if len(errs) == 0 {
			return types.NewObject(nil, types.NewDynamicProperty(cpy.Get(x.Key), cpy.Get(x.Value)))
		}
		return nil
	case *SetComprehension:
		checker := newTypeChecker()
		cpy, errs := checker.CheckBody(env, x.Body)
		if len(errs) == 0 {
			return types.NewSet(cpy.Get(x.Term))
		}
		return nil

	// Refs.
	case Ref:
		return env.getRef(x)

	// Vars.
	case Var:
		if node := env.tree.Child(x); node != nil {
			return node.Value()
		}
		if env.next != nil {
			return env.next.Get(x)
		}
		return nil

	default:
		panic("unreachable")
	}
}
897265
func (ctx *Context) PushStruct(s interface{}) (int, error) {
	t := reflect.TypeOf(s)
	v := reflect.ValueOf(s)

	obj := ctx.PushObject()
	ctx.pushStructMethods(obj, t, v)

	if t.Kind() == reflect.Ptr {
		v = v.Elem()
		t = v.Type()
	}

	return obj, ctx.pushStructFields(obj, t, v)
}
394196
func getAllXattrs(path string) (map[string]string, error) {
	xMetadata := make(map[string]string)
	list, e := xattr.List(path)
	if e != nil {
		if isNotSupported(e) {
			return nil, nil
		}
		return nil, e
	}
	for _, key := range list {
		// filter out system specific xattr
		if strings.HasPrefix(key, "system.") {
			continue
		}
		xMetadata[key], e = getXAttr(path, key)
		if e != nil {
			if isNotSupported(e) {
				return nil, nil
			}
			return nil, e
		}
	}
	return xMetadata, nil
}
1363778
func (g *GenApp) UseGoStructFlags() bool {
	if g.GenOpts == nil {
		return true
	}
	return g.GenOpts.FlagStrategy == "" || g.GenOpts.FlagStrategy == "go-flags"
}
38235
func RetrieveTxnsBlocks(ctx context.Context, db *sql.DB, txHash string) (blockHashes []string,
	blockHeights, blockIndexes []uint32, areValid, areMainchain []bool, err error) {
	var rows *sql.Rows
	rows, err = db.QueryContext(ctx, internal.SelectTxsBlocks, txHash)
	if err != nil {
		return
	}
	defer closeRows(rows)

	for rows.Next() {
		var hash string
		var height, idx uint32
		var isValid, isMainchain bool
		err = rows.Scan(&height, &hash, &idx, &isValid, &isMainchain)
		if err != nil {
			break
		}

		blockHeights = append(blockHeights, height)
		blockHashes = append(blockHashes, hash)
		blockIndexes = append(blockIndexes, idx)
		areValid = append(areValid, isValid)
		areMainchain = append(areMainchain, isMainchain)
	}
	return
}
819804
func parseStruct(value reflect.Value, token string, ctx *context) error {
	separator := string(sliceEnvSeparator)
	if ctx.usingDefault {
		separator = string(sliceDefaultSeparator)
	}

	tokens := strings.Split(token[1:len(token)-1], separator)
	if len(tokens) != value.NumField() {
		return fmt.Errorf("struct token has %d fields but struct has %d", len(tokens), value.NumField())
	}

	for i := 0; i < value.NumField(); i++ {
		field := value.Field(i)
		t := tokens[i]

		if err := parseValue(field, t, ctx); err != nil {
			return err
		}
	}

	return nil
}
798171
func (v *validate) GetStructFieldOK() (reflect.Value, reflect.Kind, bool) {
	return v.getStructFieldOKInternal(v.slflParent, v.ct.param)
}
1233423
func (reps *MonthDownloadCSV) ConvertToStructs() (*MonthDownloadStructs, error) {
	var theseReports MonthDownloadStructs

	if reps.PriceSheetReport != "" {
		err := theseReports.convertPriceSheet(&reps.PriceSheetReport)
		if err != nil {
			return nil, err
		}
	}

	if reps.DetailReport != "" {
		err := theseReports.convertDetailReport(&reps.DetailReport)
		if err != nil {
			return nil, err
		}
	}

	return &theseReports, nil
}
334341
func (v *defaultValidator) ValidateStruct(obj interface{}) error {
	value := reflect.ValueOf(obj)
	valueType := value.Kind()
	if valueType == reflect.Ptr {
		valueType = value.Elem().Kind()
	}
	if valueType == reflect.Struct {
		v.lazyinit()
		if err := v.validate.Struct(obj); err != nil {
			return err
		}
	}
	return nil
}
1321709
func GetStructType(alias string) (structType reflect.Type) {
	structTypesLocker.RLock()
	structType = structTypes[alias]
	structTypesLocker.RUnlock()
	return structType
}
1158792
func (st *StructTypeInfo) FieldInfos() FieldInfos {
	var fields FieldInfos
	for _, field := range st.AstStructType().Fields.List {
		fields = append(fields, (*FieldInfo)(field))
	}

	return fields
}