summaryrefslogtreecommitdiff
path: root/plugins/Boltun/src/Engine/Mind.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Boltun/src/Engine/Mind.cpp')
-rw-r--r--plugins/Boltun/src/Engine/Mind.cpp130
1 files changed, 65 insertions, 65 deletions
diff --git a/plugins/Boltun/src/Engine/Mind.cpp b/plugins/Boltun/src/Engine/Mind.cpp
index f9a46df967..120dbc85ef 100644
--- a/plugins/Boltun/src/Engine/Mind.cpp
+++ b/plugins/Boltun/src/Engine/Mind.cpp
@@ -22,8 +22,8 @@
using namespace std;
-typedef vector<tstring> string_vec;
-typedef multimap<tstring, tstring> string_mmap;
+typedef vector<wstring> string_vec;
+typedef multimap<wstring, wstring> string_mmap;
Mind::Mind()
{
@@ -58,51 +58,51 @@ Mind& Mind::operator= (const Mind& mind)
return *this;
}
-inline void format(tstring& s)
+inline void format(wstring& s)
{
int pos = (int)s.length() - 1;
- if (s[pos] == _T('\r'))
+ if (s[pos] == '\r')
s.resize(pos);
}
-void toLowerStr(TCHAR* ch)
+void toLowerStr(wchar_t* ch)
{
CharLower(ch);
}
-vector<tstring> Mind::Parse(tstring s)
+vector<wstring> Mind::Parse(wstring s)
{
int len = (int)s.length() - 1;
- vector <tstring> res;
- while (len != -1 && _istspace(s[len]))
+ vector <wstring> res;
+ while (len != -1 && iswspace(s[len]))
len--;
if (len < 0)
return res;
s.resize(len);
int it = 0;
while (it != len) {
- while (it != len && _istspace(s[it]))
+ while (it != len && iswspace(s[it]))
it++;
if (it == len)
break;
int start = it;
- while (it != len && !_istspace(s[it]))
+ while (it != len && !iswspace(s[it]))
it++;
res.push_back(s.substr(start, it - start));
}
return res;
}
-void Mind::Load(tstring filename)
+void Mind::Load(wstring filename)
{
- basic_ifstream<TCHAR, char_traits<TCHAR> > file;
+ basic_ifstream<wchar_t, char_traits<wchar_t> > file;
locale ulocale(locale(), new MyCodeCvt);
file.imbue(ulocale);
file.open(filename.c_str(), ios_base::in | ios_base::binary);
- tstring s1, st;
- TCHAR *c, *co = NULL;
+ wstring s1, st;
+ wchar_t *c, *co = NULL;
size_t count;
int error = 0;
int line = 1;
@@ -128,10 +128,10 @@ void Mind::Load(tstring filename)
format(st);
count = st.length();
- c = co = new TCHAR[count + 1];
+ c = co = new wchar_t[count + 1];
mir_tstrcpy(c, st.c_str());
size_t pos = 0;
- while (pos < count && _istspace(*c)) {
+ while (pos < count && iswspace(*c)) {
++pos;
++c;
}
@@ -245,9 +245,9 @@ void Mind::Load(tstring filename)
toLowerStr(c);
{
std::transform(s1.begin(), s1.end(), s1.begin(), ::tolower);
- vector<tstring> strs = Parse(s1);
+ vector<wstring> strs = Parse(s1);
data->raliases.insert(make_pair(s1, strs));
- for (vector<tstring>::const_iterator it = strs.begin(); it != strs.end(); ++it)
+ for (vector<wstring>::const_iterator it = strs.begin(); it != strs.end(); ++it)
data->aliases.insert(make_pair(*it, s1));
}
break;
@@ -281,9 +281,9 @@ void Mind::Load(tstring filename)
}
}
-void Mind::Save(tstring filename) const
+void Mind::Save(wstring filename) const
{
- basic_ofstream<TCHAR, char_traits<TCHAR> > file;
+ basic_ofstream<wchar_t, char_traits<wchar_t> > file;
locale ulocale(locale(), new MyCodeCvt);
file.imbue(ulocale);
@@ -291,61 +291,61 @@ void Mind::Save(tstring filename) const
file.open(filename.c_str(), ios_base::out | ios_base::binary);
if (fileTypeMark)
- file << TCHAR(65279);
+ file << wchar_t(65279);
for (string_mmap::iterator it = data->study.begin(); it != data->study.end(); ++it) {
- file << (*it).first << _T('\r') << endl;
- file << (*it).second << _T('\r') << endl;
+ file << (*it).first << '\r' << endl;
+ file << (*it).second << '\r' << endl;
}
- for (multimap<WordsList, tstring>::iterator it = data->keywords.begin(); it != data->keywords.end(); ++it) {
- file << L" (" << (tstring)(*it).first << L")" << _T('\r') << endl;
- file << (*it).second << _T('\r') << endl;
+ for (multimap<WordsList, wstring>::iterator it = data->keywords.begin(); it != data->keywords.end(); ++it) {
+ file << L" (" << (wstring)(*it).first << L")" << '\r' << endl;
+ file << (*it).second << '\r' << endl;
}
- for (multimap<WordsList, tstring>::iterator it = data->qkeywords.begin(); it != data->qkeywords.end(); ++it) {
- file << L" (" << (tstring)(*it).first << L")" << _T('\r') << endl;
- file << (*it).second << _T('\r') << endl;
+ for (multimap<WordsList, wstring>::iterator it = data->qkeywords.begin(); it != data->qkeywords.end(); ++it) {
+ file << L" (" << (wstring)(*it).first << L")" << '\r' << endl;
+ file << (*it).second << '\r' << endl;
}
- for (multimap<WordsList, tstring>::iterator it = data->specialEscapes.begin(); it != data->specialEscapes.end(); ++it) {
- file << L" {" << (tstring)(*it).first << L"}" << _T('\r') << endl;
- file << (*it).second << _T('\r') << endl;
+ for (multimap<WordsList, wstring>::iterator it = data->specialEscapes.begin(); it != data->specialEscapes.end(); ++it) {
+ file << L" {" << (wstring)(*it).first << L"}" << '\r' << endl;
+ file << (*it).second << '\r' << endl;
}
- for (multimap<WordsList, tstring>::iterator it = data->qspecialEscapes.begin(); it != data->qspecialEscapes.end(); ++it) {
- file << L" {" << (tstring)(*it).first << L"}" << _T('\r') << endl;
- file << (*it).second << _T('\r') << endl;
+ for (multimap<WordsList, wstring>::iterator it = data->qspecialEscapes.begin(); it != data->qspecialEscapes.end(); ++it) {
+ file << L" {" << (wstring)(*it).first << L"}" << '\r' << endl;
+ file << (*it).second << '\r' << endl;
}
for (string_mmap::iterator it = data->widelyUsed.begin(); it != data->widelyUsed.end(); ++it) {
- file << L" [" << (*it).first << L"]" << _T('\r') << endl;
- file << (*it).second << _T('\r') << endl;
+ file << L" [" << (*it).first << L"]" << '\r' << endl;
+ file << (*it).second << '\r' << endl;
}
- for (set<tstring>::iterator it = data->question.begin(); it != data->question.end(); ++it) {
- file << L" <QUESTION>" << _T('\r') << endl;
- file << (*it) << _T('\r') << endl;
+ for (set<wstring>::iterator it = data->question.begin(); it != data->question.end(); ++it) {
+ file << L" <QUESTION>" << '\r' << endl;
+ file << (*it) << '\r' << endl;
}
- for (set<tstring>::iterator it = data->special.begin(); it != data->special.end(); ++it) {
- file << L" <IGNORED>" << _T('\r') << endl;
- file << (*it) << _T('\r') << endl;
+ for (set<wstring>::iterator it = data->special.begin(); it != data->special.end(); ++it) {
+ file << L" <IGNORED>" << '\r' << endl;
+ file << (*it) << '\r' << endl;
}
for (string_vec::iterator it = data->escape.begin(); it != data->escape.end(); ++it) {
- file << L" <ESCAPE>" << _T('\r') << endl;
- file << (*it) << _T('\r') << endl;
+ file << L" <ESCAPE>" << '\r' << endl;
+ file << (*it) << '\r' << endl;
}
for (string_vec::iterator it = data->initial.begin(); it != data->initial.end(); ++it) {
- file << L" <INITIAL>" << _T('\r') << endl;
- file << (*it) << _T('\r') << endl;
+ file << L" <INITIAL>" << '\r' << endl;
+ file << (*it) << '\r' << endl;
}
for (string_vec::iterator it = data->failure.begin(); it != data->failure.end(); ++it) {
- file << L" <FAILURE>" << _T('\r') << endl;
- file << (*it) << _T('\r') << endl;
+ file << L" <FAILURE>" << '\r' << endl;
+ file << (*it) << '\r' << endl;
}
for (string_vec::iterator it = data->repeats.begin(); it != data->repeats.end(); ++it) {
- file << L" <REPEAT>" << _T('\r') << endl;
- file << (*it) << _T('\r') << endl;
+ file << L" <REPEAT>" << '\r' << endl;
+ file << (*it) << '\r' << endl;
}
- for (map<tstring, vector<tstring>>::const_iterator it = data->raliases.begin(); it != data->raliases.end(); ++it) {
- tstring s;
- const vector<tstring>& v = (*it).second;
+ for (map<wstring, vector<wstring>>::const_iterator it = data->raliases.begin(); it != data->raliases.end(); ++it) {
+ wstring s;
+ const vector<wstring>& v = (*it).second;
bool first = true;
- for (vector<tstring>::const_iterator it1 = v.begin(); it1 != v.end(); ++it1) {
+ for (vector<wstring>::const_iterator it1 = v.begin(); it1 != v.end(); ++it1) {
if (first) {
first = false;
s = *it1;
@@ -354,17 +354,17 @@ void Mind::Save(tstring filename) const
s += L" " + *it1;
}
}
- file << _T('@') << (*it).first << _T('\r') << endl;
- file << s << _T('\r') << endl;
+ file << '@' << (*it).first << '\r' << endl;
+ file << s << '\r' << endl;
}
}
-void Mind::LoadSmiles(tstring filename)
+void Mind::LoadSmiles(wstring filename)
{
- basic_ifstream<TCHAR, char_traits<TCHAR> > file;
+ basic_ifstream<wchar_t, char_traits<wchar_t> > file;
file.open(filename.c_str());
data->smiles.clear();
- tstring s;
+ wstring s;
unsigned int l = 0;
while (!file.eof()) {
getline(file, s);
@@ -378,14 +378,14 @@ void Mind::LoadSmiles(tstring filename)
void Mind::LoadSmiles(void *smiles, size_t size)
{
data->smiles.clear();
- TCHAR* buf = (TCHAR*)smiles;
+ wchar_t* buf = (wchar_t*)smiles;
unsigned l = 0;
- TCHAR* end = buf + size;
+ wchar_t* end = buf + size;
while (buf != end) {
- TCHAR *lend = buf;
- while (lend != end && *lend != _T('\r'))
+ wchar_t *lend = buf;
+ while (lend != end && *lend != '\r')
lend++;
- tstring s(buf, lend - buf);
+ wstring s(buf, lend - buf);
if ((unsigned)(lend - buf) > l)
l = (int)s.length();
data->smiles.insert(s);