-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStringsModyfier.hpp
67 lines (57 loc) · 1.39 KB
/
StringsModyfier.hpp
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef STRINGS_MODYFIER_HPP
#define STRINGS_MODYFIER_HPP
#include <vector>
#include <string>
namespace artemreyt
{
using std::vector, std::string;
class StringsModyfier
{
public:
explicit StringsModyfier(const string &_separator);
void add_string(const string& str);
void insert(size_t pos_str, size_t field_after, string &str);
string at(size_t pos_str) const;
string at_full(size_t pos_str) const;
void edit(size_t pos_str, size_t pos_field, const string &str);
void erase(size_t pos_str, size_t pos_field);
size_t size() const;
private:
bool check_exist(size_t pos_str) const;
bool check_exist(size_t pos_str, size_t pos_field) const;
vector<vector<string>> data;
string separator;
};
enum class t_cmd : int
{
CMD_ADD_STRING = 1,
CMD_PRINT_STRINGS,
CMD_PRINT_STRING_BY_ID,
CMD_EDIT_STRING,
CMD_ERASE,
CMD_INSERT,
CMD_CLEAR_SCREEN,
CMD_EXIT,
CMD_INIT = -1
};
class InteractiveModeHelper
{
public:
InteractiveModeHelper(const string& _separator="\t");
void print_instructions();
void ask_cmd(int first, int last) const;
void add_string();
void print_all() const;
void print_all_before_exit() const;
void print_by_id() const;
void edit_string();
void erase();
void insert();
static void clear_screen();
void run_cmd();
private:
StringsModyfier modyfier;
mutable t_cmd cur_cmd;
};
};
#endif