Example #1
0
 public IByteBuffer SetUnsignedShort(int index, int value)
 {
     unchecked
     {
         this.buf.SetUnsignedShort(index, (ushort)ByteBufferUtil.SwapShort((short)value));
     }
     return(this);
 }
Example #2
0
 public IByteBuffer SetUnsignedInt(int index, uint value)
 {
     unchecked
     {
         this.buf.SetUnsignedInt(index, (uint)ByteBufferUtil.SwapInt((int)value));
     }
     return(this);
 }
Example #3
0
 public static string ToString(this IByteBuffer buf, int index, int length, Encoding encoding)
 {
     if (buf is IByteBuffer2 buffer2)
     {
         return(buffer2.ToString(index, length, encoding));
     }
     return(ByteBufferUtil.DecodeString(buf, index, length, encoding));
 }
Example #4
0
        public IByteBuffer WriteUnsignedInt(uint value)
        {
            unchecked
            {
                this.buf.WriteUnsignedInt((uint)ByteBufferUtil.SwapInt((int)value));
            }

            return(this);
        }
 public bool Equals(IByteBuffer buffer)
 {
     if (ReferenceEquals(this, buffer))
     {
         return(true);
     }
     if (buffer != null)
     {
         return(ByteBufferUtil.Equals(this, buffer));
     }
     return(false);
 }
 int SetCharSequence0(int index, ICharSequence sequence, Encoding encoding, bool expand)
 {
     if (ReferenceEquals(encoding, Encoding.UTF8))
     {
         int length = ByteBufferUtil.Utf8MaxBytes(sequence);
         if (expand)
         {
             this.EnsureWritable0(length);
             this.CheckIndex0(index, length);
         }
         else
         {
             this.CheckIndex(index, length);
         }
         return(ByteBufferUtil.WriteUtf8(this, index, sequence, sequence.Count));
     }
     if (ReferenceEquals(encoding, Encoding.ASCII))
     {
         int length = sequence.Count;
         if (expand)
         {
             this.EnsureWritable0(length);
             this.CheckIndex0(index, length);
         }
         else
         {
             this.CheckIndex(index, length);
         }
         return(ByteBufferUtil.WriteAscii(this, index, sequence, length));
     }
     byte[] bytes = encoding.GetBytes(sequence.ToString());
     if (expand)
     {
         this.EnsureWritable0(bytes.Length);
         // setBytes(...) will take care of checking the indices.
     }
     this.SetBytes(index, bytes);
     return(bytes.Length);
 }
 public IByteBuffer SetFloatLE(int index, float value) => this.SetIntLE(index, ByteBufferUtil.SingleToInt32Bits(value));
 public float GetFloatLE(int index) => ByteBufferUtil.Int32BitsToSingle(this.GetIntLE(index));
 public virtual bool Equals(IByteBuffer buffer) =>
 ReferenceEquals(this, buffer) || buffer != null && ByteBufferUtil.Equals(this, buffer);
Example #10
0
 public IByteBuffer SetLong(int index, long value)
 {
     this.buf.SetLong(index, ByteBufferUtil.SwapLong(value));
     return(this);
 }
 public virtual IByteBuffer WriteFloat(float value)
 {
     this.WriteInt(ByteBufferUtil.SingleToInt32Bits(value));
     return(this);
 }
 public string ToString(int index, int length, Encoding encoding) => ByteBufferUtil.DecodeString(this, index, length, encoding);
 public virtual IByteBuffer SetFloat(int index, float value)
 {
     this.SetInt(index, ByteBufferUtil.SingleToInt32Bits(value));
     return(this);
 }
Example #14
0
 public IByteBuffer WriteInt(int value)
 {
     this.buf.WriteInt(ByteBufferUtil.SwapInt(value));
     return(this);
 }
 public float ReadFloatLE() => ByteBufferUtil.Int32BitsToSingle(this.ReadIntLE());
Example #16
0
 public IByteBuffer WriteUnsignedShort(int value)
 {
     this.buf.WriteUnsignedShort(unchecked ((ushort)ByteBufferUtil.SwapShort((short)value)));
     return(this);
 }
Example #17
0
 public IByteBuffer WriteShort(int value)
 {
     this.buf.WriteShort(ByteBufferUtil.SwapShort((short)value));
     return(this);
 }
Example #18
0
 public long ReadLong()
 {
     return(ByteBufferUtil.SwapLong(this.buf.ReadLong()));
 }
Example #19
0
 public int ReadInt()
 {
     return(ByteBufferUtil.SwapInt(this.buf.ReadInt()));
 }
Example #20
0
 public short ReadShort()
 {
     return(ByteBufferUtil.SwapShort(this.buf.ReadShort()));
 }
 public static IByteBuffer CopiedBuffer(string value, Encoding encoding) => ByteBufferUtil.EncodeString0(Allocator, true, value, encoding, 0);
Example #22
0
 public IByteBuffer WriteLong(long value)
 {
     this.buf.WriteLong(ByteBufferUtil.SwapLong(value));
     return(this);
 }
 public virtual float GetFloat(int index) => ByteBufferUtil.Int32BitsToSingle(this.GetInt(index));
Example #24
0
        public int GetHashCode(IByteBuffer obj)
        {
            //if (obj is null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.obj); }

            return(ByteBufferUtil.HashCode(obj));
        }
 public virtual float ReadFloat() => ByteBufferUtil.Int32BitsToSingle(this.ReadInt());
Example #26
0
 /// <summary>Encode the given <see cref="string" /> using the given <see cref="Encoding" /> into a new
 /// <see cref="IByteBuffer" /> which is allocated via the <see cref="IByteBufferAllocator" />.</summary>
 /// <param name="src">src The <see cref="string" /> to encode.</param>
 /// <param name="encoding">charset The specified <see cref="Encoding" /></param>
 /// <param name="extraCapacity">the extra capacity to alloc except the space for decoding.</param>
 public static IByteBuffer EncodeString(string src, Encoding encoding, int extraCapacity = 0) => ByteBufferUtil.EncodeString0(Allocator, false, src, encoding, extraCapacity);
 public override int GetHashCode() => ByteBufferUtil.HashCode(this);
 public IByteBuffer WriteFloatLE(float value) => this.WriteIntLE(ByteBufferUtil.SingleToInt32Bits(value));
 public int CompareTo(IByteBuffer that) => ByteBufferUtil.Compare(this, that);
 public virtual int IndexOf(int fromIndex, int toIndex, byte value) => ByteBufferUtil.IndexOf(this, fromIndex, toIndex, value);