コード例 #1
0
        public ReadOnlyByteBuffer(IByteBuffer buffer)
            : base(buffer is object?buffer.MaxCapacity: AbstractByteBufferAllocator.DefaultMaxCapacity)
        {
            if (buffer is null)
            {
                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.buffer);
            }

            switch (buffer)
            {
            case ReadOnlyByteBuffer _:
            case UnpooledDuplicatedByteBuffer _:
                _buffer = buffer.Unwrap();
                break;

            default:
                _buffer = buffer;
                break;
            }
            _ = SetIndex(buffer.ReaderIndex, buffer.WriterIndex);
        }
コード例 #2
0
        internal static void SetBytes(AbstractByteBuffer buf, byte *addr, int index, IByteBuffer src, int srcIndex, int length)
        {
            Contract.Requires(src != null);

            if (MathUtil.IsOutOfBounds(srcIndex, length, src.Capacity))
            {
                ThrowHelper.ThrowIndexOutOfRangeException_SrcIndex(srcIndex);
            }

            if (length != 0)
            {
                if (src.HasMemoryAddress)
                {
                    IntPtr ptr = src.AddressOfPinnedMemory();
                    if (ptr != IntPtr.Zero)
                    {
                        PlatformDependent.CopyMemory((byte *)(ptr + srcIndex), addr, length);
                    }
                    else
                    {
                        fixed(byte *source = &src.GetPinnableMemoryAddress())
                        {
                            PlatformDependent.CopyMemory(source + srcIndex, addr, length);
                        }
                    }
                }
                else if (src.HasArray)
                {
                    PlatformDependent.CopyMemory(src.Array, src.ArrayOffset + srcIndex, addr, length);
                }
                else
                {
                    src.GetBytes(srcIndex, buf, index, length);
                }
            }
        }
コード例 #3
0
 public override IByteBuffer SetBytes(int index, IByteBuffer src, int srcIndex, int length)
 {
     throw ThrowHelper.GetReadOnlyBufferException();
 }
コード例 #4
0
 public override IByteBuffer SetBytes(int index, byte[] src)
 {
     throw ThrowHelper.GetReadOnlyBufferException();
 }
コード例 #5
0
 public override IByteBuffer DiscardSomeReadBytes() => throw ThrowHelper.GetReadOnlyBufferException();
コード例 #6
0
 public override IByteBuffer EnsureWritable(int minWritableBytes) => throw ThrowHelper.GetReadOnlyBufferException();
コード例 #7
0
 public override IByteBuffer AdjustCapacity(int newCapacity) => throw ThrowHelper.GetReadOnlyBufferException();
コード例 #8
0
 public override IByteBuffer SetZero(int index, int length)
 {
     throw ThrowHelper.GetReadOnlyBufferException();
 }
コード例 #9
0
 public override int SetString(int index, string value, Encoding encoding)
 {
     throw ThrowHelper.GetReadOnlyBufferException();
 }
コード例 #10
0
 public override int SetCharSequence(int index, ICharSequence sequence, Encoding encoding)
 {
     throw ThrowHelper.GetReadOnlyBufferException();
 }
コード例 #11
0
 public override IByteBuffer SetBoolean(int index, bool value)
 {
     throw ThrowHelper.GetReadOnlyBufferException();
 }
コード例 #12
0
 protected internal override void _SetShortLE(int index, int value)
 {
     throw ThrowHelper.GetReadOnlyBufferException();
 }
コード例 #13
0
 public override IByteBuffer SetShortLE(int index, int value)
 {
     throw ThrowHelper.GetReadOnlyBufferException();
 }
コード例 #14
0
 public override IByteBuffer SetLongLE(int index, long value)
 {
     throw ThrowHelper.GetReadOnlyBufferException();
 }
コード例 #15
0
 protected internal override void _SetLong(int index, long value)
 {
     throw ThrowHelper.GetReadOnlyBufferException();
 }
コード例 #16
0
 public override Task <int> SetBytesAsync(int index, Stream src, int length, CancellationToken cancellationToken)
 {
     throw ThrowHelper.GetReadOnlyBufferException();
 }