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