1 /********************************************************************\
2  * gnc-tokenizer-csv.hpp - takes a csv file and converts it into a  *
3  *                         two-dimensional vector of strings (table)*
4  *                                                                  *
5  * This program is free software; you can redistribute it and/or    *
6  * modify it under the terms of the GNU General Public License as   *
7  * published by the Free Software Foundation; either version 2 of   *
8  * the License, or (at your option) any later version.              *
9  *                                                                  *
10  * This program is distributed in the hope that it will be useful,  *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
13  * GNU General Public License for more details.                     *
14  *                                                                  *
15  * You should have received a copy of the GNU General Public License*
16  * along with this program; if not, contact:                        *
17  *                                                                  *
18  * Free Software Foundation           Voice:  +1-617-542-5942       *
19  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
20  * Boston, MA  02110-1301,  USA       gnu@gnu.org                   *
21 \********************************************************************/
22 
23 /** @file
24      @brief Class to convert a csv file into vector of string vectors.
25      One can define the separator characters to use to split each line
26      into multiple fields. Quote characters will be removed.
27      However, no gnucash specific interpretation is done yet, that's up
28      to the code using this class.
29      *
30      gnc-tokenizer-csv.hpp
31      @author Copyright (c) 2015 Geert Janssens <geert@kobaltwit.be>
32  */
33 
34 #ifndef GNC_CSV_TOKENIZER_HPP
35 #define GNC_CSV_TOKENIZER_HPP
36 
37 extern "C" {
38 #include <config.h>
39 }
40 
41 #include <iostream>
42 #include <fstream>      // fstream
43 #include <vector>
44 #include <string>
45 #include "gnc-tokenizer.hpp"
46 
47 class GncCsvTokenizer : public GncTokenizer
48 {
49 public:
50     GncCsvTokenizer() = default;                                  // default constructor
51     GncCsvTokenizer(const GncCsvTokenizer&) = default;            // copy constructor
52     GncCsvTokenizer& operator=(const GncCsvTokenizer&) = default; // copy assignment
53     GncCsvTokenizer(GncCsvTokenizer&&) = default;                 // move constructor
54     GncCsvTokenizer& operator=(GncCsvTokenizer&&) = default;      // move assignment
55     ~GncCsvTokenizer() = default;                                 // destructor
56 
57     void set_separators(const std::string& separators);
58     int  tokenize() override;
59 
60 private:
61     std::string m_sep_str = ",";
62 };
63 
64 #endif
65