Example #1
0
        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);
        }
Example #2
0
        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));
        }
Example #3
0
 public float ReadFloatLE() => ByteBufferUtil.Int32BitsToSingle(this.ReadIntLE());
Example #4
0
 public IByteBuffer SetFloatLE(int index, float value) => this.SetIntLE(index, ByteBufferUtil.SingleToInt32Bits(value));
Example #5
0
 public virtual IByteBuffer SetFloat(int index, float value)
 {
     this.SetInt(index, ByteBufferUtil.SingleToInt32Bits(value));
     return(this);
 }
Example #6
0
 public float GetFloatLE(int index) => ByteBufferUtil.Int32BitsToSingle(this.GetIntLE(index));
Example #7
0
 public virtual int CompareTo(IByteBuffer that) => ByteBufferUtil.Compare(this, that);
Example #8
0
 public virtual bool Equals(IByteBuffer buffer) =>
 ReferenceEquals(this, buffer) || buffer != null && ByteBufferUtil.Equals(this, buffer);
Example #9
0
 public override int GetHashCode() => ByteBufferUtil.HashCode(this);
Example #10
0
 public virtual int IndexOf(int fromIndex, int toIndex, byte value) => ByteBufferUtil.IndexOf(this, fromIndex, toIndex, value);
Example #11
0
 public virtual string ToString(int index, int length, Encoding encoding) => ByteBufferUtil.DecodeString(this, index, length, encoding);
Example #12
0
 public IByteBuffer WriteFloatLE(float value) => this.WriteIntLE(ByteBufferUtil.SingleToInt32Bits(value));
Example #13
0
 public virtual IByteBuffer WriteFloat(float value)
 {
     this.WriteInt(ByteBufferUtil.SingleToInt32Bits(value));
     return(this);
 }
Example #14
0
 static IByteBuffer CopiedBuffer(string value, Encoding encoding) => ByteBufferUtil.EncodeString0(Allocator, true, value, encoding, 0);