Пример #1
0
        internal ReaderStateMachine(
            MemoryPool <char> memoryPool,
            char escapeStartChar,
            char valueSeparatorChar,
            char escapeChar,
            RowEndings rowEndings,
            ReadHeaders hasHeaders,
            char?commentChar
            )
        {
            RowEndings = rowEndings;
            HasHeaders = hasHeaders;

            switch (HasHeaders)
            {
            case ReadHeaders.Always:
                CurrentState = State.Header_Start;
                break;

            case ReadHeaders.Never:
                CurrentState = State.Record_Start;
                break;

            default:
                Throw.InvalidOperationException($"Unexpected {nameof(ReadHeaders)}: {HasHeaders}");
                break;
            }

            TransitionMatrixHandle = GetTransitionMatrix(RowEndings, escapeStartChar == escapeChar).Pin();
            TransitionMatrix       = (TransitionRule *)TransitionMatrixHandle.Pointer;

            SuppressCharLookupDispose = false;
            (MinimumCharacter, CharLookupOffset, CharLookupOwner, CharLookupPin, CharLookup) =
                MakeCharacterLookup(memoryPool, escapeStartChar, valueSeparatorChar, escapeChar, commentChar);
        }
Пример #2
0
        internal ReaderStateMachine(
            CharacterLookup preAllocLookup,
            char escapeStartChar,
            char escapeChar,
            RowEndings rowEndings,
            ReadHeaders hasHeaders
            )
        {
            RowEndings = rowEndings;
            HasHeaders = hasHeaders;

            switch (HasHeaders)
            {
            case ReadHeaders.Always:
                CurrentState = State.Header_Start;
                break;

            case ReadHeaders.Never:
                CurrentState = State.Record_Start;
                break;

            default:
                Throw.InvalidOperationException($"Unexpected {nameof(ReadHeaders)}: {HasHeaders}");
                break;
            }

            TransitionMatrixHandle = GetTransitionMatrix(RowEndings, escapeStartChar == escapeChar).Pin();
            TransitionMatrix       = (TransitionRule *)TransitionMatrixHandle.Pointer;

            SuppressCharLookupDispose = true;
            (MinimumCharacter, CharLookupOffset, _, _, CharLookup) = preAllocLookup;
        }
Пример #3
0
        internal unsafe void Initialize(
            CharacterLookup preAllocLookup,
            char?escapeStartChar,
            char?escapeChar,
            ReadRowEnding rowEndings,
            ReadHeader hasHeaders,
            bool readingComments,
            bool skipLeadingWhitespace,
            bool skipTrailingWhitespace
            )
        {
            CharacterLookup = preAllocLookup;
            CharLookup      = (CharacterType *)preAllocLookup.Memory;
            RowEndings      = rowEndings;
            HasHeaders      = hasHeaders;

            switch (HasHeaders)
            {
            case ReadHeader.Always:
                CurrentState = State.Header_Start;
                break;

            case ReadHeader.Never:
                CurrentState = State.Record_Start;
                break;

            default:
                Throw.InvalidOperationException($"Unexpected {nameof(ReadHeader)}: {HasHeaders}");
                break;
            }

            TransitionMatrix =
                GetTransitionMatrix(
                    RowEndings,
                    escapeStartChar.HasValue && escapeStartChar == escapeChar,
                    readingComments,
                    skipLeadingWhitespace,
                    skipTrailingWhitespace,
#if DEBUG
                    out TransitionMatrixMemoryOffset
#else
                    out _
#endif
                    );
        }