Example #1
0
            public override State process(CsvParser p)
            {
                for (;;)
                {
                    int ch = p.ReadChar();
                    switch (ch)
                    {
                    case -1:
                        p.AddField();
                        return(null);

                    case '"':
                        ch = p.ReadChar();
                        switch (ch)
                        {
                        case '\n':
                        case -1:
                            // Quote at end of line/file just terminates the field
                            p.AddField();
                            return(null);

                        case ',':
                            // Quote, comma is just end of field
                            p.AddField();
                            return(Start);

                        case '\t':
                            // Must be a tab-delimited file - switch
                            p.AddField();
                            return(TabStart);

                        case '"':
                            // Quote Quote = Quote
                            p.AddChar('"');
                            continue;

                        default:
                            // Quote anychar is a syntax error, but we allow it and pass through unchanged
                            p.AddChar('"');
                            p.AddChar(ch);
                            continue;
                        }

                    default:
                        // This includes newlines and tabs!
                        p.AddChar(ch);
                        continue;
                    }
                }
            }
Example #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._field.Length > 0)
                        {
                            AddField(p);
                        }
                        return(null);

                    case '\t':
                        AddField(p);
                        continue;

                    default:
                        p.AddChar(ch);
                        continue;
                    }
                }
            }
Example #3
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;
                    }
                }
            }
Example #4
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);
                    }
                }
            }
Example #5
0
 public override State process(CsvParser p)
 {
     for (; ; ) {
         int ch = p.ReadChar();
         switch (ch) {
             case '\n':
             case -1:
                 if (p._line.Count > 0 || p._field.Length > 0) AddField(p);
                 return null;
             case '\t':
                 AddField(p);
                 continue;
             default:
                 p.AddChar(ch);
                 continue;
         }
     }
 }
Example #6
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;
         }
     }
 }
Example #7
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;
         }
     }
 }
Example #8
0
 public override State process(CsvParser p)
 {
     for(;;) {
         int ch = p.ReadChar();
         switch(ch) {
             case -1:
                 p.AddField();
                 return null;
             case '"':
                 ch = p.ReadChar();
                 switch(ch) {
                     case '\n':
                     case -1:
                         // Quote at end of line/file just terminates the field
                         p.AddField();
                         return null;
                     case ',':
                         // Quote, comma is just end of field
                         p.AddField();
                         return Start;
                     case '\t':
                         // Must be a tab-delimited file - switch
                         p.AddField();
                         return TabStart;
                     case '"':
                         // Quote Quote = Quote
                         p.AddChar('"');
                         continue;
                     default:
                         // Quote anychar is a syntax error, but we allow it and pass through unchanged
                         p.AddChar('"');
                         p.AddChar(ch);
                         continue;
                 }
             default:
                 // This includes newlines and tabs!
                 p.AddChar(ch);
                 continue;
         }
     }
 }