One of my C# DLL functions reads a CSV file using CSvHelper. Eg:
using (var reader = new StreamReader(strPath))
using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
{
var records = csv.GetRecords<CLMExplorerStudent>();
foreach (var record in records)
{
}
}
I have no problem with that. My MFC C++ project runs this method in the DLL and it opens teh CSV, parses it and does what is needed. Because evrything is managed by that one function internally.
But now I want to write some more functions in my DLL to break it down. Eg, in MFC:
dll->LoadCSV(path to csv)
for(dll->NextRow(row))
{
MFC now does something with the row data
}
dll->CloseCSV();
Originally I thought that the DLL could just pass the read in data over to the MFC parent app but then I thought that not sensible approach. So I thought that it may be possible to get my DLL to open the CSV first, and then I can sequentially get the next row of data, until finished and then close the CSV. So no memory leaks.
But I am not sure how to turn the logic of my sample code into the 3 functions as it is using a using wrapper at the moment.
I hope this makes sense!