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