// toOuchValue serializes nosql.Value -> native json values.
13533
func toOuchValue(v nosql.Value) interface{} {
	switch v := v.(type) {
	case nil:
		return nil
	case nosql.Strings:
		return []string(v)
	case nosql.String:
		return string(v)
	case nosql.Int:
		return int64(v)
	case nosql.Float:
		return float64(v)
	case nosql.Bool:
		return bool(v)
	case nosql.Time:
		return time.Time(v).UTC().Format(time.RFC3339Nano)
	case nosql.Bytes:
		return base64.StdEncoding.EncodeToString(v)
	default:
		panic(fmt.Errorf("unsupported type: %T", v))
	}
}
1236188
func (confSrc *MemoryConfigurationSource) AddKeyValue(key string, value interface{}) error {
	if !confSrc.ChanStatus {
		<-confSrc.CallbackCheck
		confSrc.ChanStatus = true
	}

	event := new(core.Event)
	event.EventSource = confSrc.GetSourceName()
	event.Key = key
	event.Value = value

	confSrc.Lock()
	defer confSrc.Unlock()
	if _, ok := confSrc.Configurations[key]; !ok {
		event.EventType = core.Create
	} else {
		event.EventType = core.Update
	}

	confSrc.Configurations[key] = value

	if confSrc.callback != nil {
		confSrc.callback.OnEvent(event)
	}

	return nil
}
497739
func (h *Handle) SetValue(value []byte) error {
	return json.Unmarshal(value, h)
}
879388
func DoubleValue(val string) (*wrappers.DoubleValue, error) {
	parsedVal, err := Float64(val)
	return &wrappers.DoubleValue{Value: parsedVal}, err
}
589468
func (b *Builder) AddValue(v Value) error {
	if err := b.addInternal(v); err != nil {
		return WithStack(err)
	}
	return nil
}
977881
func IsValue(v interface{}) bool {
	if IsScanValue(v) {
		return true
	}
	if _, ok := v.(string); ok {
		return true
	}
	return false
}
886411
func (s *Setting) SetValue(v string) *Setting {
	s.Value = &v
	return s
}
497998
func (s *Sort) SetValue(v string) *Sort {
	s.Value = &v
	return s
}
716262
func (c *configuration) stackValue(i int) head {
	size := c.stackSize()
	if i >= size || i < 0 {
		return DOES_NOT_EXIST
	}
	return c.stack[size-1-i]
}
656680
func (s *MappingRule) SetValue(v string) *MappingRule {
	s.Value = &v
	return s
}
297853
func (v *NowValuer) Value(key string) (interface{}, bool) {
	if !v.Now.IsZero() && key == "now()" {
		return v.Now, true
	}
	return nil, false
}
122039
func (L *State) PushValue(index int) {
	C.lua_pushvalue(L.s, C.int(index))
}
1131374
func newTimedValue(value interface{}, err error, staleDuration, expiryDuration time.Duration) *TimedValue {
	switch val := value.(type) {
	case TimedValue:
		if val.Created.IsZero() {
			val.Created = time.Now()
		}
		return &val
	case *TimedValue:
		if val.Created.IsZero() {
			val.Created = time.Now()
		}
		return val
	default:
		if staleDuration == 0 && expiryDuration == 0 {
			return &TimedValue{Value: value, Err: err, Created: time.Now()}
		}
		var stale, expiry time.Time
		now := time.Now()
		if staleDuration > 0 {
			stale = now.Add(staleDuration)
		}
		if expiryDuration > 0 {
			expiry = now.Add(expiryDuration)
		}
		return &TimedValue{Value: value, Err: err, Created: time.Now(), Stale: stale, Expiry: expiry}
	}
}
405581
func (s *DimensionFilter) SetValue(v string) *DimensionFilter {
	s.Value = &v
	return s
}
436689
func TimeValue(v *time.Time) time.Time {
	if v != nil {
		return *v
	}
	return time.Time{}
}
1196955
func WithValue(e error, key, value interface{}) Error {
	if e == nil {
		return nil
	}
	return WrapSkipping(e, 1).WithValue(key, value)
}
1337537
func AnySettableValue(val reflect.Value) bool {
	switch val.Kind() {
	case reflect.Array:
		for i := 0; i < val.Type().Len(); i++ {
			if AnySettableValue(val.Index(i)) {
				return true
			}
		}
	case reflect.Interface:
		return AnySettableValue(val.Elem())
	case reflect.Map:
		for _, key := range val.MapKeys() {
			if AnySettableValue(val.MapIndex(key)) {
				return true
			}
		}
	case reflect.Ptr:
		return AnySettableValue(val.Elem())
	case reflect.Slice:
		for i := 0; i < val.Len(); i++ {
			if AnySettableValue(val.Index(i)) {
				return true
			}
		}
	case reflect.Struct:
		for i := 0; i < val.Type().NumField(); i++ {
			if AnySettableValue(val.Field(i)) {
				return true
			}
		}
	default:
		return val.CanSet()
	}
	return false
}