-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput_handler.h
More file actions
42 lines (34 loc) · 1.25 KB
/
Copy pathinput_handler.h
File metadata and controls
42 lines (34 loc) · 1.25 KB
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
#ifndef INPUT_HANDLER_H
#define INPUT_HANDLER_H
#include <iostream>
#include <limits> // for std::numeric_limits
#include <sstream>
#include <unordered_map>
//#include <string> // in case we want to use std::char_traits<char>::eof
class InputHandler
{
public:
// constructors
InputHandler(std::unordered_map<std::string_view,char> dict,
char delimIn='\n', char delimOut='\n');
// InputHandler(const std::array<T>& keysm const std::array<U>& items, char delim);
// getters
const std::unordered_map<std::string_view,int>& get_dict() const;
// when a template, it will be
// const std::unordered_map<T,U>& get_dict() const;
// operator overloads
friend std::istringstream& operator>>(std::istream&, InputHandler&);
friend std::ostream& operator<<(std::ostream&, InputHandler&);
private:
std::unordered_map<std::string_view,char> m_dict {};
const char m_delimIn {};
const char m_delimOut {};
std::istringstream m_translatedStream {};
// private methods
void clean_istream(std::istream&);
//
// when a template it will be
// std::unordered_map<T,U> m_dict {};
// void clean_stream(V) // V allowed to be only a class derived from basic_istream
};
#endif