// GetStructThing returns the value of StructThing if it is set or its
// zero value if it is unset.
513371
func (v *Xception2) GetStructThing() (o *Xtruct) {
	if v != nil && v.StructThing != nil {
		return v.StructThing
	}

	return
}
836487
func (p *TCompactProtocol) ReadStructEnd() error {
	// consume the last field we read off the wire.
	p.lastFieldId = p.lastField[len(p.lastField)-1]
	p.lastField = p.lastField[:len(p.lastField)-1]
	return nil
}
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
}
29228
func AnalyzeStructParams(
	requestStruct interface{},
	funcArgs *RequestParams,
	params *RequestParams,
	extraStructs *ExtraStructs,
) {
	reflectStruct, ok := requestStruct.(reflect.Type)
	if !ok {
		reflectStruct = reflect.TypeOf(requestStruct)
	}
	for i := 0; i < reflectStruct.NumField(); i++ {
		field := reflectStruct.Field(i)

		if fieldTag := field.Tag.Get("apijs"); fieldTag == "inherit" {
			AnalyzeStructParams(field.Type, funcArgs, params, extraStructs)
			continue
		}

		if fieldTag := field.Tag.Get("json"); fieldTag != "" {
			if tags := strings.Split(fieldTag, ","); len(tags) > 0 {
				jsonName := tags[0]
				if jsonName == "-" {
					continue
				}

				funcArgs.Upsert(jsonName, &field)
				params.Upsert(jsonName, &field)

				structType := ensureReflectStruct(field.Type)
				switch structType.Kind() {
				case reflect.Struct:
					extraStruct := extraStructs.Upsert(jsonName, field.Type)
					AnalyzeStructParams(
						structType,
						&extraStruct.Params,
						nil,
						extraStructs,
					)
				}
			}
		}
	}
}
1258134
func EnsureBindStruct(ctx martini.Context, obj interface{}) reflect.Value {
	objType := ctx.Get(reflect.TypeOf(obj))
	if objType.IsValid() {
		return objType
	}

	ctx.Invoke(BindStruct(obj))
	objType = ctx.Get(reflect.TypeOf(obj))
	return objType
}
1066073
func (s *Value) SetStructValue(v *StructValue) *Value {
	s.StructValue = v
	return s
}
607046
func getStructField(v interface{}, field string) (fieldVal interface{}, exists bool) {
	vv := reflect.ValueOf(v)
	if !vv.IsValid() {
		return nil, false
	}
	if vv.Kind() == reflect.Ptr {
		vv = vv.Elem()
	}
	fv := vv.FieldByName(field)
	if !fv.IsValid() {
		return nil, false
	}
	return fv.Interface(), true
}
1056407
func (tag PluginStructTag) GetString() string {
	tagValue, tagSet := reflect.StructTag(tag).Lookup(PluginStructTagDefault)
	if !tagSet {
		return ""
	}
	return tstrings.Unescape(tagValue)
}
967033
func NewStruct(s interface{}, tagid string) (*StructStruct, error) {
	if s, ok := s.(*StructStruct); ok {
		return s, nil
	}

	v := reflect.ValueOf(s)
	if v.Kind() != reflect.Ptr {
		return nil, errNoPointer
	}
	if v.Elem().Kind() != reflect.Struct {
		return nil, errNoStruct
	}

	return &StructStruct{
		name:  fmt.Sprintf("%T", s),
		raw:   s,
		value: v,
		data:  fieldsOf(s, tagid),
	}, nil
}
86869
func (marshaler *DefaultEnvMarshaler) unmarshalStruct(t reflect.Type, envPrefix string) (reflect.Value, error) {
	val := reflect.New(t).Elem()
	parser := &DefaultParser{}

	tKind := t.Kind()
	if tKind != reflect.Struct {
		return val, errors.Errorf("cannot unmarshal non-struct type %s", tKind)
	}

	for i := 0; i < t.NumField(); i++ {
		fieldStruct := t.Field(i)
		fieldEnvTag := fieldStruct.Tag.Get("env")

		if fieldEnvTag == "" {
			continue
		}

		fieldEnvTag = envPrefix + fieldEnvTag
		structFieldVal := val.Field(i)
		err := marshaler.unmarshalField(fieldStruct, structFieldVal, fieldEnvTag, parser)
		if err != nil {
			return val, err
		}
	}

	return val, nil
}
254834
func LoadStruct(obj interface{}, m map[string]interface{}, tagname string, ignoreUndefined bool) error {
	structValue := reflect.ValueOf(obj).Elem()
	for i := 0; i < structValue.NumField(); i++ {
		valueField := structValue.Field(i)
		structField := structValue.Type().Field(i)

		dest := structField.Tag.Get(tagname)
		if dest == "" {
			dest = structField.Name
		}
		if !valueField.IsValid() {
			return fmt.Errorf("No such field: %s in obj", structField.Name)
		}
		if !valueField.CanSet() {
			return fmt.Errorf("Cannot set %s field value", structField.Name)
		}
		importedValue, ok := m[dest]
		if !ok && !ignoreUndefined {
			return fmt.Errorf("input map[%v] is undefined", dest)
		}
		if importedValue == nil {
			if ignoreUndefined {
				continue
			}
			return fmt.Errorf("set value (named %v) can not be nil", dest)
		}
		newValue := reflect.ValueOf(importedValue)
		if structField.Type != newValue.Type() {
			invalidTypeError := errors.New("Provided value type didn't match obj field type")
			return invalidTypeError
		}
		valueField.Set(newValue)
	}
	return nil
}
20621
func (c *Client) DoStruct(opts interface{}, in interface{}) (interface{}, error) {
	if _, ok := opts.(*RpbGetReq); ok {
		return c.fetchStruct(opts.(*RpbGetReq), string(opts.(*RpbGetReq).GetBucket()), string(opts.(*RpbGetReq).GetKey()), in)
	}
	if _, ok := opts.(*RpbPutReq); ok {
		return c.storeStruct(opts.(*RpbPutReq), string(opts.(*RpbPutReq).GetBucket()), string(opts.(*RpbPutReq).GetKey()), in)
	}

	return nil, nil
}
516928
func IsStruct(obj interface{}) bool {
	return obj != nil && reflect.TypeOf(obj).Kind() == reflect.Struct
}
1321709
func GetStructType(alias string) (structType reflect.Type) {
	structTypesLocker.RLock()
	structType = structTypes[alias]
	structTypesLocker.RUnlock()
	return structType
}
66750
func ValidateStruct(target interface{}) (bool, error) {
	val := reflect.ValueOf(target)

	if val.Kind() == reflect.Ptr {
		val = val.Elem()
	}

	return validateStructValue(val)
}
798171
func (v *validate) GetStructFieldOK() (reflect.Value, reflect.Kind, bool) {
	return v.getStructFieldOKInternal(v.slflParent, v.ct.param)
}
740576
func (f StructField) Get(val interface{}) (err error) {
	b, err := f.db.Get(f.key)
	if err != nil {
		return err
	}
	return rlp.DecodeBytes(b, val)
}