Lines Matching refs:FieldCodec
43 /// Factory methods for <see cref="FieldCodec{T}"/>.
45 public static class FieldCodec
54 public static FieldCodec<string> ForString(uint tag)
56 return FieldCodec.ForString(tag, "");
64 public static FieldCodec<ByteString> ForBytes(uint tag)
66 return FieldCodec.ForBytes(tag, ByteString.Empty);
74 public static FieldCodec<bool> ForBool(uint tag)
76 return FieldCodec.ForBool(tag, false);
84 public static FieldCodec<int> ForInt32(uint tag)
86 return FieldCodec.ForInt32(tag, 0);
94 public static FieldCodec<int> ForSInt32(uint tag)
96 return FieldCodec.ForSInt32(tag, 0);
104 public static FieldCodec<uint> ForFixed32(uint tag)
106 return FieldCodec.ForFixed32(tag, 0);
114 public static FieldCodec<int> ForSFixed32(uint tag)
116 return FieldCodec.ForSFixed32(tag, 0);
124 public static FieldCodec<uint> ForUInt32(uint tag)
126 return FieldCodec.ForUInt32(tag, 0);
134 public static FieldCodec<long> ForInt64(uint tag)
136 return FieldCodec.ForInt64(tag, 0);
144 public static FieldCodec<long> ForSInt64(uint tag)
146 return FieldCodec.ForSInt64(tag, 0);
154 public static FieldCodec<ulong> ForFixed64(uint tag)
156 return FieldCodec.ForFixed64(tag, 0);
164 public static FieldCodec<long> ForSFixed64(uint tag)
166 return FieldCodec.ForSFixed64(tag, 0);
174 public static FieldCodec<ulong> ForUInt64(uint tag)
176 return FieldCodec.ForUInt64(tag, 0);
184 public static FieldCodec<float> ForFloat(uint tag)
186 return FieldCodec.ForFloat(tag, 0);
194 public static FieldCodec<double> ForDouble(uint tag)
196 return FieldCodec.ForDouble(tag, 0);
209 public static FieldCodec<T> ForEnum<T>(uint tag, Func<T, int> toInt32, Func<int, T> fromInt32)
211 return FieldCodec.ForEnum(tag, toInt32, fromInt32, default(T));
220 public static FieldCodec<string> ForString(uint tag, string defaultValue)
222 return new FieldCodec<string>((ref ParseContext ctx) => ctx.ReadString(), (ref WriteContext ctx, string value) => ctx.WriteString(value), CodedOutputStream.ComputeStringSize, tag, defaultValue);
231 public static FieldCodec<ByteString> ForBytes(uint tag, ByteString defaultValue)
233 return new FieldCodec<ByteString>((ref ParseContext ctx) => ctx.ReadBytes(), (ref WriteContext ctx, ByteString value) => ctx.WriteBytes(value), CodedOutputStream.ComputeBytesSize, tag, defaultValue);
242 public static FieldCodec<bool> ForBool(uint tag, bool defaultValue)
244 return new FieldCodec<bool>((ref ParseContext ctx) => ctx.ReadBool(), (ref WriteContext ctx, bool value) => ctx.WriteBool(value), CodedOutputStream.BoolSize, tag, defaultValue);
253 public static FieldCodec<int> ForInt32(uint tag, int defaultValue)
255 return new FieldCodec<int>((ref ParseContext ctx) => ctx.ReadInt32(), (ref WriteContext output, int value) => output.WriteInt32(value), CodedOutputStream.ComputeInt32Size, tag, defaultValue);
264 public static FieldCodec<int> ForSInt32(uint tag, int defaultValue)
266 return new FieldCodec<int>((ref ParseContext ctx) => ctx.ReadSInt32(), (ref WriteContext output, int value) => output.WriteSInt32(value), CodedOutputStream.ComputeSInt32Size, tag, defaultValue);
275 public static FieldCodec<uint> ForFixed32(uint tag, uint defaultValue)
277 return new FieldCodec<uint>((ref ParseContext ctx) => ctx.ReadFixed32(), (ref WriteContext output, uint value) => output.WriteFixed32(value), 4, tag, defaultValue);
286 public static FieldCodec<int> ForSFixed32(uint tag, int defaultValue)
288 return new FieldCodec<int>((ref ParseContext ctx) => ctx.ReadSFixed32(), (ref WriteContext output, int value) => output.WriteSFixed32(value), 4, tag, defaultValue);
297 public static FieldCodec<uint> ForUInt32(uint tag, uint defaultValue)
299 return new FieldCodec<uint>((ref ParseContext ctx) => ctx.ReadUInt32(), (ref WriteContext output, uint value) => output.WriteUInt32(value), CodedOutputStream.ComputeUInt32Size, tag, defaultValue);
308 public static FieldCodec<long> ForInt64(uint tag, long defaultValue)
310 return new FieldCodec<long>((ref ParseContext ctx) => ctx.ReadInt64(), (ref WriteContext output, long value) => output.WriteInt64(value), CodedOutputStream.ComputeInt64Size, tag, defaultValue);
319 public static FieldCodec<long> ForSInt64(uint tag, long defaultValue)
321 return new FieldCodec<long>((ref ParseContext ctx) => ctx.ReadSInt64(), (ref WriteContext output, long value) => output.WriteSInt64(value), CodedOutputStream.ComputeSInt64Size, tag, defaultValue);
330 public static FieldCodec<ulong> ForFixed64(uint tag, ulong defaultValue)
332 return new FieldCodec<ulong>((ref ParseContext ctx) => ctx.ReadFixed64(), (ref WriteContext output, ulong value) => output.WriteFixed64(value), 8, tag, defaultValue);
341 public static FieldCodec<long> ForSFixed64(uint tag, long defaultValue)
343 return new FieldCodec<long>((ref ParseContext ctx) => ctx.ReadSFixed64(), (ref WriteContext output, long value) => output.WriteSFixed64(value), 8, tag, defaultValue);
352 public static FieldCodec<ulong> ForUInt64(uint tag, ulong defaultValue)
354 return new FieldCodec<ulong>((ref ParseContext ctx) => ctx.ReadUInt64(), (ref WriteContext output, ulong value) => output.WriteUInt64(value), CodedOutputStream.ComputeUInt64Size, tag, defaultValue);
363 public static FieldCodec<float> ForFloat(uint tag, float defaultValue)
365 return new FieldCodec<float>((ref ParseContext ctx) => ctx.ReadFloat(), (ref WriteContext output, float value) => output.WriteFloat(value), CodedOutputStream.FloatSize, tag, defaultValue);
374 public static FieldCodec<double> ForDouble(uint tag, double defaultValue)
376 return new FieldCodec<double>((ref ParseContext ctx) => ctx.ReadDouble(), (ref WriteContext output, double value) => output.WriteDouble(value), CodedOutputStream.DoubleSize, tag, defaultValue);
390 public static FieldCodec<T> ForEnum<T>(uint tag, Func<T, int> toInt32, Func<int, T> fromInt32, T defaultValue)
392 return new FieldCodec<T>((ref ParseContext ctx) => fromInt32(
404 public static FieldCodec<T> ForMessage<T>(uint tag, MessageParser<T> parser) where T : class, IMessage<T>
406 return new FieldCodec<T>(
449 public static FieldCodec<T> ForGroup<T>(uint startTag, uint endTag, MessageParser<T> parser) where T : class, IMessage<T>
451 return new FieldCodec<T>(
490 public static FieldCodec<T> ForClassWrapper<T>(uint tag) where T : class
493 return new FieldCodec<T>(
507 public static FieldCodec<T?> ForStructWrapper<T>(uint tag) where T : struct
510 return new FieldCodec<T?>(
566 internal static FieldCodec<T> GetCodec<T>()
573 return (FieldCodec<T>) value;
594 internal static T Read<T>(ref ParseContext ctx, FieldCodec<T> codec)
619 internal static void Write<T>(ref WriteContext ctx, T value, FieldCodec<T> codec)
625 internal static int CalculateSize<T>(T value, FieldCodec<T> codec)
651 public sealed class FieldCodec<T>
668 static FieldCodec()
746 internal FieldCodec(
756 internal FieldCodec(
765 internal FieldCodec(
776 internal FieldCodec(