/** * * To support efficient serialization for SmallMessage implementations, * this utility method reads in the property flags from an ObjectInput * stream. Flags are read in one byte at a time. Flags make use of * sign-extension so that if the high-bit is set to 1 this indicates that * another set of flags follows. * * @return The array of property flags. */ protected short[] ReadFlags(IDataInput input) { bool hasNextFlag = true; short[] flagsArray = new short[2]; int i = 0; while (hasNextFlag) { short flags = (short)input.ReadUnsignedByte(); if (i == flagsArray.Length) { short[] tempArray = new short[i * 2]; Array.Copy(flagsArray, tempArray, flagsArray.Length); flagsArray = tempArray; } flagsArray[i] = flags; hasNextFlag = (flags & HAS_NEXT_FLAG) != 0; i++; } return(flagsArray); }
protected internal virtual short[] readFlags(IDataInput input) { bool hasNextFlag = true; short[] flagsArray = new short[2]; int i = 0; while (hasNextFlag) { short flags = (short)input.ReadUnsignedByte(); if (i == flagsArray.Length) { short[] tempArray = new short[i * 2]; Array.Copy(flagsArray, 0, tempArray, 0, flagsArray.Length); flagsArray = tempArray; } flagsArray[i] = flags; if ((flags & HAS_NEXT_FLAG) != 0) { hasNextFlag = true; } else { hasNextFlag = false; } i++; } return(flagsArray); }
public static List <byte> ReadFlags(IDataInput input) { var ret = new List <byte>(); byte read; do { ret.Add(read = input.ReadUnsignedByte()); }while ((read & HAS_NEXT_FLAG) != 0); //Highest bit reserved for declaring that there is another flag. return(ret); }
public static List<byte> ReadFlags(IDataInput input) { var ret = new List<byte>(); byte read; do { ret.Add(read = input.ReadUnsignedByte()); } while ((read & HAS_NEXT_FLAG) != 0); //Highest bit reserved for declaring that there is another flag. return ret; }
/// <summary> /// 读取一个无符号 8 位数字. /// </summary> /// <param name="input">输入流对象.</param> /// <returns>对应的数据.</returns> public static byte ReadUByte(IDataInput input) { return(input.ReadUnsignedByte()); }