blob: c6c80cd8e74223e3966d90bd149d46172525c618 (
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
|
#pragma once
#include <functional>
#include <string>
#include <vector>
namespace coding
{
class CSVReader
{
public:
struct Params
{
Params(){};
bool m_shouldReadHeader = false;
char m_delimiter = ',';
};
CSVReader() = default;
using LineByLineCallback = std::function<void(std::vector<std::string> const & line)>;
using FullFileCallback = std::function<void(std::vector<std::vector<std::string>> const & file)>;
void ReadLineByLine(std::string const & filePath, LineByLineCallback const & fn,
Params const & params = {}) const;
void ReadFullFile(std::string const & filePath, FullFileCallback const & fn,
Params const & params = {}) const;
};
} // namespace coding
|