Exemplo n.º 1
0
 public override int Get(TextReader reader, string[] values, TextParser.ColRow[] pos)
 {
     int count = 0;
     for (int k = 0; k < values.Length; k++)
     {
         values[k] = null;
         if (pos != null)
         {
             pos[k].col = 0;
             pos[k].line = LineIndex;
         }
     }
     int index = 0;
     String input = reader.ReadLine();
     if (input.Length > 0 && input[0] == CommentChar)
     {
         LineIndex++;
         return -1;
     }
     while (index < input.Length)
     {
         if (pos != null && count < pos.Length)
         {
             pos[count].line = LineIndex;
             pos[count].col = index;
         }
         if (input[index] == QuoteChar)
         {
             index++;
             m_stringBuilder.Length = 0;
             while (true)
             {
                 int k = input.IndexOf(QuoteChar, index);
                 if (k == -1)
                 {
                     m_stringBuilder.Append(input.Substring(index));
                     input = reader.ReadLine();
                     index = 0;
                     LineIndex++;
                 }
                 else
                 {
                     int next_ch;
                     if (k < input.Length -1)
                     {
                         next_ch = input[k + 1];
                         if (next_ch == QuoteChar)
                         {
                             m_stringBuilder.Append(input.Substring(index, k - index + 1));
                             if (index == input.Length - 1)
                             {
                                 input = reader.ReadLine();
                                 index = 0;
                                 LineIndex++;
                             }
                             else
                                 index = k + 2;
                         }
                         else
                         {
                             m_stringBuilder.Append(input.Substring(index, k - index));
                             index = k + 1;
                             break;
                         }
                     }
                     else
                     {
                         m_stringBuilder.Append(input.Substring(index, k - index));
                         index = k + 1;
                         break;
                     }
                 }
             }
             if (index < input.Length)
                 if (input[index] == Delimiter)
                     index++;
                 else
                     throw new ESQLException(Properties.Resources.InvalidTextFileFormat,
                         LineIndex + 1, index + 1);
             if (count < values.Length)
                 values[count++] = m_stringBuilder.ToString();
         }
         else
         {
             int k = input.IndexOf(Delimiter, index);
             if (k > -1)
             {
                 if (count < values.Length)
                     values[count++] = input.Substring(index, k - index);
                 index = k + 1;
             }
             else
             {
                 if (count < values.Length)
                     values[count++] = input.Substring(index);
                 break;
             }
         }
     }
     LineIndex++;
     return count;
 }
Exemplo n.º 2
0
 public ProcessingContextBase(StreamReader reader, int[] length, String nullValue, bool columnNameHeader,
     NumberFormatInfo nft, DateTimeFormatInfo dft)
     : base(null)
 {
     m_reader = reader;
     m_columnNameHeader = columnNameHeader;
     m_numberFormat = nft;
     m_dateTimeFormat = dft;
     m_parser = new FLVParser(length, TextDataAccessor.CommentChar);
 }
Exemplo n.º 3
0
 public override int Get(TextReader reader, string[] values, TextParser.ColRow[] pos)
 {
     return Get(reader.ReadLine(), values, LineIndex++, pos);
 }
Exemplo n.º 4
0
 public ProcessingContextBase(StreamReader reader, char delimiter, String nullValue, bool columnNameHeader,
     NumberFormatInfo nft, DateTimeFormatInfo dft)   
   : base(null)
 {
     m_reader = reader;
     m_columnNameHeader = columnNameHeader;
     m_numberFormat = nft;
     m_dateTimeFormat = dft;
     m_nullValue = nullValue;
     m_parser = new CsvParser(delimiter, TextDataAccessor.CommentChar);
 }