Esempio n. 1
0
        Iterate(InterationCallback Callback, UInt32 InterationSize)
        {
            if (InterationSize > 0)
            {
                if ((this._CurrentElement == UInt32.MaxValue) ||
                    ((this._Position + InterationSize) > this._TotalSize) ||
                    !this._IsInitialized)
                {
                    return(-1); // EOS
                }

                while (true)
                {
                    {
                        UInt32 fragmentSize;

                        Debug.Assert(this._CurrentElementSize >= this._CurrentElementOffset);
                        fragmentSize    = Math.Min(InterationSize, (this._CurrentElementSize - this._CurrentElementOffset));
                        this._Position += fragmentSize;

                        if (fragmentSize > 0)
                        {
                            if (Callback != null)
                            {
                                var status = Callback((this._CurrentElementBufferBase + this._CurrentElementOffset), ref fragmentSize);
                                if (status != 0)
                                {
                                    return(status);
                                }
                            }

                            this._CurrentElementOffset += fragmentSize;
                            InterationSize             -= fragmentSize;
                        }
                    }

                    if ((InterationSize > 0) || ((this._CurrentElementOffset == this._CurrentElementSize) && this._TotalSize > this._Position))
                    {
                        this._CurrentElement++;
                        this._CurrentElementOffset = 0;
                        if (this._CurrentElement >= this._NumberOfElements)
                        {
                            return(-1); // EOS
                        }

                        this._CurrentElementSize       = Math.Min(this._ElementsDescs[this._CurrentElement].Size, (this._TotalSize - this._Position));
                        this._CurrentElementBufferBase = this._ElementsDescs[this._CurrentElement].ElementBaseAddress;
                    }
                    else
                    {
                        break;
                    }
                }
            }

            return(0);
        }
Esempio n. 2
0
        Put(byte *SrcPtr, UInt32 Size)
        {
            if (!this._IsInitialized)
            {
                return(false);
            }

            this._MoveInteratorState = SrcPtr;

            InterationCallback moveToBufferIterator = this.MoveToBufferIterator;

            return(this.Iterate(moveToBufferIterator, Size) == 0);
        }
Esempio n. 3
0
        Pull(byte *ResultPtr, UInt32 ResultSize)
        {
            if (!this._IsInitialized)
            {
                return(false);
            }

            this._MoveInteratorState = ResultPtr;

            InterationCallback moveFromBufferIterator = this.MoveFromBufferIterator;

            return(this.Iterate(moveFromBufferIterator, ResultSize) == 0);
        }