github.com/imannamdari/v2ray-core/v5@v5.0.5/infra/conf/v2jsonpb/followermap.go (about)

     1  package v2jsonpb
     2  
     3  import "google.golang.org/protobuf/reflect/protoreflect"
     4  
     5  type V2JsonProtobufMapFollower struct {
     6  	protoreflect.Map
     7  	ValueKind protoreflect.FieldDescriptor
     8  }
     9  
    10  func (v V2JsonProtobufMapFollower) Len() int {
    11  	panic("implement me")
    12  }
    13  
    14  func (v V2JsonProtobufMapFollower) Range(f func(protoreflect.MapKey, protoreflect.Value) bool) {
    15  	v.Map.Range(func(key protoreflect.MapKey, value protoreflect.Value) bool {
    16  		return followMapValue(v.ValueKind, value, key, f)
    17  	})
    18  }
    19  
    20  func (v V2JsonProtobufMapFollower) Has(key protoreflect.MapKey) bool {
    21  	return v.Map.Has(key)
    22  }
    23  
    24  func (v V2JsonProtobufMapFollower) Clear(key protoreflect.MapKey) {
    25  	panic("implement me")
    26  }
    27  
    28  func (v V2JsonProtobufMapFollower) Get(key protoreflect.MapKey) protoreflect.Value {
    29  	panic("implement me")
    30  }
    31  
    32  func (v V2JsonProtobufMapFollower) Set(key protoreflect.MapKey, value protoreflect.Value) {
    33  	v.Map.Set(key, value)
    34  }
    35  
    36  func (v V2JsonProtobufMapFollower) Mutable(key protoreflect.MapKey) protoreflect.Value {
    37  	panic("implement me")
    38  }
    39  
    40  func (v V2JsonProtobufMapFollower) NewValue() protoreflect.Value {
    41  	newelement := v.Map.NewValue()
    42  	return protoreflect.ValueOfMessage(&V2JsonProtobufFollower{newelement.Message()})
    43  }
    44  
    45  func (v V2JsonProtobufMapFollower) IsValid() bool {
    46  	panic("implement me")
    47  }
    48  
    49  func followMapValue(descriptor protoreflect.FieldDescriptor, value protoreflect.Value, mapkey protoreflect.MapKey, f func(protoreflect.MapKey, protoreflect.Value) bool) bool {
    50  	if descriptor.Kind() == protoreflect.MessageKind {
    51  		if descriptor.IsList() {
    52  			value2 := protoreflect.ValueOfList(V2JsonProtobufListFollower{value.List()})
    53  			return f(mapkey, value2)
    54  		}
    55  		if descriptor.IsMap() {
    56  			value2 := protoreflect.ValueOfMap(V2JsonProtobufMapFollower{value.Map(), descriptor.MapValue()})
    57  			return f(mapkey, value2)
    58  		}
    59  		value2 := protoreflect.ValueOfMessage(&V2JsonProtobufFollower{value.Message()})
    60  		return f(mapkey, value2)
    61  	}
    62  
    63  	return f(mapkey, value)
    64  }