2 Copyright 2015 The Kubernetes Authors.
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
8 http://www.apache.org/licenses/LICENSE-2.0
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.
23 "github.com/gogo/protobuf/proto"
26 var _ proto.Sizer = &Quantity{}
28 func (m *Quantity) Marshal() (data []byte, err error) {
30 data = make([]byte, size)
31 n, err := m.MarshalTo(data)
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) {
48 // BEGIN CUSTOM MARSHAL
50 i = encodeVarintGenerated(data, i, uint64(len(out)))
51 i += copy(data[i:], out)
57 func encodeVarintGenerated(data []byte, offset int, v uint64) int {
59 data[offset] = uint8(v&0x7f | 0x80)
63 data[offset] = uint8(v)
67 func (m *Quantity) Size() (n int) {
75 n += 1 + l + sovGenerated(uint64(l))
79 func sovGenerated(x uint64) (n int) {
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 {
98 for shift := uint(0); ; shift += 7 {
100 return ErrIntOverflowGenerated
103 return io.ErrUnexpectedEOF
107 wire |= (uint64(b) & 0x7F) << shift
112 fieldNum := int32(wire >> 3)
113 wireType := int(wire & 0x7)
115 return fmt.Errorf("proto: Quantity: wiretype end group for non-group")
118 return fmt.Errorf("proto: Quantity: illegal tag %d (wire type %d)", fieldNum, wire)
123 return fmt.Errorf("proto: wrong wireType = %d for field String_", wireType)
126 for shift := uint(0); ; shift += 7 {
128 return ErrIntOverflowGenerated
131 return io.ErrUnexpectedEOF
135 stringLen |= (uint64(b) & 0x7F) << shift
140 intStringLen := int(stringLen)
141 if intStringLen < 0 {
142 return ErrInvalidLengthGenerated
144 postIndex := iNdEx + intStringLen
146 return io.ErrUnexpectedEOF
148 s := string(data[iNdEx:postIndex])
150 // BEGIN CUSTOM DECODE
151 p, err := ParseQuantity(s)
161 skippy, err := skipGenerated(data[iNdEx:])
166 return ErrInvalidLengthGenerated
168 if (iNdEx + skippy) > l {
169 return io.ErrUnexpectedEOF
176 return io.ErrUnexpectedEOF
181 func skipGenerated(data []byte) (n int, err error) {
186 for shift := uint(0); ; shift += 7 {
188 return 0, ErrIntOverflowGenerated
191 return 0, io.ErrUnexpectedEOF
195 wire |= (uint64(b) & 0x7F) << shift
200 wireType := int(wire & 0x7)
203 for shift := uint(0); ; shift += 7 {
205 return 0, ErrIntOverflowGenerated
208 return 0, io.ErrUnexpectedEOF
211 if data[iNdEx-1] < 0x80 {
221 for shift := uint(0); ; shift += 7 {
223 return 0, ErrIntOverflowGenerated
226 return 0, io.ErrUnexpectedEOF
230 length |= (int(b) & 0x7F) << shift
237 return 0, ErrInvalidLengthGenerated
243 var start int = iNdEx
244 for shift := uint(0); ; shift += 7 {
246 return 0, ErrIntOverflowGenerated
249 return 0, io.ErrUnexpectedEOF
253 innerWire |= (uint64(b) & 0x7F) << shift
258 innerWireType := int(innerWire & 0x7)
259 if innerWireType == 4 {
262 next, err := skipGenerated(data[start:])
275 return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
282 ErrInvalidLengthGenerated = fmt.Errorf("proto: negative length found during unmarshaling")
283 ErrIntOverflowGenerated = fmt.Errorf("proto: integer overflow")