Environment.cpp
1.61 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* File: Environment.cpp
* Author: mlenart
*
* Created on 22 styczeń 2014, 12:08
*/
#include "Environment.hpp"
#include "exceptions.hpp"
Environment::Environment(
const Tagset& analyzerTagset,
const Tagset& generatorTagset,
MorfeuszCharset charset)
: currentCharsetConverter(getCharsetConverter(charset)),
analyzerTagset(analyzerTagset),
generatorTagset(generatorTagset) {
}
const CharsetConverter* Environment::getCharsetConverter(MorfeuszCharset charset) const {
switch (charset) {
case UTF8:
return &this->utf8CharsetConverter;
case ISO8859_2:
return &this->isoCharsetConverter;
case CP1250:
return &this->cp1250CharsetConverter;
case CP852:
return &this->cp852CharsetConverter;
default:
throw MorfeuszException("invalid charset");
}
}
Environment::~Environment() {
}
void Environment::setCharset(MorfeuszCharset charset) {
this->currentCharsetConverter = this->getCharsetConverter(charset);
}
const CharsetConverter& Environment::getCharsetConverter() const {
return *this->currentCharsetConverter;
}
void Environment::setAnalyzerTagset(const Tagset& tagset) {
this->analyzerTagset = tagset;
}
const Tagset& Environment::getAnalyzerTagset() const {
return this->analyzerTagset;
}
void Environment::setGeneratorTagset(const Tagset& tagset) {
this->generatorTagset = tagset;
}
const Tagset& Environment::getGeneratorTagset() const {
return this->generatorTagset;
}
const CaseConverter& Environment::getCaseConverter() const {
return this->caseConverter;
}