Ejemplo n.º 1
0
        /// <remarks>Used for indexes which *are not* typically NONE (-1)</remarks>
        public static void StreamIndexPos(this IO.BitStream s, ref int value, int bitCount = Bits.kInt32BitCount)
        {
            Contract.Requires(bitCount <= Bits.kInt32BitCount);

            if (s.IsReading)
            {
                bool not_none = s.ReadBoolean();

                if (not_none)
                {
                    s.Read(out value, bitCount);
                }
                else
                {
                    value = TypeExtensions.kNone;
                }
            }
            else if (s.IsWriting)
            {
                bool not_none = value.IsNotNone();
                s.Write(not_none);

                if (not_none)
                {
                    s.Write(value, bitCount);
                }
            }
        }