• Home
  • Raw
  • Download

Lines Matching +full:is +full:- +full:accessor +full:- +full:descriptor

2 // Protocol Buffers - Google's data interchange format
4 // https://developers.google.com/protocol-buffers/
20 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
47 /// Reflection-based converter from JSON to messages.
51 /// Instances of this class are thread-safe, with no mutable state.
54 /// This is a simple start to get JSON parsing working. As it's reflection-based,
55 /// it's not as quick as baking calls into generated messages - but is a simpler implementation.
56 /// (This code is generally not heavily optimized.)
61 // Note: using 0-9 instead of \d to ensure no non-ASCII digits.
63 …(?<datetime>[0-9]{4}-[01][0-9]-[0-3][0-9]T[012][0-9]:[0-5][0-9]:[0-5][0-9])(?<subseconds>\.[0-9]{1…
64 …tic readonly Regex DurationRegex = new Regex(@"^(?<sign>-)?(?<int>[0-9]{1,12})(?<subseconds>\.[0-9…
67 …private static readonly EnumDescriptor NullValueDescriptor = StructReflection.Descriptor.EnumTypes…
76 …{ Timestamp.Descriptor.FullName, (parser, message, tokenizer) => MergeTimestamp(message, tokenizer…
77 …{ Duration.Descriptor.FullName, (parser, message, tokenizer) => MergeDuration(message, tokenizer.N…
78 …{ Value.Descriptor.FullName, (parser, message, tokenizer) => parser.MergeStructValue(message, toke…
79 { ListValue.Descriptor.FullName, (parser, message, tokenizer) =>
80 …parser.MergeRepeatedField(message, message.Descriptor.Fields[ListValue.ValuesFieldNumber], tokeniz…
81 …{ Struct.Descriptor.FullName, (parser, message, tokenizer) => parser.MergeStruct(message, tokenize…
82 … { Any.Descriptor.FullName, (parser, message, tokenizer) => parser.MergeAny(message, tokenizer) },
83 …{ FieldMask.Descriptor.FullName, (parser, message, tokenizer) => MergeFieldMask(message, tokenizer…
84 { Int32Value.Descriptor.FullName, MergeWrapperField },
85 { Int64Value.Descriptor.FullName, MergeWrapperField },
86 { UInt32Value.Descriptor.FullName, MergeWrapperField },
87 { UInt64Value.Descriptor.FullName, MergeWrapperField },
88 { FloatValue.Descriptor.FullName, MergeWrapperField },
89 { DoubleValue.Descriptor.FullName, MergeWrapperField },
90 { BytesValue.Descriptor.FullName, MergeWrapperField },
91 { StringValue.Descriptor.FullName, MergeWrapperField },
92 { BoolValue.Descriptor.FullName, MergeWrapperField }
99 …parser.MergeField(message, message.Descriptor.Fields[WrappersReflection.WrapperValueFieldNumber], … in MergeWrapperField()
147 … /// that assumption. This is implemented as an LL(1) recursive descent parser over the stream
148 … /// of tokens provided by the tokenizer. This token stream is assumed to be valid JSON, with the
149 … /// tokenizer performing that validation - but not every token stream is valid "protobuf JSON".
157 if (message.Descriptor.IsWellKnownType) in Merge()
160 if (WellKnownTypeHandlers.TryGetValue(message.Descriptor.FullName, out handler)) in Merge()
165 // Well-known types with no special handling continue in the normal way. in Merge()
172 var descriptor = message.Descriptor; in Merge()
173 var jsonFieldMap = descriptor.Fields.ByJsonName(); in Merge()
174 // All the oneof fields we've already accounted for - we can only see each of them once. in Merge()
175 // The set is created lazily to avoid the overhead of creating a set for every message in Merge()
232 field.Accessor.Clear(message); in MergeField()
249 field.Accessor.SetValue(message, value); in MergeField()
261 IList list = (IList) field.Accessor.GetValue(message); in MergeRepeatedField()
281 …// Map fields are always objects, even if the values are well-known types: ParseSingleValue handle… in MergeMapField()
295 IDictionary dictionary = (IDictionary) field.Accessor.GetValue(message); in MergeMapField()
317 field.MessageType.FullName == Value.Descriptor.FullName; in IsGoogleProtobufValueField()
419 /// <param name="descriptor">Descriptor of message type to parse.</param>
422 public IMessage Parse(string json, MessageDescriptor descriptor) in Parse() argument
425 ProtoPreconditions.CheckNotNull(descriptor, nameof(descriptor)); in Parse()
426 return Parse(new StringReader(json), descriptor); in Parse()
433 /// <param name="descriptor">Descriptor of message type to parse.</param>
436 public IMessage Parse(TextReader jsonReader, MessageDescriptor descriptor) in Parse() argument
439 ProtoPreconditions.CheckNotNull(descriptor, nameof(descriptor)); in Parse()
440 IMessage message = descriptor.Parser.CreateTemplate(); in Parse()
448 var fields = message.Descriptor.Fields; in MergeStructValue()
452 fields[Value.NullValueFieldNumber].Accessor.SetValue(message, 0); in MergeStructValue()
455 … fields[Value.StringValueFieldNumber].Accessor.SetValue(message, firstToken.StringValue); in MergeStructValue()
458 … fields[Value.NumberValueFieldNumber].Accessor.SetValue(message, firstToken.NumberValue); in MergeStructValue()
462 …fields[Value.BoolValueFieldNumber].Accessor.SetValue(message, firstToken.Type == JsonToken.TokenTy… in MergeStructValue()
470 field.Accessor.SetValue(message, structMessage); in MergeStructValue()
479 field.Accessor.SetValue(message, list); in MergeStructValue()
496 var field = message.Descriptor.Fields[Struct.FieldsFieldNumber]; in MergeStruct()
537 MessageDescriptor descriptor = settings.TypeRegistry.Find(typeName); in MergeAny()
538 if (descriptor == null) in MergeAny()
540 …throw new InvalidOperationException($"Type registry has no descriptor for type name '{typeName}'"); in MergeAny()
546 var body = descriptor.Parser.CreateTemplate(); in MergeAny()
547 if (descriptor.IsWellKnownType) in MergeAny()
558 message.Descriptor.Fields[Any.TypeUrlFieldNumber].Accessor.SetValue(message, typeUrl); in MergeAny()
559 message.Descriptor.Fields[Any.ValueFieldNumber].Accessor.SetValue(message, data); in MergeAny()
562 …// Well-known types end up in a property called "value" in the JSON. As there's no longer a @type …
563 …// in the given JSON token stream, we should *only* have tokens of start-object, name("value"), th…
564 // itself, and then end-object.
567 var token = tokenizer.Next(); // Definitely start-object; checked in previous method in MergeWellKnownTypeAnyBody()
572 …on($"Expected '{JsonFormatter.AnyWellKnownTypeValueField}' property for well-known type Any body"); in MergeWellKnownTypeAnyBody()
578 …throw new InvalidProtocolBufferException($"Expected end-object token after @type/value for well-kn… in MergeWellKnownTypeAnyBody()
765 else if (text.StartsWith("-0") && text.Length > 2)
789 /// way that Mono parses out-of-range values as infinity.
794 (isNegativeInfinity && text != "-Infinity") || in ValidateInfinityAndNan()
820 "yyyy-MM-dd'T'HH:mm:ss", in MergeTimestamp()
828 // This should always work, as we've got 1-9 digits. in MergeTimestamp()
835 …// This is the amount we need to *subtract* from the local time to get to UTC - hence - => +1 and … in MergeTimestamp()
836 int sign = offset[0] == '-' ? 1 : -1; in MergeTimestamp()
846 …// This is an offset of -00:00, which means "unknown local offset". It makes no sense for a timest… in MergeTimestamp()
856 nanosToAdd = nanosToAdd - Duration.NanosecondsPerSecond; in MergeTimestamp()
868 …message.Descriptor.Fields[Timestamp.SecondsFieldNumber].Accessor.SetValue(message, timestamp.Secon… in MergeTimestamp()
869 … message.Descriptor.Fields[Timestamp.NanosFieldNumber].Accessor.SetValue(message, timestamp.Nanos); in MergeTimestamp()
896 var multiplier = sign == "-" ? -1 : 1; in MergeDuration()
904 // This should always work, as we've got 1-9 digits. in MergeDuration()
912 … message.Descriptor.Fields[Duration.SecondsFieldNumber].Accessor.SetValue(message, seconds); in MergeDuration()
913 … message.Descriptor.Fields[Duration.NanosFieldNumber].Accessor.SetValue(message, nanos); in MergeDuration()
929 …IList messagePaths = (IList) message.Descriptor.Fields[FieldMask.PathsFieldNumber].Accessor.GetVal… in MergeFieldMask()
940 …// Note: this is probably unnecessary now, but currently retained to be as close as possible to the in ToSnakeCase()
950 // Consider when the current character B is capitalized: in ToSnakeCase()
967 … // ascii_tolower, but we already know that c *is* an upper case ASCII character... in ToSnakeCase()
968 builder.Append((char) (c + 'a' - 'A')); in ToSnakeCase()
1007 … /// messages, not collections - so a message within a collection within a message only counts as