-
Notifications
You must be signed in to change notification settings - Fork 0
/
hub.hpp
65 lines (39 loc) · 1.14 KB
/
hub.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
#ifndef HUB_HPP
#define HUB_HPP
// includes
#include <string>
#include <utility>
#include "libmy.hpp"
namespace hub {
// types
using Pair = std::pair<std::string, std::string>;
class Scanner {
private:
const std::string m_string;
int m_pos {0};
public:
explicit Scanner (const std::string & s);
std::string get_command ();
Pair get_pair ();
std::string get_name ();
std::string get_value ();
bool eos (); // skips blanks before testing
static bool is_name (const std::string & s);
private:
void skip_blank ();
void skip_char ();
char get_char ();
bool is_end () const;
char peek_char () const;
static bool is_blank (char c);
static bool is_id (char c);
};
// functions
void error (const std::string & msg);
std::string read ();
void write (const std::string & line);
void add_pair (std::string & line, const std::string & name, int value);
void add_pair (std::string & line, const std::string & name, double value, int precision);
void add_pair (std::string & line, const std::string & name, const std::string & value);
} // namespace hub
#endif // !defined HUB_HPP