Exemplo n.º 1
0
        protected ReaderBase(BoundConfigurationBase <T> config, object context)
        {
            RowNumber     = 0;
            Configuration = config;
            Context       = context;

            var bufferSize = config.ReadBufferSizeHint;

            if (bufferSize == 0)
            {
                bufferSize = DEFAULT_BUFFER_SIZE;
            }

            Buffer  = new BufferWithPushback(config.MemoryPool, bufferSize);
            Partial = new Partial <T>(config.MemoryPool);

            SharedCharacterLookup =
                ReaderStateMachine.MakeCharacterLookup(
                    config.MemoryPool,
                    config.EscapedValueStartAndStop,
                    config.ValueSeparator,
                    config.EscapeValueEscapeChar,
                    config.CommentChar
                    );
        }
Exemplo n.º 2
0
        internal HeadersReader(
            BoundConfigurationBase <T> config,
            ReaderStateMachine.CharacterLookup charLookup,
            TextReader inner,
            BufferWithPushback buffer
            )
        {
            MemoryPool     = config.MemoryPool;
            BufferSizeHint = config.ReadBufferSizeHint;
            Columns        = config.DeserializeColumns;
            Inner          = inner;

            StateMachine =
                new ReaderStateMachine(
                    charLookup,
                    config.EscapedValueStartAndStop,
                    config.EscapeValueEscapeChar,
                    config.RowEnding,
                    ReadHeaders.Never
                    );

            Buffer = buffer;

            HeaderCount    = 0;
            PushBackLength = 0;
        }
Exemplo n.º 3
0
 internal HeadersReader(
     ReaderStateMachine stateMachine,
     BoundConfigurationBase <T> config,
     CharacterLookup charLookup,
     IAsyncReaderAdapter inner,
     BufferWithPushback buffer,
     ReadRowEnding rowEndingOverride
     )
     : this(stateMachine, config, charLookup, null, inner, buffer, rowEndingOverride)
 {
 }
Exemplo n.º 4
0
        private HeadersReader(
            ReaderStateMachine stateMachine,
            BoundConfigurationBase <T> config,
            CharacterLookup charLookup,
            IReaderAdapter?inner,
            IAsyncReaderAdapter?innerAsync,
            BufferWithPushback buffer,
            ReadRowEnding rowEndingOverride
            )
        {
            LogHelper.StateTransition_NewHeadersReader();

            Configuration = config;

            Inner.SetAllowNull(inner);
            InnerAsync.SetAllowNull(innerAsync);

            var options = Configuration.Options;

            MemoryPool     = Configuration.MemoryPool;
            BufferSizeHint = options.ReadBufferSizeHint;
            Columns        = config.DeserializeColumns;

            StateMachine = stateMachine;
            stateMachine.Initialize(
                charLookup,
                options.EscapedValueStartAndEnd,
                options.EscapedValueEscapeCharacter,
                rowEndingOverride,                      // this can be something OTHER than what was provided, due to RowEnding.Detect
                ReadHeader.Never,
                false,
                options.WhitespaceTreatment.HasFlag(WhitespaceTreatments.TrimBeforeValues),
                options.WhitespaceTreatment.HasFlag(WhitespaceTreatments.TrimAfterValues)
                );

            Buffer = buffer;

            HeaderCount         = 0;
            PushBackLength      = 0;
            WhitespaceTreatment = options.WhitespaceTreatment;
        }
Exemplo n.º 5
0
        protected ReaderBase(BoundConfigurationBase <T> config, object?context, IRowConstructor <T> rowBuilder, ExtraColumnTreatment extraTreatment)
        {
            RowNumber     = 0;
            Configuration = config;
            Context       = context;

            var options = config.Options;

            var bufferSize = options.ReadBufferSizeHint;

            if (bufferSize == 0)
            {
                bufferSize = Utils.DEFAULT_BUFFER_SIZE;
            }

            // always need to be able to store a whole value separator "character"
            var bufferMinSize = config.ValueSeparatorMemory.Length * 2;

            if (bufferSize < bufferMinSize)
            {
                bufferSize = bufferMinSize;
            }

            var memPool = config.MemoryPool;

            Buffer =
                new BufferWithPushback(
                    memPool,
                    bufferSize
                    );
            Partial = new Partial(memPool);

            SharedCharacterLookup = CharacterLookup.MakeCharacterLookup(options, out _);
            StateMachine          = new ReaderStateMachine();
            RowBuilder            = rowBuilder;

            ExtraColumnTreatment = extraTreatment;
        }