GnuCash  5.6-150-g038405b370+
gnc-tokenizer-fw.hpp
Go to the documentation of this file.
1 /********************************************************************\
2  * gnc-tokenizer-fw.hpp - takes a file and converts it into a *
3  * two-dimensional vector of strings (table) *
4  * splitting the contents on fixed width *
5  * positions *
6  * *
7  * This program is free software; you can redistribute it and/or *
8  * modify it under the terms of the GNU General Public License as *
9  * published by the Free Software Foundation; either version 2 of *
10  * the License, or (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License*
18  * along with this program; if not, contact: *
19  * *
20  * Free Software Foundation Voice: +1-617-542-5942 *
21  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
22  * Boston, MA 02110-1301, USA gnu@gnu.org *
23 \********************************************************************/
24 
37 #ifndef GNC_FW_TOKENIZER_HPP
38 #define GNC_FW_TOKENIZER_HPP
39 
40 #include <config.h>
41 
42 #include <iostream>
43 #include <fstream> // fstream
44 #include <vector>
45 #include <string>
46 #include <cstdint>
47 #include "gnc-tokenizer.hpp"
48 
50 {
51 public:
52  GncFwTokenizer() = default; // default constructor
53  GncFwTokenizer(const GncFwTokenizer&) = default; // copy constructor
54  GncFwTokenizer& operator=(const GncFwTokenizer&) = default; // copy assignment
55  GncFwTokenizer(GncFwTokenizer&&) = default; // move constructor
56  GncFwTokenizer& operator=(GncFwTokenizer&&) = default; // move assignment
57  ~GncFwTokenizer() = default; // destructor
58 
59  void columns(const std::vector<uint32_t>& cols = std::vector<uint32_t>());
60  std::vector<uint32_t> get_columns();
61  uint32_t get_column (uint32_t num);
62 
63  // Column manipulators
64  bool col_can_delete (uint32_t col_num);
65  void col_delete (uint32_t col_num);
66  bool col_can_narrow (uint32_t col_num);
67  void col_narrow (uint32_t col_num);
68  bool col_can_widen (uint32_t col_num);
69  void col_widen (uint32_t col_num);
70  bool col_can_split (uint32_t col_num, uint32_t position);
71  void col_split (uint32_t col_num, uint32_t position);
72 
73  void load_file (const std::string& path) override;
74  int tokenize() override;
75 
76 
77 private:
78  std::vector<uint32_t> m_col_vec;
79  uint32_t m_longest_line = 0;
80 };
81 
82 #endif
Class convert a file into vector of string vectors.