Ejemplo n.º 1
0
            public virtual State process(CsvParser p)
            {
                for (;;)
                {
                    int ch = p.ReadChar();
                    switch (ch)
                    {
                    case '\n':
                    case -1:
                        // End of line/file - add current field
                        p.AddField();
                        return(null);

                    case '\t':
                        // This must be a tab-delimited file - switch mode to tab delimited
                        TabStart.AddField(p);
                        p._startState = TabStart;
                        return(TabStart);

                    case ',':
                        // End of field
                        p.AddField();
                        return(Start);                                  // Initial field state

                    default:
                        // Add character to field
                        p.AddChar(ch);
                        continue;
                    }
                }
            }
Ejemplo n.º 2
0
            public override State process(CsvParser p)
            {
                for (;;)
                {
                    int ch = p.ReadChar();
                    switch (ch)
                    {
                    case '\n':
                    case -1:
                        if (p._line.Count > 0)
                        {
                            p.AddField();
                        }
                        return(null);

                    case '\t':
                        // This must be a tab-delimited file - switch mode to tab delimited
                        TabStart.AddField(p);
                        p._startState = TabStart;
                        return(TabStart);

                    case ',':
                        // Empty field
                        p.AddField();
                        continue;

                    case '"':
                        return(QuotedField);

                    default:
                        // Anything else is a normal field - switch state to field processor
                        p.AddChar(ch);
                        return(FieldData);
                    }
                }
            }