-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLanguages.cpp
More file actions
30 lines (27 loc) · 736 Bytes
/
Languages.cpp
File metadata and controls
30 lines (27 loc) · 736 Bytes
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
#include "Languages.h"
#include "Utilities/Unicode.h"
#include <algorithm>
#include <sstream>
using namespace std;
namespace Languages {
bool isSubsetOf(const Alphabet& lhs, const Alphabet& rhs) {
return all_of(lhs.begin(), lhs.end(), [&](char32_t ch) {
return rhs.count(ch);
});
}
Alphabet toAlphabet(const string& chars) {
istringstream in(chars);
Languages::Alphabet result;
while (in.peek() != EOF) {
result.insert(readChar(in));
}
return result;
}
string toString(const Alphabet& alphabet) {
string result;
for (char32_t ch: alphabet) {
result += toUTF8(ch);
}
return result;
}
}