Exemplo n.º 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);
 }
Exemplo n.º 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);
        }
Exemplo n.º 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)));
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 25
0
        internal void WriteRawLittleEndian64(ulong value)
        {
            var span = new Span <byte>(buffer);

            WritingPrimitives.WriteRawLittleEndian64(ref span, ref state, value);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
 }
Exemplo n.º 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);
        }
Exemplo n.º 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)));
 }
Exemplo n.º 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);
 }