Remove BPA from Makefile
[icn.git] / cmd / bpa-operator / vendor / k8s.io / apimachinery / pkg / api / resource / quantity_proto.go
1 /*
2 Copyright 2015 The Kubernetes Authors.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8     http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17 package resource
18
19 import (
20         "fmt"
21         "io"
22
23         "github.com/gogo/protobuf/proto"
24 )
25
26 var _ proto.Sizer = &Quantity{}
27
28 func (m *Quantity) Marshal() (data []byte, err error) {
29         size := m.Size()
30         data = make([]byte, size)
31         n, err := m.MarshalTo(data)
32         if err != nil {
33                 return nil, err
34         }
35         return data[:n], nil
36 }
37
38 // MarshalTo is a customized version of the generated Protobuf unmarshaler for a struct
39 // with a single string field.
40 func (m *Quantity) MarshalTo(data []byte) (int, error) {
41         var i int
42         _ = i
43         var l int
44         _ = l
45
46         data[i] = 0xa
47         i++
48         // BEGIN CUSTOM MARSHAL
49         out := m.String()
50         i = encodeVarintGenerated(data, i, uint64(len(out)))
51         i += copy(data[i:], out)
52         // END CUSTOM MARSHAL
53
54         return i, nil
55 }
56
57 func encodeVarintGenerated(data []byte, offset int, v uint64) int {
58         for v >= 1<<7 {
59                 data[offset] = uint8(v&0x7f | 0x80)
60                 v >>= 7
61                 offset++
62         }
63         data[offset] = uint8(v)
64         return offset + 1
65 }
66
67 func (m *Quantity) Size() (n int) {
68         var l int
69         _ = l
70
71         // BEGIN CUSTOM SIZE
72         l = len(m.String())
73         // END CUSTOM SIZE
74
75         n += 1 + l + sovGenerated(uint64(l))
76         return n
77 }
78
79 func sovGenerated(x uint64) (n int) {
80         for {
81                 n++
82                 x >>= 7
83                 if x == 0 {
84                         break
85                 }
86         }
87         return n
88 }
89
90 // Unmarshal is a customized version of the generated Protobuf unmarshaler for a struct
91 // with a single string field.
92 func (m *Quantity) Unmarshal(data []byte) error {
93         l := len(data)
94         iNdEx := 0
95         for iNdEx < l {
96                 preIndex := iNdEx
97                 var wire uint64
98                 for shift := uint(0); ; shift += 7 {
99                         if shift >= 64 {
100                                 return ErrIntOverflowGenerated
101                         }
102                         if iNdEx >= l {
103                                 return io.ErrUnexpectedEOF
104                         }
105                         b := data[iNdEx]
106                         iNdEx++
107                         wire |= (uint64(b) & 0x7F) << shift
108                         if b < 0x80 {
109                                 break
110                         }
111                 }
112                 fieldNum := int32(wire >> 3)
113                 wireType := int(wire & 0x7)
114                 if wireType == 4 {
115                         return fmt.Errorf("proto: Quantity: wiretype end group for non-group")
116                 }
117                 if fieldNum <= 0 {
118                         return fmt.Errorf("proto: Quantity: illegal tag %d (wire type %d)", fieldNum, wire)
119                 }
120                 switch fieldNum {
121                 case 1:
122                         if wireType != 2 {
123                                 return fmt.Errorf("proto: wrong wireType = %d for field String_", wireType)
124                         }
125                         var stringLen uint64
126                         for shift := uint(0); ; shift += 7 {
127                                 if shift >= 64 {
128                                         return ErrIntOverflowGenerated
129                                 }
130                                 if iNdEx >= l {
131                                         return io.ErrUnexpectedEOF
132                                 }
133                                 b := data[iNdEx]
134                                 iNdEx++
135                                 stringLen |= (uint64(b) & 0x7F) << shift
136                                 if b < 0x80 {
137                                         break
138                                 }
139                         }
140                         intStringLen := int(stringLen)
141                         if intStringLen < 0 {
142                                 return ErrInvalidLengthGenerated
143                         }
144                         postIndex := iNdEx + intStringLen
145                         if postIndex > l {
146                                 return io.ErrUnexpectedEOF
147                         }
148                         s := string(data[iNdEx:postIndex])
149
150                         // BEGIN CUSTOM DECODE
151                         p, err := ParseQuantity(s)
152                         if err != nil {
153                                 return err
154                         }
155                         *m = p
156                         // END CUSTOM DECODE
157
158                         iNdEx = postIndex
159                 default:
160                         iNdEx = preIndex
161                         skippy, err := skipGenerated(data[iNdEx:])
162                         if err != nil {
163                                 return err
164                         }
165                         if skippy < 0 {
166                                 return ErrInvalidLengthGenerated
167                         }
168                         if (iNdEx + skippy) > l {
169                                 return io.ErrUnexpectedEOF
170                         }
171                         iNdEx += skippy
172                 }
173         }
174
175         if iNdEx > l {
176                 return io.ErrUnexpectedEOF
177         }
178         return nil
179 }
180
181 func skipGenerated(data []byte) (n int, err error) {
182         l := len(data)
183         iNdEx := 0
184         for iNdEx < l {
185                 var wire uint64
186                 for shift := uint(0); ; shift += 7 {
187                         if shift >= 64 {
188                                 return 0, ErrIntOverflowGenerated
189                         }
190                         if iNdEx >= l {
191                                 return 0, io.ErrUnexpectedEOF
192                         }
193                         b := data[iNdEx]
194                         iNdEx++
195                         wire |= (uint64(b) & 0x7F) << shift
196                         if b < 0x80 {
197                                 break
198                         }
199                 }
200                 wireType := int(wire & 0x7)
201                 switch wireType {
202                 case 0:
203                         for shift := uint(0); ; shift += 7 {
204                                 if shift >= 64 {
205                                         return 0, ErrIntOverflowGenerated
206                                 }
207                                 if iNdEx >= l {
208                                         return 0, io.ErrUnexpectedEOF
209                                 }
210                                 iNdEx++
211                                 if data[iNdEx-1] < 0x80 {
212                                         break
213                                 }
214                         }
215                         return iNdEx, nil
216                 case 1:
217                         iNdEx += 8
218                         return iNdEx, nil
219                 case 2:
220                         var length int
221                         for shift := uint(0); ; shift += 7 {
222                                 if shift >= 64 {
223                                         return 0, ErrIntOverflowGenerated
224                                 }
225                                 if iNdEx >= l {
226                                         return 0, io.ErrUnexpectedEOF
227                                 }
228                                 b := data[iNdEx]
229                                 iNdEx++
230                                 length |= (int(b) & 0x7F) << shift
231                                 if b < 0x80 {
232                                         break
233                                 }
234                         }
235                         iNdEx += length
236                         if length < 0 {
237                                 return 0, ErrInvalidLengthGenerated
238                         }
239                         return iNdEx, nil
240                 case 3:
241                         for {
242                                 var innerWire uint64
243                                 var start int = iNdEx
244                                 for shift := uint(0); ; shift += 7 {
245                                         if shift >= 64 {
246                                                 return 0, ErrIntOverflowGenerated
247                                         }
248                                         if iNdEx >= l {
249                                                 return 0, io.ErrUnexpectedEOF
250                                         }
251                                         b := data[iNdEx]
252                                         iNdEx++
253                                         innerWire |= (uint64(b) & 0x7F) << shift
254                                         if b < 0x80 {
255                                                 break
256                                         }
257                                 }
258                                 innerWireType := int(innerWire & 0x7)
259                                 if innerWireType == 4 {
260                                         break
261                                 }
262                                 next, err := skipGenerated(data[start:])
263                                 if err != nil {
264                                         return 0, err
265                                 }
266                                 iNdEx = start + next
267                         }
268                         return iNdEx, nil
269                 case 4:
270                         return iNdEx, nil
271                 case 5:
272                         iNdEx += 4
273                         return iNdEx, nil
274                 default:
275                         return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
276                 }
277         }
278         panic("unreachable")
279 }
280
281 var (
282         ErrInvalidLengthGenerated = fmt.Errorf("proto: negative length found during unmarshaling")
283         ErrIntOverflowGenerated   = fmt.Errorf("proto: integer overflow")
284 )