예제 #1
0
 public bool readOptional(int tag, OptionalFormat format)
 {
     return(_is.readOpt(tag, format));
 }
예제 #2
0
 public bool writeOptional(int tag, OptionalFormat format)
 {
     return(_os.writeOpt(tag, format));
 }
예제 #3
0
 internal override bool readOptional(int readTag, OptionalFormat expectedFormat)
 {
     if(_current == null)
     {
         return _stream.readOptImpl(readTag, expectedFormat);
     }
     else if((_current.sliceFlags & Protocol.FLAG_HAS_OPTIONAL_MEMBERS) != 0)
     {
         return _stream.readOptImpl(readTag, expectedFormat);
     }
     return false;
 }
예제 #4
0
 internal virtual bool readOptional(int tag, OptionalFormat format)
 {
     return false;
 }
예제 #5
0
 private void skipOptional(OptionalFormat format)
 {
     switch(format)
     {
     case OptionalFormat.F1:
     {
         skip(1);
         break;
     }
     case OptionalFormat.F2:
     {
         skip(2);
         break;
     }
     case OptionalFormat.F4:
     {
         skip(4);
         break;
     }
     case OptionalFormat.F8:
     {
         skip(8);
         break;
     }
     case OptionalFormat.Size:
     {
         skipSize();
         break;
     }
     case OptionalFormat.VSize:
     {
         skip(readSize());
         break;
     }
     case OptionalFormat.FSize:
     {
         skip(readInt());
         break;
     }
     case OptionalFormat.Class:
     {
         readValue(null);
         break;
     }
     }
 }
예제 #6
0
        private bool readOptImpl(int readTag, OptionalFormat expectedFormat)
        {
            if(isEncoding_1_0())
            {
                return false; // Optional members aren't supported with the 1.0 encoding.
            }

            while(true)
            {
                if(_buf.b.position() >= _encapsStack.start + _encapsStack.sz)
                {
                    return false; // End of encapsulation also indicates end of optionals.
                }

                int v = readByte();
                if(v == Protocol.OPTIONAL_END_MARKER)
                {
                    _buf.b.position(_buf.b.position() - 1); // Rewind.
                    return false;
                }

                OptionalFormat format = (OptionalFormat)(v & 0x07); // First 3 bits.
                int tag = v >> 3;
                if(tag == 30)
                {
                    tag = readSize();
                }

                if(tag > readTag)
                {
                    int offset = tag < 30 ? 1 : (tag < 255 ? 2 : 6); // Rewind
                    _buf.b.position(_buf.b.position() - offset);
                    return false; // No optional data members with the requested tag.
                }
                else if(tag < readTag)
                {
                    skipOptional(format); // Skip optional data members
                }
                else
                {
                    if(format != expectedFormat)
                    {
                        throw new MarshalException("invalid optional data member `" + tag + "': unexpected format");
                    }
                    return true;
                }
            }
        }
예제 #7
0
 /// <summary>
 /// Determine if an optional value is available for reading.
 /// </summary>
 /// <param name="tag">The tag associated with the value.</param>
 /// <param name="expectedFormat">The optional format for the value.</param>
 /// <returns>True if the value is present, false otherwise.</returns>
 public bool readOptional(int tag, OptionalFormat expectedFormat)
 {
     Debug.Assert(_encapsStack != null);
     if(_encapsStack.decoder != null)
     {
         return _encapsStack.decoder.readOptional(tag, expectedFormat);
     }
     else
     {
         return readOptImpl(tag, expectedFormat);
     }
 }