Exemplo n.º 1
0
        internal void ParseExistentData()
        {
            if (0 == _workBuffer.Size)
            {
                return;
            }

            DataChunk[] chunks = DataChunk.ParseData(_workBuffer.Data, _workBuffer.Size);
            int         chunksNum = chunks.Length, i = 0;

            try
            {
                for (; i < chunksNum; i++)
                {
                    LineInfo line = GetCurrentLine();
                    if (LineInfoState.Completed == line.State)
                    {
                        MoveToNextLine();
                        line = GetCurrentLine();
                    }


                    try
                    {
                        line.PutChunk(_workBuffer.Data, chunks[i]);
                    }
                    catch (LineException e)
                    {
                        e.Line = GetCurrentLineIndex();
                        throw;
                    }

                    if (LineInfoState.Completed == line.State)
                    {
                        OnNewLine(line, GetCurrentLineIndex());
                        if (true == SingleLineMode && (i != chunksNum - 1))
                        {
                            break;
                        }
                    }
                }
            }
            catch
            {
                _invalidState = true;
                throw;
            }

            if (chunksNum == i)            //all working data was parsed?
            {
                _workBuffer.Clear();
            }
            else
            {
                _workBuffer.CutHead(chunks[i].Start + chunks[i].Length);
            }
        }