示例#1
0
 /// <summary>
 /// Writes a fixed64 field value, without a tag.
 /// </summary>
 /// <param name="value">The value to write</param>
 public void WriteFixed64(ulong value)
 {
     WritingPrimitives.WriteFixed64(ref buffer, ref state, value);
 }
示例#2
0
        /// <summary>
        /// Writes out part of an array of bytes.
        /// </summary>
        internal void WriteRawBytes(byte[] value, int offset, int length)
        {
            var span = new Span <byte>(buffer);

            WritingPrimitives.WriteRawBytes(ref span, ref state, value, offset, length);
        }
示例#3
0
 /// <summary>
 /// Computes the number of bytes that would be needed to encode an
 /// sint32 field, including the tag.
 /// </summary>
 public static int ComputeSInt32Size(int value)
 {
     return(ComputeRawVarint32Size(WritingPrimitives.EncodeZigZag32(value)));
 }
示例#4
0
        /// <summary>
        /// Writes the given single-byte tag directly to the stream.
        /// </summary>
        /// <param name="b1">The encoded tag</param>
        public void WriteRawTag(byte b1)
        {
            var span = new Span <byte>(buffer);

            WritingPrimitives.WriteRawTag(ref span, ref state, b1);
        }
示例#5
0
        /// <summary>
        /// Writes a 32 bit value as a varint. The fast route is taken when
        /// there's enough buffer space left to whizz through without checking
        /// for each byte; otherwise, we resort to calling WriteRawByte each time.
        /// </summary>
        internal void WriteRawVarint32(uint value)
        {
            var span = new Span <byte>(buffer);

            WritingPrimitives.WriteRawVarint32(ref span, ref state, value);
        }
示例#6
0
        /// <summary>
        /// Writes an sint64 value, without a tag, to the stream.
        /// </summary>
        /// <param name="value">The value to write</param>
        public void WriteSInt64(long value)
        {
            var span = new Span <byte>(buffer);

            WritingPrimitives.WriteSInt64(ref span, ref state, value);
        }
示例#7
0
        /// <summary>
        /// Encodes and writes a tag.
        /// </summary>
        /// <param name="fieldNumber">The number of the field to write the tag for</param>
        /// <param name="type">The wire format type of the tag to write</param>
        public void WriteTag(int fieldNumber, WireFormat.WireType type)
        {
            var span = new Span <byte>(buffer);

            WritingPrimitives.WriteTag(ref span, ref state, fieldNumber, type);
        }
示例#8
0
 /// <summary>
 /// Writes an sint64 value, without a tag.
 /// </summary>
 /// <param name="value">The value to write</param>
 public void WriteSInt64(long value)
 {
     WritingPrimitives.WriteSInt64(ref buffer, ref state, value);
 }
示例#9
0
 /// <summary>
 /// Writes a length (in bytes) for length-delimited data.
 /// </summary>
 /// <remarks>
 /// This method simply writes a rawint, but exists for clarity in calling code.
 /// </remarks>
 /// <param name="length">Length value, in bytes.</param>
 public void WriteLength(int length)
 {
     WritingPrimitives.WriteLength(ref buffer, ref state, length);
 }
示例#10
0
 /// <summary>
 /// Writes an enum value, without a tag.
 /// </summary>
 /// <param name="value">The value to write</param>
 public void WriteEnum(int value)
 {
     WritingPrimitives.WriteEnum(ref buffer, ref state, value);
 }
示例#11
0
 /// <summary>
 /// Writes an sint32 value, without a tag.
 /// </summary>
 /// <param name="value">The value to write</param>
 public void WriteSInt32(int value)
 {
     WritingPrimitives.WriteSInt32(ref buffer, ref state, value);
 }
示例#12
0
 /// <summary>
 /// Write a byte string, without a tag, to the stream.
 /// The data is length-prefixed.
 /// </summary>
 /// <param name="value">The value to write</param>
 public void WriteBytes(ByteString value)
 {
     WritingPrimitives.WriteBytes(ref buffer, ref state, value);
 }
示例#13
0
 /// <summary>
 /// Writes a bool field value, without a tag.
 /// </summary>
 /// <param name="value">The value to write</param>
 public void WriteBool(bool value)
 {
     WritingPrimitives.WriteBool(ref buffer, ref state, value);
 }
示例#14
0
 /// <summary>
 /// Writes a fixed32 field value, without a tag.
 /// </summary>
 /// <param name="value">The value to write</param>
 public void WriteFixed32(uint value)
 {
     WritingPrimitives.WriteFixed32(ref buffer, ref state, value);
 }
示例#15
0
        /// <summary>
        /// Write a byte string, without a tag, to the stream.
        /// The data is length-prefixed.
        /// </summary>
        /// <param name="value">The value to write</param>
        public void WriteBytes(ByteString value)
        {
            var span = new Span <byte>(buffer);

            WritingPrimitives.WriteBytes(ref span, ref state, value);
        }
示例#16
0
 /// <summary>
 /// Encodes and writes a tag.
 /// </summary>
 /// <param name="fieldNumber">The number of the field to write the tag for</param>
 /// <param name="type">The wire format type of the tag to write</param>
 public void WriteTag(int fieldNumber, WireFormat.WireType type)
 {
     WritingPrimitives.WriteTag(ref buffer, ref state, fieldNumber, type);
 }
示例#17
0
        /// <summary>
        /// Writes an sfixed32 value, without a tag, to the stream.
        /// </summary>
        /// <param name="value">The value to write.</param>
        public void WriteSFixed32(int value)
        {
            var span = new Span <byte>(buffer);

            WritingPrimitives.WriteSFixed32(ref span, ref state, value);
        }
示例#18
0
 /// <summary>
 /// Writes an already-encoded tag.
 /// </summary>
 /// <param name="tag">The encoded tag</param>
 public void WriteTag(uint tag)
 {
     WritingPrimitives.WriteTag(ref buffer, ref state, tag);
 }
示例#19
0
        /// <summary>
        /// Writes a length (in bytes) for length-delimited data.
        /// </summary>
        /// <remarks>
        /// This method simply writes a rawint, but exists for clarity in calling code.
        /// </remarks>
        /// <param name="length">Length value, in bytes.</param>
        public void WriteLength(int length)
        {
            var span = new Span <byte>(buffer);

            WritingPrimitives.WriteLength(ref span, ref state, length);
        }
示例#20
0
 /// <summary>
 /// Writes the given two-byte tag.
 /// </summary>
 /// <param name="b1">The first byte of the encoded tag</param>
 /// <param name="b2">The second byte of the encoded tag</param>
 public void WriteRawTag(byte b1, byte b2)
 {
     WritingPrimitives.WriteRawTag(ref buffer, ref state, b1, b2);
 }
示例#21
0
        /// <summary>
        /// Writes an already-encoded tag.
        /// </summary>
        /// <param name="tag">The encoded tag</param>
        public void WriteTag(uint tag)
        {
            var span = new Span <byte>(buffer);

            WritingPrimitives.WriteTag(ref span, ref state, tag);
        }
示例#22
0
 /// <summary>
 /// Writes the given five-byte tag.
 /// </summary>
 /// <param name="b1">The first byte of the encoded tag</param>
 /// <param name="b2">The second byte of the encoded tag</param>
 /// <param name="b3">The third byte of the encoded tag</param>
 /// <param name="b4">The fourth byte of the encoded tag</param>
 /// <param name="b5">The fifth byte of the encoded tag</param>
 public void WriteRawTag(byte b1, byte b2, byte b3, byte b4, byte b5)
 {
     WritingPrimitives.WriteRawTag(ref buffer, ref state, b1, b2, b3, b4, b5);
 }
示例#23
0
        /// <summary>
        /// Writes the given five-byte tag directly to the stream.
        /// </summary>
        /// <param name="b1">The first byte of the encoded tag</param>
        /// <param name="b2">The second byte of the encoded tag</param>
        /// <param name="b3">The third byte of the encoded tag</param>
        /// <param name="b4">The fourth byte of the encoded tag</param>
        /// <param name="b5">The fifth byte of the encoded tag</param>
        public void WriteRawTag(byte b1, byte b2, byte b3, byte b4, byte b5)
        {
            var span = new Span <byte>(buffer);

            WritingPrimitives.WriteRawTag(ref span, ref state, b1, b2, b3, b4, b5);
        }
示例#24
0
        /// <summary>
        /// Writes a double field value, without a tag, to the stream.
        /// </summary>
        /// <param name="value">The value to write</param>
        public void WriteDouble(double value)
        {
            var span = new Span <byte>(buffer);

            WritingPrimitives.WriteDouble(ref span, ref state, value);
        }
示例#25
0
        internal void WriteRawLittleEndian64(ulong value)
        {
            var span = new Span <byte>(buffer);

            WritingPrimitives.WriteRawLittleEndian64(ref span, ref state, value);
        }
示例#26
0
        /// <summary>
        /// Writes a float field value, without a tag, to the stream.
        /// </summary>
        /// <param name="value">The value to write</param>
        public void WriteFloat(float value)
        {
            var span = new Span <byte>(buffer);

            WritingPrimitives.WriteFloat(ref span, ref state, value);
        }
示例#27
0
 public static void WriteMessage(ref WriteContext ctx, IMessage value)
 {
     WritingPrimitives.WriteLength(ref ctx.buffer, ref ctx.state, value.CalculateSize());
     WriteRawMessage(ref ctx, value);
 }
示例#28
0
        /// <summary>
        /// Writes a bool field value, without a tag, to the stream.
        /// </summary>
        /// <param name="value">The value to write</param>
        public void WriteBool(bool value)
        {
            var span = new Span <byte>(buffer);

            WritingPrimitives.WriteBool(ref span, ref state, value);
        }
示例#29
0
 /// <summary>
 /// Computes the number of bytes that would be needed to encode an
 /// sint64 field, including the tag.
 /// </summary>
 public static int ComputeSInt64Size(long value)
 {
     return(ComputeRawVarint64Size(WritingPrimitives.EncodeZigZag64(value)));
 }
示例#30
0
 /// <summary>
 /// Writes a float field value, without a tag.
 /// </summary>
 /// <param name="value">The value to write</param>
 public void WriteFloat(float value)
 {
     WritingPrimitives.WriteFloat(ref buffer, ref state, value);
 }