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