Пример #1
0
    /// <summary>
    /// Seek past the value for the previously read key.
    /// </summary>
    public static void SkipKey(CitoStream stream, Key key)
    {
        switch (key.GetWireType())
        {
        case Wire.Fixed32:
            stream.Seek(4, CitoSeekOrigin.Current);
            return;

        case Wire.Fixed64:
            stream.Seek(8, CitoSeekOrigin.Current);
            return;

        case Wire.LengthDelimited:
            stream.Seek(ProtocolParser.ReadUInt32(stream), CitoSeekOrigin.Current);
            return;

        case Wire.Varint:
            ProtocolParser.ReadSkipVarInt(stream);
            return;

        default:
#if !CITO
            throw new NotImplementedException("Unknown wire type: " + key.GetWireType());
#else
            return;
#endif
        }
    }
Пример #2
0
    /// <summary>
    /// Skip the next varint length prefixed bytes.
    /// Alternative to ReadBytes when the data is not of interest.
    /// </summary>
    public static void SkipBytes(CitoStream stream)
    {
        int length = ReadUInt32(stream);

        if (stream.CanSeek())
        {
            stream.Seek(length, CitoSeekOrigin.Current);
        }
        else
        {
            ReadBytes(stream);
        }
    }
Пример #3
0
 /// <summary>
 /// Seek past the value for the previously read key.
 /// </summary>
 public static void SkipKey(CitoStream stream, Key key)
 {
     switch (key.GetWireType())
     {
         case Wire.Fixed32:
             stream.Seek(4, CitoSeekOrigin.Current);
             return;
         case Wire.Fixed64:
             stream.Seek(8, CitoSeekOrigin.Current);
             return;
         case Wire.LengthDelimited:
             stream.Seek(ProtocolParser.ReadUInt32(stream), CitoSeekOrigin.Current);
             return;
         case Wire.Varint:
             ProtocolParser.ReadSkipVarInt(stream);
             return;
         default:
     #if !CITO
             throw new NotImplementedException("Unknown wire type: " + key.GetWireType());
     #else
             return;
     #endif
     }
 }
Пример #4
0
 /// <summary>
 /// Skip the next varint length prefixed bytes.
 /// Alternative to ReadBytes when the data is not of interest.
 /// </summary>
 public static void SkipBytes(CitoStream stream)
 {
     int length = ReadUInt32(stream);
     if (stream.CanSeek())
         stream.Seek(length, CitoSeekOrigin.Current);
     else
         ReadBytes(stream);
 }