aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/json-iterator/go/any_number.go
diff options
context:
space:
mode:
authorLibravatar Rutger Broekhoff2023-12-29 21:31:53 +0100
committerLibravatar Rutger Broekhoff2023-12-29 21:31:53 +0100
commit404aeae4545d2426c089a5f8d5e82dae56f5212b (patch)
tree2d84e00af272b39fc04f3795ae06bc48970e57b5 /vendor/github.com/json-iterator/go/any_number.go
parent209d8b0187ed025dec9ac149ebcced3462877bff (diff)
downloadgitolfs3-404aeae4545d2426c089a5f8d5e82dae56f5212b.tar.gz
gitolfs3-404aeae4545d2426c089a5f8d5e82dae56f5212b.zip
Make Nix builds work
Diffstat (limited to 'vendor/github.com/json-iterator/go/any_number.go')
-rw-r--r--vendor/github.com/json-iterator/go/any_number.go123
1 files changed, 123 insertions, 0 deletions
diff --git a/vendor/github.com/json-iterator/go/any_number.go b/vendor/github.com/json-iterator/go/any_number.go
new file mode 100644
index 0000000..9d1e901
--- /dev/null
+++ b/vendor/github.com/json-iterator/go/any_number.go
@@ -0,0 +1,123 @@
1package jsoniter
2
3import (
4 "io"
5 "unsafe"
6)
7
8type numberLazyAny struct {
9 baseAny
10 cfg *frozenConfig
11 buf []byte
12 err error
13}
14
15func (any *numberLazyAny) ValueType() ValueType {
16 return NumberValue
17}
18
19func (any *numberLazyAny) MustBeValid() Any {
20 return any
21}
22
23func (any *numberLazyAny) LastError() error {
24 return any.err
25}
26
27func (any *numberLazyAny) ToBool() bool {
28 return any.ToFloat64() != 0
29}
30
31func (any *numberLazyAny) ToInt() int {
32 iter := any.cfg.BorrowIterator(any.buf)
33 defer any.cfg.ReturnIterator(iter)
34 val := iter.ReadInt()
35 if iter.Error != nil && iter.Error != io.EOF {
36 any.err = iter.Error
37 }
38 return val
39}
40
41func (any *numberLazyAny) ToInt32() int32 {
42 iter := any.cfg.BorrowIterator(any.buf)
43 defer any.cfg.ReturnIterator(iter)
44 val := iter.ReadInt32()
45 if iter.Error != nil && iter.Error != io.EOF {
46 any.err = iter.Error
47 }
48 return val
49}
50
51func (any *numberLazyAny) ToInt64() int64 {
52 iter := any.cfg.BorrowIterator(any.buf)
53 defer any.cfg.ReturnIterator(iter)
54 val := iter.ReadInt64()
55 if iter.Error != nil && iter.Error != io.EOF {
56 any.err = iter.Error
57 }
58 return val
59}
60
61func (any *numberLazyAny) ToUint() uint {
62 iter := any.cfg.BorrowIterator(any.buf)
63 defer any.cfg.ReturnIterator(iter)
64 val := iter.ReadUint()
65 if iter.Error != nil && iter.Error != io.EOF {
66 any.err = iter.Error
67 }
68 return val
69}
70
71func (any *numberLazyAny) ToUint32() uint32 {
72 iter := any.cfg.BorrowIterator(any.buf)
73 defer any.cfg.ReturnIterator(iter)
74 val := iter.ReadUint32()
75 if iter.Error != nil && iter.Error != io.EOF {
76 any.err = iter.Error
77 }
78 return val
79}
80
81func (any *numberLazyAny) ToUint64() uint64 {
82 iter := any.cfg.BorrowIterator(any.buf)
83 defer any.cfg.ReturnIterator(iter)
84 val := iter.ReadUint64()
85 if iter.Error != nil && iter.Error != io.EOF {
86 any.err = iter.Error
87 }
88 return val
89}
90
91func (any *numberLazyAny) ToFloat32() float32 {
92 iter := any.cfg.BorrowIterator(any.buf)
93 defer any.cfg.ReturnIterator(iter)
94 val := iter.ReadFloat32()
95 if iter.Error != nil && iter.Error != io.EOF {
96 any.err = iter.Error
97 }
98 return val
99}
100
101func (any *numberLazyAny) ToFloat64() float64 {
102 iter := any.cfg.BorrowIterator(any.buf)
103 defer any.cfg.ReturnIterator(iter)
104 val := iter.ReadFloat64()
105 if iter.Error != nil && iter.Error != io.EOF {
106 any.err = iter.Error
107 }
108 return val
109}
110
111func (any *numberLazyAny) ToString() string {
112 return *(*string)(unsafe.Pointer(&any.buf))
113}
114
115func (any *numberLazyAny) WriteTo(stream *Stream) {
116 stream.Write(any.buf)
117}
118
119func (any *numberLazyAny) GetInterface() interface{} {
120 iter := any.cfg.BorrowIterator(any.buf)
121 defer any.cfg.ReturnIterator(iter)
122 return iter.Read()
123}