Esempio n. 1
0
    /// <summary>
    /// Unsigned VarInt format
    /// </summary>
    public static void WriteUInt64(CitoStream stream, int val)
    {
        byte[] buffer = new byte[10];
        int    count  = 0;

        while (true)
        {
#if !CITO
            buffer[count] = (byte)(val & 0x7F);
#else
            buffer[count] = (val & 0x7F).LowByte;
#endif
            val = ProtoPlatform.logical_right_shift(val, 7);
            if (val == 0)
            {
                break;
            }

            buffer[count] |= 0x80;

            count += 1;
        }

        stream.Write(buffer, 0, count + 1);
    }
Esempio n. 2
0
    /// <summary>
    /// Unsigned VarInt format
    /// </summary>
    public static void WriteUInt32_(CitoStream stream, int val)
    {
        byte[] buffer = new byte[5];
        int    count  = 0;

        while (true)
        {
#if !CITO
            buffer[count] = (byte)(val & 0x7F);
#else
            buffer[count] = (val & 0x7F).LowByte;
#endif
            val = val >> 7;
            if (val == 0)
            {
                break;
            }

            buffer[count] |= 0x80;

            count += 1;
        }

        stream.Write(buffer, 0, count + 1);
    }
Esempio n. 3
0
    /// <summary>
    /// Unsigned VarInt format
    /// </summary>
    public static void WriteUInt64(CitoStream stream, int val)
    {
        byte[] buffer = new byte[10];
        int count = 0;

        while (true)
        {
        #if !CITO
            buffer[count] = (byte)(val & 0x7F);
        #else
            buffer[count] = (val & 0x7F).LowByte;
        #endif
            val = ProtoPlatform.logical_right_shift(val, 7);
            if (val == 0)
                break;

            buffer[count] |= 0x80;

            count += 1;
        }

        stream.Write(buffer, 0, count + 1);
    }
Esempio n. 4
0
    /// <summary>
    /// Unsigned VarInt format
    /// </summary>
    public static void WriteUInt32_(CitoStream stream, int val)
    {
        byte[] buffer = new byte[5];
        int count = 0;

        while (true)
        {
        #if !CITO
            buffer[count] = (byte)(val & 0x7F);
        #else
            buffer[count] = (val & 0x7F).LowByte;
        #endif
            val = val >> 7;
            if (val == 0)
                break;

            buffer[count] |= 0x80;

            count += 1;
        }

        stream.Write(buffer, 0, count + 1);
    }
Esempio n. 5
0
 /// <summary>
 /// Writes length delimited byte array
 /// </summary>
 public static void WriteBytes(CitoStream stream, byte[] val)
 {
     WriteUInt32_(stream, ProtoPlatform.ArrayLength(val));
     stream.Write(val, 0, ProtoPlatform.ArrayLength(val));
 }
Esempio n. 6
0
 /// <summary>
 /// Writes length delimited byte array
 /// </summary>
 public static void WriteBytes(CitoStream stream, byte[] val)
 {
     WriteUInt32_(stream, ProtoPlatform.ArrayLength(val));
     stream.Write(val, 0, ProtoPlatform.ArrayLength(val));
 }