Esempio n. 1
0
        public CompressionTests()
        {
            var recyclableMemoryStreamManager = new RecyclableMemoryStreamManager();

            compressor   = new Compressor(recyclableMemoryStreamManager);
            decompressor = new Decompressor(recyclableMemoryStreamManager);
        }
Esempio n. 2
0
 public int ForEachByteDesc(IByteProcessor processor)
 {
     if (!_terminated)
     {
         ThrowReplay();
     }
     return(_buffer.ForEachByteDesc(processor));
 }
Esempio n. 3
0
 /// <summary>
 ///     Iterates over the readable bytes of this buffer with the specified <paramref name="processor"/> in descending order.
 /// </summary>
 /// <returns>
 ///     <c>-1</c> if the processor iterated to or beyond the beginning of the readable bytes.
 ///     The last-visited index If the <see cref="IByteProcessor.Process"/> returned <c>false</c>.
 /// </returns>
 public static int ForEachByteDesc(this IByteBuffer buf, IByteProcessor processor)
 {
     if (buf is IByteBuffer2 buffer2)
     {
         return(buffer2.ForEachByteDesc(processor));
     }
     return(buf.ForEachByteDesc(buf.ReaderIndex, buf.ReadableBytes, processor));
 }
Esempio n. 4
0
        public int ForEachByteDesc(int index, int length, IByteProcessor processor)
        {
            if ((uint)(index + length) > (uint)_buffer.WriterIndex)
            {
                ThrowReplay();
            }

            return(_buffer.ForEachByteDesc(index, length, processor));
        }
Esempio n. 5
0
        public int ForEachByte(IByteProcessor processor)
        {
            int ret = _buffer.ForEachByte(processor);

            if ((uint)ret > SharedConstants.TooBigOrNegative)
            {
                ThrowReplay();
            }
            return(ret);
        }
Esempio n. 6
0
        public int ForEachByteDesc(IByteProcessor visitor)
        {
            var thisLength = this.length;

            if (0u >= (uint)thisLength)
            {
                return(IndexNotFound);
            }
            return(SpanHelpers.ForEachByteDesc(ref this.value[this.offset], visitor, thisLength));
        }
Esempio n. 7
0
 public ChunkProcessor(BlockingCollection <FileChunk> jobQueue, IOutputBuffer outputBuffer,
                       IByteProcessor byteProcessor, IJobContext jobContext, CancellationTokenSource cancellationTokenSource,
                       CountdownEvent countdown)
 {
     this.jobQueue                = jobQueue;
     this.outputBuffer            = outputBuffer;
     this.byteProcessor           = byteProcessor;
     this.jobContext              = jobContext;
     this.cancellationTokenSource = cancellationTokenSource;
     this.countdown               = countdown;
 }
        public sealed override int ForEachByteDesc(int index, int length, IByteProcessor processor)
        {
            CheckIndex0(index, length);
            int ret = Unwrap().ForEachByteDesc(Idx(index), length, processor);

            if (ret < adjustment)
            {
                return(IndexNotFound);
            }
            return(ret - adjustment);
        }
Esempio n. 9
0
        public override int ForEachByteDesc(int index, int length, IByteProcessor processor)
        {
            this.CheckIndex0(index, length);
            int ret = this.Unwrap().ForEachByteDesc(this.Idx(index), length, processor);

            if (ret < this.adjustment)
            {
                return(-1);
            }
            return(ret - this.adjustment);
        }
Esempio n. 10
0
        public sealed override int ForEachByte(int index, int length, IByteProcessor processor)
        {
            CheckIndex0(index, length);
            int ret = Unwrap().ForEachByte(Idx(index), length, processor);

            if (ret < _adjustment)
            {
                return(-1);
            }
            return(ret - _adjustment);
        }
        int ForEachByteAsc0(int start, int end, IByteProcessor processor)
        {
            for (; start < end; ++start)
            {
                if (!processor.Process(this._GetByte(start)))
                {
                    return(start);
                }
            }

            return(-1);
        }
        int ForEachByteDesc0(int rStart, int rEnd, IByteProcessor processor)
        {
            for (; rStart >= rEnd; --rStart)
            {
                if (!processor.Process(this._GetByte(rStart)))
                {
                    return(rStart);
                }
            }

            return(-1);
        }
        public override int ForEachByte(int index, int length, IByteProcessor processor)
        {
            CheckIndex0(index, length);
            int ret = Unwrap().ForEachByte(Idx(index), length, processor);

            if (ret >= _adjustment)
            {
                return(ret - _adjustment);
            }
            else
            {
                return(IndexNotFound);
            }
        }
Esempio n. 14
0
        public ISO2022CharDecoder(ICharProcessor processor, EncodingProfile enc)
        {
            _escseq = new EscapeSequenceBuffer();
            _processor = processor;
            _state = State.Normal;
            _encoding = enc;

            _asciiByteProcessor = new ASCIIByteProcessor(processor);
            _currentByteProcessor = _asciiByteProcessor;
            _G0ByteProcessor = _asciiByteProcessor;
            _G1ByteProcessor = _asciiByteProcessor;

            _byteProcessorBuffer = new ByteProcessorBuffer();
        }
Esempio n. 15
0
        private void ChangeProcessor(IByteProcessor newprocessor)
        {
            //既存のやつがあればリセット
            if (_currentByteProcessor != null)
            {
                _currentByteProcessor.Flush();
            }

            if (newprocessor != null)
            {
                newprocessor.Init();
            }

            _currentByteProcessor = newprocessor;
            _state = State.Normal;
        }
Esempio n. 16
0
        private void ChangeProcessor(IByteProcessor newprocessor)
        {
            //Šù‘¶‚Ì‚â‚‚ª‚ ‚ê‚΃ŠƒZƒbƒg
            if (_currentByteProcessor != null)
            {
                _currentByteProcessor.Flush();
            }

            if (newprocessor != null)
            {
                newprocessor.Init();
            }

            _currentByteProcessor = newprocessor;
            _state = State.Normal;
        }
Esempio n. 17
0
        public int ForEachByte(int index, int count, IByteProcessor visitor)
        {
            var thisLength = this.length;

            if (0u >= (uint)thisLength)
            {
                return(IndexNotFound);
            }
            if (MathUtil.IsOutOfBounds(index, count, thisLength))
            {
                ThrowIndexOutOfRangeException_Index(index, count, thisLength);
            }
            var idx = SpanHelpers.ForEachByte(ref this.value[this.offset + index], visitor, count);

            if ((uint)count > (uint)idx)
            {
                return(index + idx);
            }
            return(IndexNotFound);
        }
Esempio n. 18
0
        public int ForEachByte(int index, int length, IByteProcessor processor)
        {
            int  writerIndex  = _buffer.WriterIndex;
            uint uWriterIndex = (uint)writerIndex;

            if ((uint)index >= uWriterIndex)
            {
                ThrowReplay();
            }

            if ((uint)(index + length) <= uWriterIndex)
            {
                return(_buffer.ForEachByte(index, length, processor));
            }

            int ret = _buffer.ForEachByte(index, writerIndex - index, processor);

            if ((uint)ret > SharedConstants.TooBigOrNegative)
            {
                ThrowReplay();
            }
            return(ret);
        }
Esempio n. 19
0
        private void ChangeProcessor(IByteProcessor newprocessor)
        {
            //�����̂�‚�����΃��Z�b�g
            if (_currentByteProcessor != null) {
                _currentByteProcessor.Flush();
            }

            if (newprocessor != null) {
                newprocessor.Init();
            }

            _currentByteProcessor = newprocessor;
            _state = State.Normal;
        }
 public sealed override int ForEachByteDesc(int index, int length, IByteProcessor processor) => Unwrap().ForEachByteDesc(index, length, processor);
 public FileEncryptor()
 {
     dataSerialiser = new DataSerialiser();
     byteProcessor  = new ByteProcessor();
 }
Esempio n. 22
0
        private void ChangeProcessor(IByteProcessor newprocessor) {
            //既存のやつがあればリセット
            if (_currentByteProcessor != null) {
                _currentByteProcessor.Flush();
            }

            if (newprocessor != null) {
                newprocessor.Init();
            }

            _currentByteProcessor = newprocessor;
            _state = State.Normal;
        }
Esempio n. 23
0
 private void ProcessByte(byte b) {
     if (_processor.State == ProcessCharResult.Escaping)
         _processor.ProcessChar((char)b);
     else {
         if (_state == State.Normal && !IsControlChar(b) && _encoding.IsInterestingByte(b)) {
             PutMBCSByte(b);
         }
         else {
             switch (_state) {
                 case State.Normal:
                     if (b == 0x1B) { //ESC
                         _escseq.Reset();
                         _escseq.Append(b);
                         _state = State.ESC;
                     }
                     else if (b == 14) //SO
                         ChangeProcessor(_G1ByteProcessor);
                     else if (b == 15) //SI
                         ChangeProcessor(_G0ByteProcessor);
                     else
                         ConsumeByte(b);
                     break;
                 case State.ESC:
                     _escseq.Append(b);
                     if (b == (byte)'$')
                         _state = State.ESC_DOLLAR;
                     else if (b == (byte)'(')
                         _state = State.ESC_BRACKET;
                     else if (b == (byte)')')
                         _state = State.ESC_ENDBRACKET;
                     else {
                         ConsumeBytes(_escseq.Buffer, _escseq.Length);
                         _state = State.Normal;
                     }
                     break;
                 case State.ESC_BRACKET:
                     _escseq.Append(b);
                     if (b == (byte)'0') {
                         _G0ByteProcessor = GetDECLineByteProcessor();
                         ChangeProcessor(_G0ByteProcessor);
                         _state = State.Normal;
                     }
                     else if (b == (byte)'B' || b == (byte)'J' || b == (byte)'~') { //!!lessでssh2architecture.txtを見ていたら来た。詳細はまだ調べていない。
                         _G0ByteProcessor = _asciiByteProcessor;
                         ChangeProcessor(_G0ByteProcessor);
                         _state = State.Normal;
                     }
                     else {
                         _processor.UnsupportedCharSetDetected((char)b);
                         ConsumeBytes(_escseq.Buffer, _escseq.Length);
                         _state = State.Normal;
                     }
                     break;
                 case State.ESC_ENDBRACKET:
                     _escseq.Append(b);
                     if (b == (byte)'0') {
                         _G1ByteProcessor = GetDECLineByteProcessor();
                         _state = State.Normal;
                     }
                     else if (b == (byte)'B' || b == (byte)'J' || b == (byte)'~') { //!!lessでssh2architecture.txtを見ていたら来た。詳細はまだ調べていない。
                         _G1ByteProcessor = _asciiByteProcessor;
                         _state = State.Normal;
                     }
                     else {
                         ConsumeBytes(_escseq.Buffer, _escseq.Length);
                         _state = State.Normal;
                     }
                     break;
                 case State.ESC_DOLLAR:
                     _escseq.Append(b);
                     if (b == (byte)'(')
                         _state = State.ESC_DOLLAR_BRACKET;
                     else if (b == (byte)')')
                         _state = State.ESC_DOLLAR_ENDBRACKET;
                     else if (b == (byte)'B' || b == (byte)'@') {
                         _G0ByteProcessor = GetISO2022JPByteProcessor();
                         ChangeProcessor(_G0ByteProcessor);
                         _state = State.Normal;
                     }
                     else {
                         _processor.UnsupportedCharSetDetected((char)b);
                         ConsumeBytes(_escseq.Buffer, _escseq.Length);
                         _state = State.Normal;
                     }
                     break;
                 case State.ESC_DOLLAR_BRACKET:
                     _escseq.Append(b);
                     if (b == (byte)'C') {
                         _G0ByteProcessor = GetISO2022KRByteProcessor();
                         ChangeProcessor(_G0ByteProcessor);
                         _state = State.Normal;
                     }
                     else if (b == (byte)'D') {
                         _G0ByteProcessor = GetISO2022JPByteProcessor();
                         ChangeProcessor(_G0ByteProcessor);
                         _state = State.Normal;
                     }
                     else if (b == (byte)'I') {
                         _G0ByteProcessor = GetISO2022JPKanaByteProcessor();
                         ChangeProcessor(_G0ByteProcessor);
                         _state = State.Normal;
                     }
                     else {
                         _processor.UnsupportedCharSetDetected((char)b);
                         ConsumeBytes(_escseq.Buffer, _escseq.Length);
                         _state = State.Normal;
                     }
                     break;
                 case State.ESC_DOLLAR_ENDBRACKET:
                     _escseq.Append(b);
                     if (b == (byte)'C') {
                         _G1ByteProcessor = GetISO2022KRByteProcessor();
                         _state = State.Normal;
                     }
                     else {
                         ConsumeBytes(_escseq.Buffer, _escseq.Length);
                         _state = State.Normal;
                     }
                     break;
                 default:
                     Debug.Assert(false, "unexpected state transition");
                     break;
             }
         }
     }
 }
 public virtual int ForEachByteDesc(int index, int length, IByteProcessor processor)
 {
     this.CheckIndex(index, length);
     return(this.ForEachByteDesc0(index + length - 1, index, processor));
 }
 public virtual int ForEachByteDesc(IByteProcessor processor)
 {
     this.EnsureAccessible();
     return(this.ForEachByteDesc0(this.writerIndex - 1, this.readerIndex, processor));
 }
 public override int ForEachByte(IByteProcessor processor)
 {
     RecordLeakNonRefCountingOperation(this.Leak);
     return(base.ForEachByte(processor));
 }
Esempio n. 27
0
 public virtual int ForEachByteDesc(IByteProcessor processor) => this.Buf.ForEachByteDesc(processor);
Esempio n. 28
0
 public int ForEachByteDesc(IByteProcessor processor) => - 1;
Esempio n. 29
0
 public int ForEachByteDesc(int index, int length, IByteProcessor processor)
 {
     this.CheckIndex(index, length);
     return(-1);
 }
Esempio n. 30
0
        private void ProcessByte(byte b)
        {
            if (_processor.State == ProcessCharResult.Escaping)
            {
                _processor.ProcessChar((char)b);
            }
            else
            {
                if (_state == State.Normal && !IsControlChar(b) && _encoding.IsInterestingByte(b))
                {
                    PutMBCSByte(b);
                }
                else
                {
                    switch (_state)
                    {
                    case State.Normal:
                        if (b == 0x1B)                                //ESC
                        {
                            _escseq.Reset();
                            _escseq.Append(b);
                            _state = State.ESC;
                        }
                        else if (b == 14)                              //SO
                        {
                            ChangeProcessor(_G1ByteProcessor);
                        }
                        else if (b == 15)                              //SI
                        {
                            ChangeProcessor(_G0ByteProcessor);
                        }
                        else
                        {
                            ConsumeByte(b);
                        }
                        break;

                    case State.ESC:
                        _escseq.Append(b);
                        if (b == (byte)'$')
                        {
                            _state = State.ESC_DOLLAR;
                        }
                        else if (b == (byte)'(')
                        {
                            _state = State.ESC_BRACKET;
                        }
                        else if (b == (byte)')')
                        {
                            _state = State.ESC_ENDBRACKET;
                        }
                        else
                        {
                            ConsumeBytes(_escseq.Buffer, _escseq.Length);
                            _state = State.Normal;
                        }
                        break;

                    case State.ESC_BRACKET:
                        _escseq.Append(b);
                        if (b == (byte)'0')
                        {
                            _G0ByteProcessor = GetDECLineByteProcessor();
                            ChangeProcessor(_G0ByteProcessor);
                            _state = State.Normal;
                        }
                        else if (b == (byte)'B' || b == (byte)'J' || b == (byte)'~')                            //!!lessでssh2architecture.txtを見ていたら来た。詳細はまだ調べていない。
                        {
                            _G0ByteProcessor = _asciiByteProcessor;
                            ChangeProcessor(_G0ByteProcessor);
                            _state = State.Normal;
                        }
                        else
                        {
                            _processor.UnsupportedCharSetDetected((char)b);
                            ConsumeBytes(_escseq.Buffer, _escseq.Length);
                            _state = State.Normal;
                        }
                        break;

                    case State.ESC_ENDBRACKET:
                        _escseq.Append(b);
                        if (b == (byte)'0')
                        {
                            _G1ByteProcessor = GetDECLineByteProcessor();
                            _state           = State.Normal;
                        }
                        else if (b == (byte)'B' || b == (byte)'J' || b == (byte)'~')                            //!!lessでssh2architecture.txtを見ていたら来た。詳細はまだ調べていない。
                        {
                            _G1ByteProcessor = _asciiByteProcessor;
                            _state           = State.Normal;
                        }
                        else
                        {
                            ConsumeBytes(_escseq.Buffer, _escseq.Length);
                            _state = State.Normal;
                        }
                        break;

                    case State.ESC_DOLLAR:
                        _escseq.Append(b);
                        if (b == (byte)'(')
                        {
                            _state = State.ESC_DOLLAR_BRACKET;
                        }
                        else if (b == (byte)')')
                        {
                            _state = State.ESC_DOLLAR_ENDBRACKET;
                        }
                        else if (b == (byte)'B' || b == (byte)'@')
                        {
                            _G0ByteProcessor = GetISO2022JPByteProcessor();
                            ChangeProcessor(_G0ByteProcessor);
                            _state = State.Normal;
                        }
                        else
                        {
                            _processor.UnsupportedCharSetDetected((char)b);
                            ConsumeBytes(_escseq.Buffer, _escseq.Length);
                            _state = State.Normal;
                        }
                        break;

                    case State.ESC_DOLLAR_BRACKET:
                        _escseq.Append(b);
                        if (b == (byte)'C')
                        {
                            _G0ByteProcessor = GetISO2022KRByteProcessor();
                            ChangeProcessor(_G0ByteProcessor);
                            _state = State.Normal;
                        }
                        else if (b == (byte)'D')
                        {
                            _G0ByteProcessor = GetISO2022JPByteProcessor();
                            ChangeProcessor(_G0ByteProcessor);
                            _state = State.Normal;
                        }
                        else if (b == (byte)'I')
                        {
                            _G0ByteProcessor = GetISO2022JPKanaByteProcessor();
                            ChangeProcessor(_G0ByteProcessor);
                            _state = State.Normal;
                        }
                        else
                        {
                            _processor.UnsupportedCharSetDetected((char)b);
                            ConsumeBytes(_escseq.Buffer, _escseq.Length);
                            _state = State.Normal;
                        }
                        break;

                    case State.ESC_DOLLAR_ENDBRACKET:
                        _escseq.Append(b);
                        if (b == (byte)'C')
                        {
                            _G1ByteProcessor = GetISO2022KRByteProcessor();
                            _state           = State.Normal;
                        }
                        else
                        {
                            ConsumeBytes(_escseq.Buffer, _escseq.Length);
                            _state = State.Normal;
                        }
                        break;

                    default:
                        Debug.Assert(false, "unexpected state transition");
                        break;
                    }
                }
            }
        }
Esempio n. 31
0
 public virtual int ForEachByteDesc(int index, int length, IByteProcessor processor) => this.Buf.ForEachByteDesc(index, length, processor);
Esempio n. 32
0
 public int ForEachByteDesc(IByteProcessor processor)
 {
     throw new NotImplementedException();
 }
 public override int ForEachByteDesc(int index, int length, IByteProcessor processor)
 {
     RecordLeakNonRefCountingOperation(this.Leak);
     return(base.ForEachByteDesc(index, length, processor));
 }
Esempio n. 34
0
 public int ForEachByteDesc(int index, int length, IByteProcessor processor)
 {
     throw new NotImplementedException();
 }