blob: 040a701b374e3e643829ee70969ed38a9ebb6907 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
// Copyright 2009-2022 Josh Close
// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
// https://github.com/JoshClose/CsvHelper
using System;
using CsvHelper.Configuration;
using System.Threading.Tasks;
namespace CsvHelper
{
/// <summary>
/// Defines methods used the parse a CSV file.
/// </summary>
public interface IParser : IDisposable
{
/// <summary>
/// Gets the count of how many bytes have been read.
/// <see cref="IParserConfiguration.CountBytes"/> needs
/// to be enabled for this value to be populated.
/// </summary>
long ByteCount { get; }
/// <summary>
/// Gets the count of how many characters have been read.
/// </summary>
long CharCount { get; }
/// <summary>
/// Gets the number of fields for the current row.
/// </summary>
int Count { get; }
/// <summary>
/// Gets the field at the specified index for the current row.
/// </summary>
/// <param name="index">The index.</param>
/// <returns>The field.</returns>
string this[int index] { get; }
/// <summary>
/// Gets the record for the current row. Note:
/// It is much more efficient to only get the fields you need. If
/// you need all fields, then use this.
/// </summary>
string[]? Record { get; }
/// <summary>
/// Gets the raw record for the current row.
/// </summary>
string RawRecord { get; }
/// <summary>
/// Gets the CSV row the parser is currently on.
/// </summary>
int Row { get; }
/// <summary>
/// Gets the raw row the parser is currently on.
/// </summary>
int RawRow { get; }
/// <summary>
/// The delimiter the parser is using.
/// </summary>
string Delimiter { get; }
/// <summary>
/// Gets the reading context.
/// </summary>
CsvContext Context { get; }
/// <summary>
/// Gets the configuration.
/// </summary>
IParserConfiguration Configuration { get; }
/// <summary>
/// Reads a record from the CSV file.
/// </summary>
/// <returns>True if there are more records to read, otherwise false.</returns>
bool Read();
/// <summary>
/// Reads a record from the CSV file asynchronously.
/// </summary>
/// <returns>True if there are more records to read, otherwise false.</returns>
Task<bool> ReadAsync();
}
}
|