-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroman.h
More file actions
35 lines (31 loc) · 1 KB
/
roman.h
File metadata and controls
35 lines (31 loc) · 1 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
#ifndef __roman_h__
#define __roman_h__
#include <utility>
#include <list>
#include <string>
class Roman {
public:
Roman() = default;
virtual ~Roman() = default;
std::string to_s(int n) const;
int to_i(const std::string& s) const;
protected:
using StdPair = std::pair<int,std::string>;
class Mapping : public StdPair {
public:
Mapping(int n, const std::string& s);
bool canReduce(int n) const;
bool canReduce(const std::string& s) const;
int reduce(int n) const;
std::string reduce(const std::string& s) const;
int apply(int n) const;
std::string apply(const std::string& s) const;
};
using Table = std::list<Mapping>;
const Table& table() const;
std::string to_roman(int n, const std::string& s, Table::const_iterator it, const Table::const_iterator end) const;
int from_roman(const std::string& s, int n, Table::const_iterator it, const Table::const_iterator end) const;
static const char * const empty_string_literal;
static const int starting_value;
};
#endif