Welcome to mirror list, hosted at ThFree Co, Russian Federation.

csv_reader.cpp « coding - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7cc135b5069ef4675e4559c92cbf6e5c9edda5d6 (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
#include "coding/csv_reader.hpp"

#include "base/logging.hpp"
#include "base/string_utils.hpp"

namespace coding
{
using namespace std;

void CSVReader::Read(istringstream & stream, RowByRowCallback const & fn,
                     Params const & params) const
{
  bool readFirstRow = params.m_readHeader;

  for (string line; getline(stream, line);)
  {
    Row row;
    strings::ParseCSVRow(line, params.m_delimiter, row);
    if (!readFirstRow)
    {
      readFirstRow = true;
      continue;
    }
    fn(move(row));
  }
}

void CSVReader::Read(istringstream & stream, FullFileCallback const & fn,
                     Params const & params) const
{
  File file;
  Read(stream, [&file](Row && row)
  {
    file.emplace_back(move(row));
  }, params);

  fn(move(file));
}
}  // namespace coding