public static void SetFloat(this IArrayBuffer <byte> buffer, int start, float value, bool isLittleEndian) { Contract.Requires(buffer != null); buffer.CheckIndex(start, sizeof(float)); buffer.SetInt32(start, ByteBufferUtil.SingleToInt32Bits(value), BitConverter.IsLittleEndian == isLittleEndian); }
public string ReadString(Encoding encoding, byte[] separator) { Contract.Requires(encoding != null); Contract.Requires(separator != null && separator.Length > 0); int readableBytes = this.buffer.ReadableBytes; if (readableBytes == 0) { return(string.Empty); } IByteBuffer buf = Unpooled.WrappedBuffer(separator); return(ByteBufferUtil.ReadString(this.buffer, buf, encoding)); }
public float ReadFloatLE() => ByteBufferUtil.Int32BitsToSingle(this.ReadIntLE());
public IByteBuffer SetFloatLE(int index, float value) => this.SetIntLE(index, ByteBufferUtil.SingleToInt32Bits(value));
public virtual IByteBuffer SetFloat(int index, float value) { this.SetInt(index, ByteBufferUtil.SingleToInt32Bits(value)); return(this); }
public float GetFloatLE(int index) => ByteBufferUtil.Int32BitsToSingle(this.GetIntLE(index));
public virtual int CompareTo(IByteBuffer that) => ByteBufferUtil.Compare(this, that);
public virtual bool Equals(IByteBuffer buffer) => ReferenceEquals(this, buffer) || buffer != null && ByteBufferUtil.Equals(this, buffer);
public override int GetHashCode() => ByteBufferUtil.HashCode(this);
public virtual int IndexOf(int fromIndex, int toIndex, byte value) => ByteBufferUtil.IndexOf(this, fromIndex, toIndex, value);
public virtual string ToString(int index, int length, Encoding encoding) => ByteBufferUtil.DecodeString(this, index, length, encoding);
public IByteBuffer WriteFloatLE(float value) => this.WriteIntLE(ByteBufferUtil.SingleToInt32Bits(value));
public virtual IByteBuffer WriteFloat(float value) { this.WriteInt(ByteBufferUtil.SingleToInt32Bits(value)); return(this); }
static IByteBuffer CopiedBuffer(string value, Encoding encoding) => ByteBufferUtil.EncodeString0(Allocator, true, value, encoding, 0);