khenaidoo | ab1f7bd | 2019-11-14 14:00:27 -0500 | [diff] [blame] | 1 | package jsoniter |
| 2 | |
| 3 | import "fmt" |
| 4 | |
| 5 | type invalidAny struct { |
| 6 | baseAny |
| 7 | err error |
| 8 | } |
| 9 | |
| 10 | func newInvalidAny(path []interface{}) *invalidAny { |
| 11 | return &invalidAny{baseAny{}, fmt.Errorf("%v not found", path)} |
| 12 | } |
| 13 | |
| 14 | func (any *invalidAny) LastError() error { |
| 15 | return any.err |
| 16 | } |
| 17 | |
| 18 | func (any *invalidAny) ValueType() ValueType { |
| 19 | return InvalidValue |
| 20 | } |
| 21 | |
| 22 | func (any *invalidAny) MustBeValid() Any { |
| 23 | panic(any.err) |
| 24 | } |
| 25 | |
| 26 | func (any *invalidAny) ToBool() bool { |
| 27 | return false |
| 28 | } |
| 29 | |
| 30 | func (any *invalidAny) ToInt() int { |
| 31 | return 0 |
| 32 | } |
| 33 | |
| 34 | func (any *invalidAny) ToInt32() int32 { |
| 35 | return 0 |
| 36 | } |
| 37 | |
| 38 | func (any *invalidAny) ToInt64() int64 { |
| 39 | return 0 |
| 40 | } |
| 41 | |
| 42 | func (any *invalidAny) ToUint() uint { |
| 43 | return 0 |
| 44 | } |
| 45 | |
| 46 | func (any *invalidAny) ToUint32() uint32 { |
| 47 | return 0 |
| 48 | } |
| 49 | |
| 50 | func (any *invalidAny) ToUint64() uint64 { |
| 51 | return 0 |
| 52 | } |
| 53 | |
| 54 | func (any *invalidAny) ToFloat32() float32 { |
| 55 | return 0 |
| 56 | } |
| 57 | |
| 58 | func (any *invalidAny) ToFloat64() float64 { |
| 59 | return 0 |
| 60 | } |
| 61 | |
| 62 | func (any *invalidAny) ToString() string { |
| 63 | return "" |
| 64 | } |
| 65 | |
| 66 | func (any *invalidAny) WriteTo(stream *Stream) { |
| 67 | } |
| 68 | |
| 69 | func (any *invalidAny) Get(path ...interface{}) Any { |
| 70 | if any.err == nil { |
| 71 | return &invalidAny{baseAny{}, fmt.Errorf("get %v from invalid", path)} |
| 72 | } |
| 73 | return &invalidAny{baseAny{}, fmt.Errorf("%v, get %v from invalid", any.err, path)} |
| 74 | } |
| 75 | |
| 76 | func (any *invalidAny) Parse() *Iterator { |
| 77 | return nil |
| 78 | } |
| 79 | |
| 80 | func (any *invalidAny) GetInterface() interface{} { |
| 81 | return nil |
| 82 | } |