github.com/gogo/protobuf@v1.3.2/test/mapdefaults/map.pb.go (about) 1 // Code generated by protoc-gen-gogo. DO NOT EDIT. 2 // source: map.proto 3 4 /* 5 Package mapdefaults is a generated protocol buffer package. 6 7 It is generated from these files: 8 map.proto 9 10 It has these top-level messages: 11 MapTest 12 */ 13 package mapdefaults 14 15 import proto "github.com/gogo/protobuf/proto" 16 import fmt "fmt" 17 import math "math" 18 19 import io "io" 20 21 // Reference imports to suppress errors if they are not otherwise used. 22 var _ = proto.Marshal 23 var _ = fmt.Errorf 24 var _ = math.Inf 25 26 // This is a compile-time assertion to ensure that this generated file 27 // is compatible with the proto package it is being compiled against. 28 // A compilation error at this line likely means your copy of the 29 // proto package needs to be updated. 30 const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package 31 32 type MapTest struct { 33 StrStr map[string]string `protobuf:"bytes,1,rep,name=str_str,json=strStr" json:"str_str,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` 34 } 35 36 func (m *MapTest) Reset() { *m = MapTest{} } 37 func (m *MapTest) String() string { return proto.CompactTextString(m) } 38 func (*MapTest) ProtoMessage() {} 39 func (*MapTest) Descriptor() ([]byte, []int) { return fileDescriptorMap, []int{0} } 40 41 func (m *MapTest) GetStrStr() map[string]string { 42 if m != nil { 43 return m.StrStr 44 } 45 return nil 46 } 47 48 func init() { 49 proto.RegisterType((*MapTest)(nil), "mapdefaults.MapTest") 50 } 51 func (m *MapTest) Marshal() (dAtA []byte, err error) { 52 size := m.Size() 53 dAtA = make([]byte, size) 54 n, err := m.MarshalTo(dAtA) 55 if err != nil { 56 return nil, err 57 } 58 return dAtA[:n], nil 59 } 60 61 func (m *MapTest) MarshalTo(dAtA []byte) (int, error) { 62 var i int 63 _ = i 64 var l int 65 _ = l 66 if len(m.StrStr) > 0 { 67 for k := range m.StrStr { 68 dAtA[i] = 0xa 69 i++ 70 v := m.StrStr[k] 71 mapSize := 1 + len(k) + sovMap(uint64(len(k))) + 1 + len(v) + sovMap(uint64(len(v))) 72 i = encodeVarintMap(dAtA, i, uint64(mapSize)) 73 dAtA[i] = 0xa 74 i++ 75 i = encodeVarintMap(dAtA, i, uint64(len(k))) 76 i += copy(dAtA[i:], k) 77 dAtA[i] = 0x12 78 i++ 79 i = encodeVarintMap(dAtA, i, uint64(len(v))) 80 i += copy(dAtA[i:], v) 81 } 82 } 83 return i, nil 84 } 85 86 func encodeFixed64Map(dAtA []byte, offset int, v uint64) int { 87 dAtA[offset] = uint8(v) 88 dAtA[offset+1] = uint8(v >> 8) 89 dAtA[offset+2] = uint8(v >> 16) 90 dAtA[offset+3] = uint8(v >> 24) 91 dAtA[offset+4] = uint8(v >> 32) 92 dAtA[offset+5] = uint8(v >> 40) 93 dAtA[offset+6] = uint8(v >> 48) 94 dAtA[offset+7] = uint8(v >> 56) 95 return offset + 8 96 } 97 func encodeFixed32Map(dAtA []byte, offset int, v uint32) int { 98 dAtA[offset] = uint8(v) 99 dAtA[offset+1] = uint8(v >> 8) 100 dAtA[offset+2] = uint8(v >> 16) 101 dAtA[offset+3] = uint8(v >> 24) 102 return offset + 4 103 } 104 func encodeVarintMap(dAtA []byte, offset int, v uint64) int { 105 for v >= 1<<7 { 106 dAtA[offset] = uint8(v&0x7f | 0x80) 107 v >>= 7 108 offset++ 109 } 110 dAtA[offset] = uint8(v) 111 return offset + 1 112 } 113 func (m *MapTest) Size() (n int) { 114 var l int 115 _ = l 116 if len(m.StrStr) > 0 { 117 for k, v := range m.StrStr { 118 _ = k 119 _ = v 120 mapEntrySize := 1 + len(k) + sovMap(uint64(len(k))) + 1 + len(v) + sovMap(uint64(len(v))) 121 n += mapEntrySize + 1 + sovMap(uint64(mapEntrySize)) 122 } 123 } 124 return n 125 } 126 127 func sovMap(x uint64) (n int) { 128 for { 129 n++ 130 x >>= 7 131 if x == 0 { 132 break 133 } 134 } 135 return n 136 } 137 func sozMap(x uint64) (n int) { 138 return sovMap(uint64((x << 1) ^ uint64((int64(x) >> 63)))) 139 } 140 func (m *MapTest) Unmarshal(dAtA []byte) error { 141 l := len(dAtA) 142 iNdEx := 0 143 for iNdEx < l { 144 preIndex := iNdEx 145 var wire uint64 146 for shift := uint(0); ; shift += 7 { 147 if shift >= 64 { 148 return ErrIntOverflowMap 149 } 150 if iNdEx >= l { 151 return io.ErrUnexpectedEOF 152 } 153 b := dAtA[iNdEx] 154 iNdEx++ 155 wire |= (uint64(b) & 0x7F) << shift 156 if b < 0x80 { 157 break 158 } 159 } 160 fieldNum := int32(wire >> 3) 161 wireType := int(wire & 0x7) 162 if wireType == 4 { 163 return fmt.Errorf("proto: MapTest: wiretype end group for non-group") 164 } 165 if fieldNum <= 0 { 166 return fmt.Errorf("proto: MapTest: illegal tag %d (wire type %d)", fieldNum, wire) 167 } 168 switch fieldNum { 169 case 1: 170 if wireType != 2 { 171 return fmt.Errorf("proto: wrong wireType = %d for field StrStr", wireType) 172 } 173 var msglen int 174 for shift := uint(0); ; shift += 7 { 175 if shift >= 64 { 176 return ErrIntOverflowMap 177 } 178 if iNdEx >= l { 179 return io.ErrUnexpectedEOF 180 } 181 b := dAtA[iNdEx] 182 iNdEx++ 183 msglen |= (int(b) & 0x7F) << shift 184 if b < 0x80 { 185 break 186 } 187 } 188 if msglen < 0 { 189 return ErrInvalidLengthMap 190 } 191 postIndex := iNdEx + msglen 192 if postIndex > l { 193 return io.ErrUnexpectedEOF 194 } 195 if m.StrStr == nil { 196 m.StrStr = make(map[string]string) 197 } 198 var mapkey string 199 var mapvalue string 200 for iNdEx < postIndex { 201 var wire uint64 202 for shift := uint(0); ; shift += 7 { 203 if shift >= 64 { 204 return ErrIntOverflowMap 205 } 206 if iNdEx >= l { 207 return io.ErrUnexpectedEOF 208 } 209 b := dAtA[iNdEx] 210 iNdEx++ 211 wire |= (uint64(b) & 0x7F) << shift 212 if b < 0x80 { 213 break 214 } 215 } 216 fieldNum := int32(wire >> 3) 217 if fieldNum == 1 { 218 var stringLenmapkey uint64 219 for shift := uint(0); ; shift += 7 { 220 if shift >= 64 { 221 return ErrIntOverflowMap 222 } 223 if iNdEx >= l { 224 return io.ErrUnexpectedEOF 225 } 226 b := dAtA[iNdEx] 227 iNdEx++ 228 stringLenmapkey |= (uint64(b) & 0x7F) << shift 229 if b < 0x80 { 230 break 231 } 232 } 233 intStringLenmapkey := int(stringLenmapkey) 234 if intStringLenmapkey < 0 { 235 return ErrInvalidLengthMap 236 } 237 postStringIndexmapkey := iNdEx + intStringLenmapkey 238 if postStringIndexmapkey > l { 239 return io.ErrUnexpectedEOF 240 } 241 mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) 242 iNdEx = postStringIndexmapkey 243 } else { 244 var stringLenmapvalue uint64 245 for shift := uint(0); ; shift += 7 { 246 if shift >= 64 { 247 return ErrIntOverflowMap 248 } 249 if iNdEx >= l { 250 return io.ErrUnexpectedEOF 251 } 252 b := dAtA[iNdEx] 253 iNdEx++ 254 stringLenmapvalue |= (uint64(b) & 0x7F) << shift 255 if b < 0x80 { 256 break 257 } 258 } 259 intStringLenmapvalue := int(stringLenmapvalue) 260 if intStringLenmapvalue < 0 { 261 return ErrInvalidLengthMap 262 } 263 postStringIndexmapvalue := iNdEx + intStringLenmapvalue 264 if postStringIndexmapvalue > l { 265 return io.ErrUnexpectedEOF 266 } 267 mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue]) 268 iNdEx = postStringIndexmapvalue 269 } 270 } 271 m.StrStr[mapkey] = mapvalue 272 iNdEx = postIndex 273 default: 274 iNdEx = preIndex 275 skippy, err := skipMap(dAtA[iNdEx:]) 276 if err != nil { 277 return err 278 } 279 if skippy < 0 { 280 return ErrInvalidLengthMap 281 } 282 if (iNdEx + skippy) > l { 283 return io.ErrUnexpectedEOF 284 } 285 iNdEx += skippy 286 } 287 } 288 289 if iNdEx > l { 290 return io.ErrUnexpectedEOF 291 } 292 return nil 293 } 294 func skipMap(dAtA []byte) (n int, err error) { 295 l := len(dAtA) 296 iNdEx := 0 297 for iNdEx < l { 298 var wire uint64 299 for shift := uint(0); ; shift += 7 { 300 if shift >= 64 { 301 return 0, ErrIntOverflowMap 302 } 303 if iNdEx >= l { 304 return 0, io.ErrUnexpectedEOF 305 } 306 b := dAtA[iNdEx] 307 iNdEx++ 308 wire |= (uint64(b) & 0x7F) << shift 309 if b < 0x80 { 310 break 311 } 312 } 313 wireType := int(wire & 0x7) 314 switch wireType { 315 case 0: 316 for shift := uint(0); ; shift += 7 { 317 if shift >= 64 { 318 return 0, ErrIntOverflowMap 319 } 320 if iNdEx >= l { 321 return 0, io.ErrUnexpectedEOF 322 } 323 iNdEx++ 324 if dAtA[iNdEx-1] < 0x80 { 325 break 326 } 327 } 328 return iNdEx, nil 329 case 1: 330 iNdEx += 8 331 return iNdEx, nil 332 case 2: 333 var length int 334 for shift := uint(0); ; shift += 7 { 335 if shift >= 64 { 336 return 0, ErrIntOverflowMap 337 } 338 if iNdEx >= l { 339 return 0, io.ErrUnexpectedEOF 340 } 341 b := dAtA[iNdEx] 342 iNdEx++ 343 length |= (int(b) & 0x7F) << shift 344 if b < 0x80 { 345 break 346 } 347 } 348 iNdEx += length 349 if length < 0 { 350 return 0, ErrInvalidLengthMap 351 } 352 return iNdEx, nil 353 case 3: 354 for { 355 var innerWire uint64 356 var start int = iNdEx 357 for shift := uint(0); ; shift += 7 { 358 if shift >= 64 { 359 return 0, ErrIntOverflowMap 360 } 361 if iNdEx >= l { 362 return 0, io.ErrUnexpectedEOF 363 } 364 b := dAtA[iNdEx] 365 iNdEx++ 366 innerWire |= (uint64(b) & 0x7F) << shift 367 if b < 0x80 { 368 break 369 } 370 } 371 innerWireType := int(innerWire & 0x7) 372 if innerWireType == 4 { 373 break 374 } 375 next, err := skipMap(dAtA[start:]) 376 if err != nil { 377 return 0, err 378 } 379 iNdEx = start + next 380 } 381 return iNdEx, nil 382 case 4: 383 return iNdEx, nil 384 case 5: 385 iNdEx += 4 386 return iNdEx, nil 387 default: 388 return 0, fmt.Errorf("proto: illegal wireType %d", wireType) 389 } 390 } 391 panic("unreachable") 392 } 393 394 var ( 395 ErrInvalidLengthMap = fmt.Errorf("proto: negative length found during unmarshaling") 396 ErrIntOverflowMap = fmt.Errorf("proto: integer overflow") 397 ) 398 399 func init() { proto.RegisterFile("map.proto", fileDescriptorMap) } 400 401 var fileDescriptorMap = []byte{ 402 // 161 bytes of a gzipped FileDescriptorProto 403 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0xcc, 0x4d, 0x2c, 0xd0, 404 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xce, 0x4d, 0x2c, 0x48, 0x49, 0x4d, 0x4b, 0x2c, 0xcd, 405 0x29, 0x29, 0x56, 0xaa, 0xe7, 0x62, 0xf7, 0x4d, 0x2c, 0x08, 0x49, 0x2d, 0x2e, 0x11, 0xb2, 0xe4, 406 0x62, 0x2f, 0x2e, 0x29, 0x8a, 0x2f, 0x2e, 0x29, 0x92, 0x60, 0x54, 0x60, 0xd6, 0xe0, 0x36, 0x52, 407 0xd0, 0x43, 0x52, 0xa9, 0x07, 0x55, 0xa6, 0x17, 0x5c, 0x52, 0x14, 0x5c, 0x52, 0xe4, 0x9a, 0x57, 408 0x52, 0x54, 0x19, 0xc4, 0x56, 0x0c, 0xe6, 0x48, 0x59, 0x72, 0x71, 0x23, 0x09, 0x0b, 0x09, 0x70, 409 0x31, 0x67, 0xa7, 0x56, 0x4a, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x06, 0x81, 0x98, 0x42, 0x22, 0x5c, 410 0xac, 0x65, 0x89, 0x39, 0xa5, 0xa9, 0x12, 0x4c, 0x60, 0x31, 0x08, 0xc7, 0x8a, 0xc9, 0x82, 0xd1, 411 0x89, 0xe7, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x4c, 0x62, 412 0x03, 0x3b, 0xd1, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x38, 0xe5, 0x24, 0x74, 0xaf, 0x00, 0x00, 413 0x00, 414 }