// 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 CsvHelper.TypeConversion; namespace CsvHelper { /// /// Defines methods used to read parsed data /// from a CSV file row. /// public interface IReaderRow { /// /// Gets the column count of the current row. /// This should match . /// int ColumnCount { get; } /// /// Gets the field index the reader is currently on. /// int CurrentIndex { get; } /// /// Gets the header record. /// string[]? HeaderRecord { get; } /// /// Gets the parser. /// IParser Parser { get; } /// /// Gets the reading context. /// CsvContext Context { get; } /// /// Gets or sets the configuration. /// IReaderConfiguration Configuration { get; } /// /// Gets the raw field at position (column) index. /// /// The zero based index of the field. /// The raw field. string? this[int index] { get; } /// /// Gets the raw field at position (column) name. /// /// The named index of the field. /// The raw field. string? this[string name] { get; } /// /// Gets the raw field at position (column) name. /// /// The named index of the field. /// The zero based index of the field. /// The raw field. string? this[string name, int index] { get; } /// /// Gets the raw field at position (column) index. /// /// The zero based index of the field. /// The raw field. string? GetField(int index); /// /// Gets the raw field at position (column) name. /// /// The named index of the field. /// The raw field. string? GetField(string name); /// /// Gets the raw field at position (column) name and the index /// instance of that field. The index is used when there are /// multiple columns with the same header name. /// /// The named index of the field. /// The zero based index of the instance of the field. /// The raw field. string? GetField(string name, int index); /// /// Gets the field converted to using /// the specified . /// /// The type of the field. /// The index of the field. /// The field converted to . object? GetField(Type type, int index); /// /// Gets the field converted to using /// the specified . /// /// The type of the field. /// The named index of the field. /// The field converted to . object? GetField(Type type, string name); /// /// Gets the field converted to using /// the specified . /// /// The type of the field. /// The named index of the field. /// The zero based index of the instance of the field. /// The field converted to . object? GetField(Type type, string name, int index); /// /// Gets the field converted to using /// the specified . /// /// The type of the field. /// The index of the field. /// The used to convert the field to . /// The field converted to . object? GetField(Type type, int index, ITypeConverter converter); /// /// Gets the field converted to using /// the specified . /// /// The type of the field. /// The named index of the field. /// The used to convert the field to . /// The field converted to . object? GetField(Type type, string name, ITypeConverter converter); /// /// Gets the field converted to using /// the specified . /// /// The type of the field. /// The named index of the field. /// The zero based index of the instance of the field. /// The used to convert the field to . /// The field converted to . object? GetField(Type type, string name, int index, ITypeConverter converter); /// /// Gets the field converted to T at position (column) index. /// /// The of the field. /// The zero based index of the field. /// The field converted to T. T? GetField(int index); /// /// Gets the field converted to T at position (column) name. /// /// The of the field. /// The named index of the field. /// The field converted to T. T? GetField(string name); /// /// Gets the field converted to T at position /// (column) name and the index instance of that field. The index /// is used when there are multiple columns with the same header name. /// /// /// The named index of the field. /// The zero based index of the instance of the field. /// T? GetField(string name, int index); /// /// Gets the field converted to T at position (column) index using /// the given . /// /// The of the field. /// The zero based index of the field. /// The used to convert the field to T. /// The field converted to T. T? GetField(int index, ITypeConverter converter); /// /// Gets the field converted to T at position (column) name using /// the given . /// /// The of the field. /// The named index of the field. /// The used to convert the field to T. /// The field converted to T. T? GetField(string name, ITypeConverter converter); /// /// Gets the field converted to T at position /// (column) name and the index instance of that field. The index /// is used when there are multiple columns with the same header name. /// /// The of the field. /// The named index of the field. /// The zero based index of the instance of the field. /// The used to convert the field to T. /// The field converted to T. T? GetField(string name, int index, ITypeConverter converter); /// /// Gets the field converted to T at position (column) index using /// the given . /// /// The of the field. /// The used to convert the field to T. /// The zero based index of the field. /// The field converted to T. T? GetField(int index) where TConverter : ITypeConverter; /// /// Gets the field converted to T at position (column) name using /// the given . /// /// The of the field. /// The used to convert the field to T. /// The named index of the field. /// The field converted to T. T? GetField(string name) where TConverter : ITypeConverter; /// /// Gets the field converted to T at position /// (column) name and the index instance of that field. The index /// is used when there are multiple columns with the same header name. /// /// The of the field. /// The used to convert the field to T. /// The named index of the field. /// The zero based index of the instance of the field. /// The field converted to T. T? GetField(string name, int index) where TConverter : ITypeConverter; /// /// Gets the field converted to T at position (column) index. /// /// The of the field. /// The zero based index of the field. /// The field converted to type T. /// A value indicating if the get was successful. bool TryGetField(Type type, int index, out object? field); /// /// Gets the field converted to T at position (column) name. /// /// The of the field. /// The named index of the field. /// The field converted to T. /// A value indicating if the get was successful. bool TryGetField(Type type, string name, out object? field); /// /// Gets the field converted to T at position /// (column) name and the index instance of that field. The index /// is used when there are multiple columns with the same header name. /// /// The of the field. /// The named index of the field. /// The zero based index of the instance of the field. /// The field converted to T. /// A value indicating if the get was successful. bool TryGetField(Type type, string name, int index, out object? field); /// /// Gets the field converted to T at position (column) index /// using the specified . /// /// The of the field. /// The zero based index of the field. /// The used to convert the field to T. /// The field converted to T. /// A value indicating if the get was successful. bool TryGetField(Type type, int index, ITypeConverter converter, out object? field); /// /// Gets the field converted to T at position (column) name /// using the specified . /// /// The of the field. /// The named index of the field. /// The used to convert the field to T. /// The field converted to T. /// A value indicating if the get was successful. bool TryGetField(Type type, string name, ITypeConverter converter, out object? field); /// /// Gets the field converted to T at position (column) name /// using the specified . /// /// The of the field. /// The named index of the field. /// The zero based index of the instance of the field. /// The used to convert the field to T. /// The field converted to T. /// A value indicating if the get was successful. bool TryGetField(Type type, string name, int index, ITypeConverter converter, out object? field); /// /// Gets the field converted to T at position (column) index. /// /// The of the field. /// The zero based index of the field. /// The field converted to type T. /// A value indicating if the get was successful. bool TryGetField(int index, out T? field); /// /// Gets the field converted to T at position (column) name. /// /// The of the field. /// The named index of the field. /// The field converted to T. /// A value indicating if the get was successful. bool TryGetField(string name, out T? field); /// /// Gets the field converted to T at position /// (column) name and the index instance of that field. The index /// is used when there are multiple columns with the same header name. /// /// /// The named index of the field. /// The zero based index of the instance of the field. /// The field converted to T. /// A value indicating if the get was successful. bool TryGetField(string name, int index, out T? field); /// /// Gets the field converted to T at position (column) index /// using the specified . /// /// The of the field. /// The zero based index of the field. /// The used to convert the field to T. /// The field converted to T. /// A value indicating if the get was successful. bool TryGetField(int index, ITypeConverter converter, out T? field); /// /// Gets the field converted to T at position (column) name /// using the specified . /// /// The of the field. /// The named index of the field. /// The used to convert the field to T. /// The field converted to T. /// A value indicating if the get was successful. bool TryGetField(string name, ITypeConverter converter, out T? field); /// /// Gets the field converted to T at position (column) name /// using the specified . /// /// The of the field. /// The named index of the field. /// The zero based index of the instance of the field. /// The used to convert the field to T. /// The field converted to T. /// A value indicating if the get was successful. bool TryGetField(string name, int index, ITypeConverter converter, out T? field); /// /// Gets the field converted to T at position (column) index /// using the specified . /// /// The of the field. /// The used to convert the field to T. /// The zero based index of the field. /// The field converted to T. /// A value indicating if the get was successful. bool TryGetField(int index, out T? field) where TConverter : ITypeConverter; /// /// Gets the field converted to T at position (column) name /// using the specified . /// /// The of the field. /// The used to convert the field to T. /// The named index of the field. /// The field converted to T. /// A value indicating if the get was successful. bool TryGetField(string name, out T? field) where TConverter : ITypeConverter; /// /// Gets the field converted to T at position (column) name /// using the specified . /// /// The of the field. /// The used to convert the field to T. /// The named index of the field. /// The zero based index of the instance of the field. /// The field converted to T. /// A value indicating if the get was successful. bool TryGetField(string name, int index, out T? field) where TConverter : ITypeConverter; /// /// Gets the record converted into T. /// /// The of the record. /// The record converted to T. T? GetRecord(); /// /// Get the record converted into T. /// /// The of the record. /// The anonymous type definition to use for the record. /// The record converted to T. T? GetRecord(T anonymousTypeDefinition); /// /// Gets the record. /// /// The of the record. /// The record. object? GetRecord(Type type); } }