diff options
author | George Hazan <george.hazan@gmail.com> | 2016-07-26 09:20:25 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2016-07-26 09:20:25 +0000 |
commit | 6e53dfca72b932c4bdcd7aa02ca62bf8b2630eac (patch) | |
tree | 2e8bb660c908b54914abd562af8aafa4a486c846 /plugins/Boltun/src | |
parent | a61c8728b379057fe7f0a0d86fe0b037598229dd (diff) |
less TCHARs:
- TCHAR is replaced with wchar_t everywhere;
- LPGENT replaced with either LPGENW or LPGEN;
- fixes for ANSI plugins that improperly used _t functions;
- TCHAR *t removed from MAllStrings;
- ptszGroup, ptszTitle & ptszTab in OPTIONSDIALOGPAGE replaced with pwsz*
git-svn-id: http://svn.miranda-ng.org/main/trunk@17133 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Boltun/src')
-rw-r--r-- | plugins/Boltun/src/Engine/Mind.cpp | 130 | ||||
-rw-r--r-- | plugins/Boltun/src/Engine/Mind.h | 38 | ||||
-rw-r--r-- | plugins/Boltun/src/Engine/TalkEngine.cpp | 160 | ||||
-rw-r--r-- | plugins/Boltun/src/Engine/TalkEngine.h | 44 | ||||
-rw-r--r-- | plugins/Boltun/src/Engine/UnrecentChooser.cpp | 10 | ||||
-rw-r--r-- | plugins/Boltun/src/Engine/UnrecentChooser.h | 16 | ||||
-rw-r--r-- | plugins/Boltun/src/Engine/ValueChooser.h | 2 | ||||
-rw-r--r-- | plugins/Boltun/src/Engine/WordsList.cpp | 48 | ||||
-rw-r--r-- | plugins/Boltun/src/Engine/WordsList.h | 18 | ||||
-rw-r--r-- | plugins/Boltun/src/actionQueue.cpp | 6 | ||||
-rw-r--r-- | plugins/Boltun/src/actionQueue.h | 2 | ||||
-rw-r--r-- | plugins/Boltun/src/boltun.cpp | 56 | ||||
-rw-r--r-- | plugins/Boltun/src/config.cpp | 22 | ||||
-rw-r--r-- | plugins/Boltun/src/config.h | 8 | ||||
-rw-r--r-- | plugins/Boltun/src/stdafx.h | 12 |
15 files changed, 286 insertions, 286 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);
diff --git a/plugins/Boltun/src/Engine/Mind.h b/plugins/Boltun/src/Engine/Mind.h index d11eb6cd78..2b93c5fdcb 100644 --- a/plugins/Boltun/src/Engine/Mind.h +++ b/plugins/Boltun/src/Engine/Mind.h @@ -31,22 +31,22 @@ class Mind; typedef struct
{
friend class Mind;
- std::vector<std::tstring> initial;
- std::set<std::tstring> question;
- std::set<std::tstring> special;
- std::vector<std::tstring> escape;
- std::vector<std::tstring> failure;
- std::vector<std::tstring> repeats;
+ std::vector<std::wstring> initial;
+ std::set<std::wstring> question;
+ std::set<std::wstring> special;
+ std::vector<std::wstring> escape;
+ std::vector<std::wstring> failure;
+ std::vector<std::wstring> repeats;
unsigned int maxSmileLen;
- std::set<std::tstring> smiles;
- std::multimap<WordsList, std::tstring> keywords;
- std::multimap<WordsList, std::tstring> qkeywords;
- std::multimap<std::tstring, std::tstring> widelyUsed;
- std::multimap<WordsList, std::tstring> specialEscapes;
- std::multimap<WordsList, std::tstring> qspecialEscapes;
- std::multimap<std::tstring, std::tstring> study;
- std::map<std::tstring, std::tstring> aliases;
- std::map<std::tstring, std::vector<std::tstring>> raliases;
+ std::set<std::wstring> smiles;
+ std::multimap<WordsList, std::wstring> keywords;
+ std::multimap<WordsList, std::wstring> qkeywords;
+ std::multimap<std::wstring, std::wstring> widelyUsed;
+ std::multimap<WordsList, std::wstring> specialEscapes;
+ std::multimap<WordsList, std::wstring> qspecialEscapes;
+ std::multimap<std::wstring, std::wstring> study;
+ std::map<std::wstring, std::wstring> aliases;
+ std::map<std::wstring, std::vector<std::wstring>> raliases;
private:
int referenceCount;
} MindData;
@@ -57,7 +57,7 @@ private: MindData *data;
bool fileTypeMark;
- std::vector<std::tstring> Parse(std::tstring s);
+ std::vector<std::wstring> Parse(std::wstring s);
public:
Mind();
~Mind();
@@ -75,9 +75,9 @@ public: };
const MindData *GetData() const;
- void Load(std::tstring filename);
- void Save(std::tstring filename) const;
- void LoadSmiles(std::tstring filename);
+ void Load(std::wstring filename);
+ void Save(std::wstring filename) const;
+ void LoadSmiles(std::wstring filename);
void LoadSmiles(void* smiles, size_t size);
};
diff --git a/plugins/Boltun/src/Engine/TalkEngine.cpp b/plugins/Boltun/src/Engine/TalkEngine.cpp index c5cc859bb3..0f53403003 100644 --- a/plugins/Boltun/src/Engine/TalkEngine.cpp +++ b/plugins/Boltun/src/Engine/TalkEngine.cpp @@ -33,12 +33,12 @@ //#define EXCLUDE_SPECIAL_WORDS
#ifdef DEBUG_SHOW_VARIANTS
-extern void AddBotMessage(tstring s);
+extern void AddBotMessage(wstring s);
#endif
using namespace std;
-void TalkBot::UpdateStartChar(tstring &str)
+void TalkBot::UpdateStartChar(wstring &str)
{
if (!makeLowercase)
return;
@@ -46,21 +46,21 @@ void TalkBot::UpdateStartChar(tstring &str) size_t l = str.length();
if (l) {
// Answers starting with ' ' must remain unchanged.
- if (str[0] == _T(' ')) {
+ if (str[0] == ' ') {
str = str.substr(1);
return;
}
- TCHAR *strl = NEWTSTR_ALLOCA(str.c_str()), *stru = NEWTSTR_ALLOCA(str.c_str());
+ wchar_t *strl = NEWWSTR_ALLOCA(str.c_str()), *stru = NEWWSTR_ALLOCA(str.c_str());
CharLower(strl);
CharUpper(stru);
for (size_t i = 0; i < l; i++) {
- TCHAR cl = strl[i];
- TCHAR cu = stru[i];
+ wchar_t cl = strl[i];
+ wchar_t cu = stru[i];
if (i != l - 1) {
// Do not react to BLONDE ANSWERS
- TCHAR ncl = strl[i+1];
- TCHAR ncu = stru[i+1];
+ wchar_t ncl = strl[i+1];
+ wchar_t ncu = stru[i+1];
if (ncl != ncu && str[i+1] == ncu)
break;
}
@@ -84,27 +84,27 @@ TalkBot::~TalkBot() delete contactDatas;
}
-tstring TalkBot::GetInitMessage(MCONTACT contact)
+wstring TalkBot::GetInitMessage(MCONTACT contact)
{
ContactData* d = contactDatas->GetData(contact);
- tstring s = d->initial.GetString();
+ wstring s = d->initial.GetString();
contactDatas->PutData(contact);
return s;
}
-tstring TalkBot::ReplaceAliases(const tstring &message)
+wstring TalkBot::ReplaceAliases(const wstring &message)
{
- const TCHAR dividers[] = L" \t\n\r,./?\\|;:'\"~!#^&*()_-+=[{]}—\1";
- tstring sentence = message;
- tstring result;
- map<size_t, tstring> sm;
+ const wchar_t dividers[] = L" \t\n\r,./?\\|;:'\"~!#^&*()_-+=[{]}—\1";
+ wstring sentence = message;
+ wstring result;
+ map<size_t, wstring> sm;
//Find smiles
for (size_t i = 0; i < sentence.length() - 1; i++) {
unsigned max = (int)(sentence.length() - i);
if (max > mind.GetData()->maxSmileLen)
max = mind.GetData()->maxSmileLen;
for (unsigned j = max; j > 0; j--) {
- tstring item = sentence.substr(i, j);
+ wstring item = sentence.substr(i, j);
if (mind.GetData()->smiles.find(item) != mind.GetData()->smiles.end()) {
sm[i] = item;
sentence.replace(i, j, L"\1");
@@ -116,10 +116,10 @@ tstring TalkBot::ReplaceAliases(const tstring &message) bool hadQuestionSigns = false;
int it = 0;
while (it != len) {
- while (it != len && _tcschr(dividers, sentence[it])) {
- if (sentence[it] == _T('?'))
+ while (it != len && wcschr(dividers, sentence[it])) {
+ if (sentence[it] == '?')
hadQuestionSigns = true;
- map<size_t, tstring>::iterator smit;
+ map<size_t, wstring>::iterator smit;
if (sentence[it] == '\1') {
smit = sm.find(it);
result.append((*smit).second);
@@ -132,17 +132,17 @@ tstring TalkBot::ReplaceAliases(const tstring &message) break;
int start = it;
while (true) {
- while (it != len && !_tcschr(dividers, sentence[it]))
+ while (it != len && !wcschr(dividers, sentence[it]))
it++;
- if (it == len || sentence[it] != _T('-'))
+ if (it == len || sentence[it] != '-')
break;
//If we have-a-word-with-minus, we shouldn't split it
- if (_tcschr(dividers, sentence[it + 1]))
+ if (wcschr(dividers, sentence[it + 1]))
break;
it += 2;
}
- tstring str = sentence.substr(start, it - start);
- map<tstring, tstring>::const_iterator al = mind.GetData()->aliases.find(str);
+ wstring str = sentence.substr(start, it - start);
+ map<wstring, wstring>::const_iterator al = mind.GetData()->aliases.find(str);
if (al != mind.GetData()->aliases.end())
result.append((*al).second);
else
@@ -151,9 +151,9 @@ tstring TalkBot::ReplaceAliases(const tstring &message) return result;
}
-tstring TalkBot::AllReplies(const tstring &incomingMessage, ContactData *contactData, Level &maxValue, std::multimap<Level, tstring> &mm)
+wstring TalkBot::AllReplies(const wstring &incomingMessage, ContactData *contactData, Level &maxValue, std::multimap<Level, wstring> &mm)
{
- tstring res;
+ wstring res;
//Part 1
if (FindExact(contactData, incomingMessage, mind.GetData()->widelyUsed, res)) //widelyUsed
{
@@ -170,7 +170,7 @@ tstring TalkBot::AllReplies(const tstring &incomingMessage, ContactData *contact maxValue = LOOKSLIKE;
}
//Part 3
- vector<tstring> sentences;
+ vector<wstring> sentences;
SplitSectences(incomingMessage, sentences);
ValueChooser<> ch(sentences, true); //Using random order of sentences.
while ((res = ch.GetString()) != L"") {
@@ -197,7 +197,7 @@ tstring TalkBot::AllReplies(const tstring &incomingMessage, ContactData *contact maxValue = LOOKSLIKE;
}
//Part 6
- vector<tstring> keywords, otherwords;
+ vector<wstring> keywords, otherwords;
bool isQuestion;
SplitAndSortWords(res, keywords, otherwords, isQuestion);
//Part 7, 8
@@ -258,12 +258,12 @@ tstring TalkBot::AllReplies(const tstring &incomingMessage, ContactData *contact maxValue = FAIL;
}
}
- return tstring();
+ return wstring();
}
-TalkBot::MessageInfo* TalkBot::Reply(MCONTACT contact, tstring incomingMessage, bool saveChoice)
+TalkBot::MessageInfo* TalkBot::Reply(MCONTACT contact, wstring incomingMessage, bool saveChoice)
{
- TCHAR* str = new TCHAR[incomingMessage.length() + 1];
+ wchar_t* str = new wchar_t[incomingMessage.length() + 1];
mir_tstrcpy(str, incomingMessage.c_str());
CharLower(str);
incomingMessage = str;
@@ -274,8 +274,8 @@ TalkBot::MessageInfo* TalkBot::Reply(MCONTACT contact, tstring incomingMessage, MessageInfo *info;
//only 2-3 repeats
if (contactData->repeatCount < 2 || contactData->repeatCount == 2 && (rand() % 2)) {
- const vector<tstring>& v = mind.GetData()->repeats;
- tstring res = v[rand() % v.size()];
+ const vector<wstring>& v = mind.GetData()->repeats;
+ wstring res = v[rand() % v.size()];
#ifdef DEBUG_PREFIXES
info = new MessageInfo(incomingMessage, L"(repeat_norm) " + res);
#else
@@ -294,10 +294,10 @@ TalkBot::MessageInfo* TalkBot::Reply(MCONTACT contact, tstring incomingMessage, return info;
}
- multimap<Level, tstring> mm;
+ multimap<Level, wstring> mm;
Level maxValue = NOTHING;
- tstring res = AllReplies(incomingMessage, contactData, maxValue, mm);
+ wstring res = AllReplies(incomingMessage, contactData, maxValue, mm);
if (!res.empty()) {
UpdateStartChar(res);
#ifdef DEBUG_PREFIXES
@@ -328,7 +328,7 @@ TalkBot::MessageInfo* TalkBot::Reply(MCONTACT contact, tstring incomingMessage, }
//Also does Part 12
- tstring final = ChooseResult(contactData, maxValue, mm);
+ wstring final = ChooseResult(contactData, maxValue, mm);
MessageInfo *info = new MessageInfo(incomingMessage, final);
UpdateStartChar(final);
if (saveChoice)
@@ -337,14 +337,14 @@ TalkBot::MessageInfo* TalkBot::Reply(MCONTACT contact, tstring incomingMessage, return info;
}
-bool TalkBot::FindExact(ContactData *contactData, const tstring &incomingMessage,
- const multimap<tstring, tstring>& map, tstring& res)
+bool TalkBot::FindExact(ContactData *contactData, const wstring &incomingMessage,
+ const multimap<wstring, wstring> &map, wstring &res)
{
int max = (int)map.count(incomingMessage);
if (!max) {
- TCHAR c = incomingMessage[incomingMessage.length() - 1];
- if (c != _T('?') && c != _T('.') && c != _T('!'))
- return FindExact(contactData, incomingMessage + _T('.'), map, res);
+ wchar_t c = incomingMessage[incomingMessage.length() - 1];
+ if (c != '?' && c != '.' && c != '!')
+ return FindExact(contactData, incomingMessage + L'.', map, res);
return false;
}
pair<mm_cit, mm_cit> range = map.equal_range(incomingMessage);
@@ -372,7 +372,7 @@ void TalkBot::RecordAnswer(ContactData *contactData, const TalkBot::MessageInfo& contactData->lastMessage = info.Question;
}
-bool TalkBot::FindAny(ValueChooser<> &ch, tstring& res)
+bool TalkBot::FindAny(ValueChooser<> &ch, wstring& res)
{
if (!ch.GetContainer().size())
return false;
@@ -380,23 +380,23 @@ bool TalkBot::FindAny(ValueChooser<> &ch, tstring& res) return true;
}
-void TalkBot::SplitSectences(const tstring &incomingMessage, vector<tstring>& vec)
+void TalkBot::SplitSectences(const wstring &incomingMessage, vector<wstring>& vec)
{
//FIXME: (THINK ABOUT IT:-))these chars not always mark the end of sentence.
- const TCHAR symbols[] = L".?!";
+ const wchar_t symbols[] = L".?!";
int it = 0, len = (int)incomingMessage.length();
while (it != len) {
- while (it != len && _istspace(incomingMessage[it]))
+ while (it != len && iswspace(incomingMessage[it]))
it++;
int start = it;
while (it != len) {
- if (_tcschr(symbols, incomingMessage[it++])) {
+ if (wcschr(symbols, incomingMessage[it++])) {
//Test for a :-! smile
- if (it > 2 && incomingMessage[it - 1] == _T('!')
- && incomingMessage[it - 2] == _T('-')
- && incomingMessage[it - 3] == _T(':'))
+ if (it > 2 && incomingMessage[it - 1] == '!'
+ && incomingMessage[it - 2] == '-'
+ && incomingMessage[it - 3] == ':')
continue;
- while (it != len && _tcschr(symbols, incomingMessage[it]))
+ while (it != len && wcschr(symbols, incomingMessage[it]))
it++;
break;
}
@@ -406,9 +406,9 @@ void TalkBot::SplitSectences(const tstring &incomingMessage, vector<tstring>& ve }
#ifdef _DEBUG
-tstring LevelToStr(TalkBot::Level target)
+wstring LevelToStr(TalkBot::Level target)
{
- tstring lev;
+ wstring lev;
switch (target) {
case TalkBot::BEST: lev = L"BEST(0)"; break;
case TalkBot::LOOKSLIKE: lev = L"LOOKSLIKE(1)"; break;
@@ -420,41 +420,41 @@ tstring LevelToStr(TalkBot::Level target) }
#endif
-tstring TalkBot::ChooseResult(ContactData *contactData, Level maxValue, const multimap<Level, tstring> &mm)
+wstring TalkBot::ChooseResult(ContactData *contactData, Level maxValue, const multimap<Level, wstring> &mm)
{
#ifdef DEBUG_SHOW_VARIANTS
AddBotMessage(L">>Availabe:");
- for (multimap<Level, tstring>::iterator it = mm.begin(); it != mm.end(); it++)
+ for (multimap<Level, wstring>::iterator it = mm.begin(); it != mm.end(); it++)
AddBotMessage(LevelToStr((*it).first) + L": " + (*it).second);
AddBotMessage(L">>Result:");
#endif
if (maxValue == NOTHING)
return L"";
Level target = maxValue;
- typedef multimap<Level, tstring>::const_iterator lt_cit;
+ typedef multimap<Level, wstring>::const_iterator lt_cit;
pair<lt_cit, lt_cit> range = mm.equal_range(target);
for (lt_cit it = range.first; it != range.second; ++it)
contactData->chooser.AddChoice((*it).second);
#ifdef DEBUG_SHOW_LEVEL
- tstring lev = LevelToStr(target);
+ wstring lev = LevelToStr(target);
return lev + L": " + contactData->chooser.Choose();
#else
return contactData->chooser.Choose();
#endif
}
-void TalkBot::FindByKeywords(ContactData *contactData, const vector<tstring> &keywords, tstring& res/*, tstring& ures*/,
+void TalkBot::FindByKeywords(ContactData *contactData, const vector<wstring> &keywords, wstring& res/*, wstring& ures*/,
bool isQuestion)
{
if (keywords.size() == 0)
return;
- const multimap<WordsList, tstring> &keys = isQuestion ? mind.GetData()->qkeywords :
+ const multimap<WordsList, wstring> &keys = isQuestion ? mind.GetData()->qkeywords :
mind.GetData()->keywords;
- for (multimap<WordsList, tstring>::const_iterator it = keys.begin(); it != keys.end(); ++it) {
+ for (multimap<WordsList, wstring>::const_iterator it = keys.begin(); it != keys.end(); ++it) {
float prio;
if ((*it).first.MatchesAll(keywords/*, strict*/, prio))
#ifdef DEBUG_SHOW_SOLUTION_REASON
- contactData->chooser.AddChoice((tstring)(*it).first + L": - " + (*it).second, prio);
+ contactData->chooser.AddChoice((wstring)(*it).first + L": - " + (*it).second, prio);
#else
contactData->chooser.AddChoice((*it).second, prio);
#endif
@@ -462,16 +462,16 @@ void TalkBot::FindByKeywords(ContactData *contactData, const vector<tstring> &ke res = contactData->chooser.Choose();
}
-bool TalkBot::FindByOthers(ContactData *contactData, const vector<tstring> &otherwords, tstring& res, bool isQuestion)
+bool TalkBot::FindByOthers(ContactData *contactData, const vector<wstring> &otherwords, wstring& res, bool isQuestion)
{
- //vector<tstring> results;
- const multimap<WordsList, tstring> &specs = isQuestion ? mind.GetData()->qspecialEscapes :
+ //vector<wstring> results;
+ const multimap<WordsList, wstring> &specs = isQuestion ? mind.GetData()->qspecialEscapes :
mind.GetData()->specialEscapes;
- for (multimap<WordsList, tstring>::const_iterator it = specs.begin();
+ for (multimap<WordsList, wstring>::const_iterator it = specs.begin();
it != specs.end(); ++it)
if ((*it).first.MatchesAny(otherwords)) {
#ifdef DEBUG_SHOW_SOLUTION_REASON
- contactData->chooser.AddChoice((tstring)(*it).first + L": - " + (*it).second);
+ contactData->chooser.AddChoice((wstring)(*it).first + L": - " + (*it).second);
#else
contactData->chooser.AddChoice((*it).second);
#endif
@@ -487,20 +487,20 @@ const Mind& TalkBot::GetMind() const return mind;
}
-void TalkBot::SplitAndSortWords(tstring sentence, vector<tstring>& keywords,
- vector<tstring>& otherwords, bool& isQuestion)
+void TalkBot::SplitAndSortWords(wstring sentence, vector<wstring>& keywords,
+ vector<wstring>& otherwords, bool& isQuestion)
{
- const TCHAR dividers[] = L" \t\n\r,./?\\|;:'\"~!#^&*()_-+=[{]}—";
+ const wchar_t dividers[] = L" \t\n\r,./?\\|;:'\"~!#^&*()_-+=[{]}—";
int len = (int)sentence.length();
- vector<tstring> words;
- map<size_t, tstring> sm;
+ vector<wstring> words;
+ map<size_t, wstring> sm;
//Find smiles
for (size_t i = 0; i < sentence.length() - 1; i++) {
unsigned max = (int)(sentence.length() - i);
if (max > mind.GetData()->maxSmileLen)
max = mind.GetData()->maxSmileLen;
for (unsigned j = max; j > 0; j--) {
- tstring item = sentence.substr(i, j);
+ wstring item = sentence.substr(i, j);
if (mind.GetData()->smiles.find(item)
!= mind.GetData()->smiles.end()) {
sm[i] = item;
@@ -512,11 +512,11 @@ void TalkBot::SplitAndSortWords(tstring sentence, vector<tstring>& keywords, len = (int)sentence.length();
bool hadQuestionSigns = false;
for (int it = 0; it != len;) {
- while (it != len && _tcschr(dividers, sentence[it])) {
- if (sentence[it] == _T('?'))
+ while (it != len && wcschr(dividers, sentence[it])) {
+ if (sentence[it] == '?')
hadQuestionSigns = true;
- map<size_t, tstring>::iterator smit;
- if (_istspace(sentence[it]) && (smit = sm.find(it)) != sm.end())
+ map<size_t, wstring>::iterator smit;
+ if (iswspace(sentence[it]) && (smit = sm.find(it)) != sm.end())
words.push_back((*smit).second);
it++;
}
@@ -526,20 +526,20 @@ void TalkBot::SplitAndSortWords(tstring sentence, vector<tstring>& keywords, hadQuestionSigns = false;
int start = it;
while (true) {
- while (it != len && !_tcschr(dividers, sentence[it]))
+ while (it != len && !wcschr(dividers, sentence[it]))
it++;
- if (it == len || sentence[it] != _T('-'))
+ if (it == len || sentence[it] != '-')
break;
// If we have-a-word-with-minus, we shouldn't split it
- if (_tcschr(dividers, sentence[it + 1]))
+ if (wcschr(dividers, sentence[it + 1]))
break;
it += 2;
}
- tstring str = sentence.substr(start, it - start);
+ wstring str = sentence.substr(start, it - start);
words.push_back(str);
}
isQuestion = hadQuestionSigns;
- for (vector<tstring>::iterator it = words.begin(); it != words.end(); ++it) {
+ for (vector<wstring>::iterator it = words.begin(); it != words.end(); ++it) {
if (!isQuestion)
if (mind.GetData()->question.find(*it) != mind.GetData()->question.end())
isQuestion = true;
diff --git a/plugins/Boltun/src/Engine/TalkEngine.h b/plugins/Boltun/src/Engine/TalkEngine.h index c18f3df1c1..7e0539c9e6 100644 --- a/plugins/Boltun/src/Engine/TalkEngine.h +++ b/plugins/Boltun/src/Engine/TalkEngine.h @@ -34,14 +34,14 @@ public: struct MessageInfo
{
private:
- std::tstring Question;
- MessageInfo(std::tstring q, std::tstring a)
+ std::wstring Question;
+ MessageInfo(std::wstring q, std::wstring a)
:Question(q), Answer(a)
{
}
public:
- std::tstring Answer;
- MessageInfo(std::tstring q)
+ std::wstring Answer;
+ MessageInfo(std::wstring q)
:Question(q)
{
}
@@ -52,17 +52,17 @@ private: {
BEST, LOOKSLIKE/*, LOOKSLIKE2*/, BAD, FAIL, NOTHING
} Level;
- friend std::tstring LevelToStr(TalkBot::Level target);
+ friend std::wstring LevelToStr(TalkBot::Level target);
struct ContactData
{
ValueChooser<> initial;
- //ValueChooser<std::set<std::tstring> > question;
- //ValueChooser<std::set<std::tstring> > special;
+ //ValueChooser<std::set<std::wstring> > question;
+ //ValueChooser<std::set<std::wstring> > special;
ValueChooser<> escape;
ValueChooser<> failure;
UnRecentChooser chooser;
- std::tstring lastMessage;
+ std::wstring lastMessage;
long long lastMessageTime;
int repeatCount;
inline ContactData(const Mind& mind)
@@ -81,22 +81,22 @@ private: bool beSilent;
bool makeLowercase;
bool understandAlways;
- void UpdateStartChar(std::tstring &str);
- typedef std::multimap<std::tstring, std::tstring>::const_iterator mm_cit;
- bool FindExact(ContactData *contactData, const std::tstring &incomingMessage, const std::multimap<std::tstring, std::tstring> &map, std::tstring &res);
- bool FindAny(ValueChooser<> &ch, std::tstring &res);
- void FindByKeywords(ContactData *contactData, const std::vector<std::tstring> &keywords, std::tstring &res/*, std::tstring& ures*/, bool isQuestion);
- bool FindByOthers(ContactData *contactData, const std::vector<std::tstring> &otherwords, std::tstring &res, bool isQuestion);
- std::tstring AllReplies(const std::tstring &incomingMessage, ContactData *contactData, Level &maxValue, std::multimap<Level, std::tstring> &mm);
- std::tstring ReplaceAliases(const std::tstring &message);
- std::tstring ChooseResult(ContactData *contactData, Level maxValue, const std::multimap<Level, std::tstring> &mm);
+ void UpdateStartChar(std::wstring &str);
+ typedef std::multimap<std::wstring, std::wstring>::const_iterator mm_cit;
+ bool FindExact(ContactData *contactData, const std::wstring &incomingMessage, const std::multimap<std::wstring, std::wstring> &map, std::wstring &res);
+ bool FindAny(ValueChooser<> &ch, std::wstring &res);
+ void FindByKeywords(ContactData *contactData, const std::vector<std::wstring> &keywords, std::wstring &res/*, std::wstring& ures*/, bool isQuestion);
+ bool FindByOthers(ContactData *contactData, const std::vector<std::wstring> &otherwords, std::wstring &res, bool isQuestion);
+ std::wstring AllReplies(const std::wstring &incomingMessage, ContactData *contactData, Level &maxValue, std::multimap<Level, std::wstring> &mm);
+ std::wstring ReplaceAliases(const std::wstring &message);
+ std::wstring ChooseResult(ContactData *contactData, Level maxValue, const std::multimap<Level, std::wstring> &mm);
void RecordAnswer(ContactData *contactData, const TalkBot::MessageInfo &info);
#ifdef _DEBUG
public:
#endif
- void SplitSectences(const std::tstring &incomingMessage, std::vector<std::tstring> &vec);
- void SplitAndSortWords(std::tstring sentence, std::vector<std::tstring> &keywords,
- std::vector<std::tstring>& otherwords, bool& isQuestion);
+ void SplitSectences(const std::wstring &incomingMessage, std::vector<std::wstring> &vec);
+ void SplitAndSortWords(std::wstring sentence, std::vector<std::wstring> &keywords,
+ std::vector<std::wstring>& otherwords, bool& isQuestion);
public:
TalkBot(const Mind& goodMind);
~TalkBot();
@@ -105,8 +105,8 @@ public: void SetLowercase(const bool isLowercase);
void SetUnderstandAlways(const bool understandAlways);
//const MindData *GetData();
- std::tstring GetInitMessage(MCONTACT contact);
- MessageInfo* Reply(MCONTACT contact, const std::tstring incomingMessage, bool saveChoice);
+ std::wstring GetInitMessage(MCONTACT contact);
+ MessageInfo* Reply(MCONTACT contact, const std::wstring incomingMessage, bool saveChoice);
void AnswerGiven(MCONTACT contact, const MessageInfo &info);
};
diff --git a/plugins/Boltun/src/Engine/UnrecentChooser.cpp b/plugins/Boltun/src/Engine/UnrecentChooser.cpp index b0b5e1460e..761adf10c4 100644 --- a/plugins/Boltun/src/Engine/UnrecentChooser.cpp +++ b/plugins/Boltun/src/Engine/UnrecentChooser.cpp @@ -27,7 +27,7 @@ UnRecentChooser::UnRecentChooser() {
}
-void UnRecentChooser::AddChoice(tstring value, float prio)
+void UnRecentChooser::AddChoice(wstring value, float prio)
{
if (items.count(value) != 0)
{
@@ -49,9 +49,9 @@ void UnRecentChooser::AddChoice(tstring value, float prio) }
}
-tstring UnRecentChooser::Choose()
+wstring UnRecentChooser::Choose()
{
- tstring res;
+ wstring res;
//Find answer
if (newItemsPrio != -1)
{
@@ -78,12 +78,12 @@ tstring UnRecentChooser::Choose() return res;
}
-void UnRecentChooser::SaveChoice(tstring choice)
+void UnRecentChooser::SaveChoice(wstring choice)
{
//Add answer
if (items.find(choice) != items.end())
{
- for (vector<tstring>::iterator it = itemsList.begin(); it != itemsList.end(); ++it)
+ for (vector<wstring>::iterator it = itemsList.begin(); it != itemsList.end(); ++it)
if (*it == choice)
{
itemsList.erase(it);
diff --git a/plugins/Boltun/src/Engine/UnrecentChooser.h b/plugins/Boltun/src/Engine/UnrecentChooser.h index 72245773de..ff82faf628 100644 --- a/plugins/Boltun/src/Engine/UnrecentChooser.h +++ b/plugins/Boltun/src/Engine/UnrecentChooser.h @@ -23,20 +23,20 @@ class UnRecentChooser
{
- std::map<std::tstring, size_t> items;
- std::vector<std::tstring> itemsList;
- std::vector<std::tstring> newItems;
+ std::map<std::wstring, size_t> items;
+ std::vector<std::wstring> itemsList;
+ std::vector<std::wstring> newItems;
float newItemsPrio, maxOldPrio;
- std::map<size_t, std::tstring> oldItems;
- std::map<std::tstring, float> oldPrios;
+ std::map<size_t, std::wstring> oldItems;
+ std::map<std::wstring, float> oldPrios;
size_t last;
int minimum;
static const size_t maxItems = 100;
public:
UnRecentChooser();
- void AddChoice(std::tstring value, float prio = 1.0);
- std::tstring Choose();
- void SaveChoice(std::tstring choice);
+ void AddChoice(std::wstring value, float prio = 1.0);
+ std::wstring Choose();
+ void SaveChoice(std::wstring choice);
};
#endif /* UnRecentChooserH */
\ No newline at end of file diff --git a/plugins/Boltun/src/Engine/ValueChooser.h b/plugins/Boltun/src/Engine/ValueChooser.h index f82ceecbea..b65db2acea 100644 --- a/plugins/Boltun/src/Engine/ValueChooser.h +++ b/plugins/Boltun/src/Engine/ValueChooser.h @@ -21,7 +21,7 @@ #ifndef StringChooserH
#define StringChooserH
-template<class container = std::vector<std::tstring> >
+template<class container = std::vector<std::wstring> >
class ValueChooser
{
private:
diff --git a/plugins/Boltun/src/Engine/WordsList.cpp b/plugins/Boltun/src/Engine/WordsList.cpp index b111cc3414..1efbdebc20 100644 --- a/plugins/Boltun/src/Engine/WordsList.cpp +++ b/plugins/Boltun/src/Engine/WordsList.cpp @@ -22,17 +22,17 @@ using namespace std;
-WordsList::WordsList(const tstring &data/*, bool allowUnstrict*/)
+WordsList::WordsList(const wstring &data/*, bool allowUnstrict*/)
{
Parse(data/*, allowUnstrict*/);
}
-WordsList::operator tstring() const
+WordsList::operator wstring() const
{
- tstring res;
+ wstring res;
//if (unstrict)
// res = L"~";
- set<tstring>::const_iterator it = words.begin();
+ set<wstring>::const_iterator it = words.begin();
if (!words.empty())
while (true)
{
@@ -47,16 +47,16 @@ WordsList::operator tstring() const return res;
}
-WordsList& WordsList::operator= (const tstring& s)
+WordsList& WordsList::operator= (const wstring& s)
{
Parse(s);
return *this;
};
-void WordsList::Parse(tstring s/*, bool allowUnstrict*/)
+void WordsList::Parse(wstring s/*, bool allowUnstrict*/)
{
isQuestion = false;
- /*if (allowUnstrict && s.length() && s[0] == _T('~'))
+ /*if (allowUnstrict && s.length() && s[0] == '~')
{
s = s.substr(1, s.npos);
unstrict = true;
@@ -64,7 +64,7 @@ void WordsList::Parse(tstring s/*, bool allowUnstrict*/) else
unstrict = false;*/
int len = (int)s.length() - 1;
- while (len != -1 && _istspace(s[len]))
+ while (len != -1 && iswspace(s[len]))
len--;
if (len < 0)
return;
@@ -77,22 +77,22 @@ void WordsList::Parse(tstring s/*, bool allowUnstrict*/) 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++;
words.insert(s.substr(start, it - start));
}
}
-bool WordsList::MatchesAll(const vector<tstring>& s/*, bool& WasStrict*/, float& priority) const
+bool WordsList::MatchesAll(const vector<wstring>& s/*, bool& WasStrict*/, float& priority) const
{
- std::set<tstring> temp;
+ std::set<wstring> temp;
//WasStrict = true;
- for (vector<tstring>::const_iterator it = s.begin(); it != s.end(); ++it)
+ for (vector<wstring>::const_iterator it = s.begin(); it != s.end(); ++it)
{
/* if (words.find(*it) == words.end())
if (unstrict)
@@ -112,27 +112,27 @@ bool WordsList::MatchesAll(const vector<tstring>& s/*, bool& WasStrict*/, float& return temp.size() == words.size();
}
-bool WordsList::MatchesAny(const vector<tstring>& s) const
+bool WordsList::MatchesAny(const vector<wstring>& s) const
{
- for (vector<tstring>::const_iterator it = s.begin(); it != s.end(); ++it)
+ for (vector<wstring>::const_iterator it = s.begin(); it != s.end(); ++it)
if (words.find(*it) != words.end())
return true;
return false;
}
-vector<tstring> WordsList::ConsistsOf(const set<tstring>& list) const
+vector<wstring> WordsList::ConsistsOf(const set<wstring>& list) const
{
- vector<tstring> res;
- for (set<tstring>::const_iterator it = words.begin(); it != words.end(); ++it)
+ vector<wstring> res;
+ for (set<wstring>::const_iterator it = words.begin(); it != words.end(); ++it)
if (list.find(*it) == list.end())
res.push_back(*it);
return res;
}
-vector<tstring> WordsList::DoesntIncludeAny(const set<tstring>& list) const
+vector<wstring> WordsList::DoesntIncludeAny(const set<wstring>& list) const
{
- vector<tstring> res;
- for (set<tstring>::const_iterator it = words.begin(); it != words.end(); ++it)
+ vector<wstring> res;
+ for (set<wstring>::const_iterator it = words.begin(); it != words.end(); ++it)
if (list.find(*it) != list.end())
res.push_back(*it);
return res;
@@ -140,17 +140,17 @@ vector<tstring> WordsList::DoesntIncludeAny(const set<tstring>& list) const bool WordsList::operator<(const WordsList& value) const
{
- return (tstring)*this < (tstring)value;
+ return (wstring)*this < (wstring)value;
}
bool WordsList::operator!=(const WordsList& value) const
{
- return (tstring)*this != (tstring)value;
+ return (wstring)*this != (wstring)value;
}
bool WordsList::operator==(const WordsList& value) const
{
- return (tstring)*this == (tstring)value;
+ return (wstring)*this == (wstring)value;
}
size_t WordsList::Size() const
diff --git a/plugins/Boltun/src/Engine/WordsList.h b/plugins/Boltun/src/Engine/WordsList.h index 4cac8cd969..dfda3b6c91 100644 --- a/plugins/Boltun/src/Engine/WordsList.h +++ b/plugins/Boltun/src/Engine/WordsList.h @@ -24,21 +24,21 @@ class WordsList
{
WordsList();
- void Parse(std::tstring s/*, bool allowUnstrict = false*/);
+ void Parse(std::wstring s/*, bool allowUnstrict = false*/);
//bool unstrict;
#ifdef _DEBUG
public:
#endif
- std::set<std::tstring> words;
+ std::set<std::wstring> words;
bool isQuestion;
public:
- WordsList(const std::tstring &data/*, bool allowUnstrict = false*/);
- operator std::tstring() const;
- bool MatchesAll(const std::vector<std::tstring>& s/*, bool& WasStrict*/, float& priority) const;
- bool MatchesAny(const std::vector<std::tstring>& s) const;
- std::vector<std::tstring> ConsistsOf(const std::set<std::tstring>& list) const;
- std::vector<std::tstring> DoesntIncludeAny(const std::set<std::tstring>& list) const;
- WordsList& operator= (const std::tstring& s);
+ WordsList(const std::wstring &data/*, bool allowUnstrict = false*/);
+ operator std::wstring() const;
+ bool MatchesAll(const std::vector<std::wstring>& s/*, bool& WasStrict*/, float& priority) const;
+ bool MatchesAny(const std::vector<std::wstring>& s) const;
+ std::vector<std::wstring> ConsistsOf(const std::set<std::wstring>& list) const;
+ std::vector<std::wstring> DoesntIncludeAny(const std::set<std::wstring>& list) const;
+ WordsList& operator= (const std::wstring& s);
bool operator<(const WordsList& value) const;
bool operator==(const WordsList& value) const;
bool operator!=(const WordsList& value) const;
diff --git a/plugins/Boltun/src/actionQueue.cpp b/plugins/Boltun/src/actionQueue.cpp index 3d7d322bf9..b7656873cd 100644 --- a/plugins/Boltun/src/actionQueue.cpp +++ b/plugins/Boltun/src/actionQueue.cpp @@ -115,7 +115,7 @@ static void StartTyping(MCONTACT hContact, const TalkBot::MessageInfo*) void DoAnswer(MCONTACT hContact, const TalkBot::MessageInfo *info, bool sticky = false)
{
- if (info->Answer[0] == _T('\0'))
+ if (info->Answer[0] == '\0')
return;
int waitTime, thinkTime = 0;
int defWaitTime = Config.AnswerPauseTime * 1000;
@@ -191,12 +191,12 @@ void DoAnswer(MCONTACT hContact, const TalkBot::MessageInfo *info, bool sticky = UpdateTimer();
}
-void AnswerToContact(MCONTACT hContact, const TCHAR* messageToAnswer)
+void AnswerToContact(MCONTACT hContact, const wchar_t* messageToAnswer)
{
if (Config.TalkWarnContacts && db_get_b(hContact, BOLTUN_KEY,
DB_CONTACT_WARNED, FALSE) == FALSE)
{
- DoAnswer(hContact, new TalkBot::MessageInfo((const TCHAR*)Config.WarnText), true);
+ DoAnswer(hContact, new TalkBot::MessageInfo((const wchar_t*)Config.WarnText), true);
db_set_b(hContact, BOLTUN_KEY, DB_CONTACT_WARNED, TRUE);
}
else
diff --git a/plugins/Boltun/src/actionQueue.h b/plugins/Boltun/src/actionQueue.h index 492bdcb24e..953b9a08f3 100644 --- a/plugins/Boltun/src/actionQueue.h +++ b/plugins/Boltun/src/actionQueue.h @@ -21,7 +21,7 @@ #ifndef ACTIONQUEUE_H
#define ACTIONQUEUE_H
-void AnswerToContact(MCONTACT hContact, const TCHAR* messageToAnswer);
+void AnswerToContact(MCONTACT hContact, const wchar_t* messageToAnswer);
void StartChatting(MCONTACT hContact);
diff --git a/plugins/Boltun/src/boltun.cpp b/plugins/Boltun/src/boltun.cpp index 8fb65dd806..100c18b144 100644 --- a/plugins/Boltun/src/boltun.cpp +++ b/plugins/Boltun/src/boltun.cpp @@ -30,7 +30,7 @@ TalkBot* bot = NULL; HINSTANCE hInst;
BOOL blInit = FALSE;
UINT pTimer = 0;
-TCHAR tszPath[MAX_PATH];
+wchar_t tszPath[MAX_PATH];
PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
@@ -63,13 +63,13 @@ void UpdateEngine() }
}
-TCHAR* GetFullName(const TCHAR *filename)
+wchar_t* GetFullName(const wchar_t *filename)
{
size_t flen = mir_tstrlen(filename);
- TCHAR* fullname = const_cast<TCHAR*>(filename);
- if (!_tcschr(filename, _T(':'))) {
+ wchar_t* fullname = const_cast<wchar_t*>(filename);
+ if (!wcschr(filename, ':')) {
size_t plen = mir_tstrlen(tszPath);
- fullname = new TCHAR[plen + flen + 1];
+ fullname = new wchar_t[plen + flen + 1];
fullname[0] = NULL;
mir_tstrcat(fullname, tszPath);
mir_tstrcat(fullname, filename);
@@ -77,9 +77,9 @@ TCHAR* GetFullName(const TCHAR *filename) return fullname;
}
-static bool LoadMind(const TCHAR* filename, int &line)
+static bool LoadMind(const wchar_t* filename, int &line)
{
- TCHAR* fullname = GetFullName(filename);
+ wchar_t* fullname = GetFullName(filename);
HCURSOR newCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_WAIT));
HCURSOR oldCur = SetCursor(newCur);
#ifdef DEBUG_LOAD_TIME
@@ -157,7 +157,7 @@ static bool LoadMind(const TCHAR* filename, int &line) return true;
}
-/*static bool SaveMind(const TCHAR* filename)
+/*static bool SaveMind(const wchar_t* filename)
{
if (!bot)
return false;
@@ -220,7 +220,7 @@ static int MessageEventAdded(WPARAM hContact, LPARAM hDbEvent) egt.codepage = CP_ACP;
egt.datatype = DBVT_TCHAR;
egt.dbei = &dbei;
- TCHAR* s = (TCHAR*)(void*)CallService(MS_DB_EVENT_GETTEXT, 0, (LPARAM)&egt);
+ wchar_t* s = (wchar_t*)(void*)CallService(MS_DB_EVENT_GETTEXT, 0, (LPARAM)&egt);
free(dbei.pBlob);
if (Config.MarkAsRead)
db_event_markRead(hContact, hDbEvent);
@@ -307,7 +307,7 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPAR Config.AnswerThinkTime = GetDlgItemInt(hwndDlg, IDC_THINKTIME, &bTranslated, FALSE);
if (!bTranslated)
Config.AnswerThinkTime = 4;
- TCHAR c[MAX_WARN_TEXT];
+ wchar_t c[MAX_WARN_TEXT];
bTranslated = GetDlgItemText(hwndDlg, IDC_WARNTXT, c, _countof(c));
if (bTranslated)
Config.WarnText = c;
@@ -359,8 +359,8 @@ static INT_PTR CALLBACK EngineDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP case IDC_BTNPATH:
{
const size_t fileNameSize = 5000;
- TCHAR *filename = new TCHAR[fileNameSize];
- TCHAR *fullname = GetFullName(Config.MindFileName);
+ wchar_t *filename = new wchar_t[fileNameSize];
+ wchar_t *fullname = GetFullName(Config.MindFileName);
mir_tstrcpy(filename, fullname);
if (fullname != Config.MindFileName)
delete[] fullname;
@@ -369,8 +369,8 @@ static INT_PTR CALLBACK EngineDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = GetParent(hwndDlg);
- TCHAR *mind = TranslateTS(MIND_FILE_DESC);
- TCHAR *anyfile = TranslateTS(ALL_FILES_DESC);
+ wchar_t *mind = TranslateTS(MIND_FILE_DESC);
+ wchar_t *anyfile = TranslateTS(ALL_FILES_DESC);
CMString filt(FORMAT, MIND_DIALOG_FILTER, mind, anyfile);
filt.Replace('\1', '\0');
@@ -384,12 +384,12 @@ static INT_PTR CALLBACK EngineDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP break;
}
- TCHAR *origf = filename;
- TCHAR *f = filename;
- TCHAR *p = tszPath;
+ wchar_t *origf = filename;
+ wchar_t *f = filename;
+ wchar_t *p = tszPath;
while (*p && *f) {
- TCHAR p1 = (TCHAR)CharLower((TCHAR*)(long)*p++);
- TCHAR f1 = (TCHAR)CharLower((TCHAR*)(long)*f++);
+ wchar_t p1 = (wchar_t)CharLower((wchar_t*)(long)*p++);
+ wchar_t f1 = (wchar_t)CharLower((wchar_t*)(long)*f++);
if (p1 != f1)
break;
}
@@ -402,11 +402,11 @@ static INT_PTR CALLBACK EngineDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP case IDC_BTNRELOAD:
{
- const TCHAR *c = Config.MindFileName;
+ const wchar_t *c = Config.MindFileName;
int line;
bTranslated = blInit = LoadMind(c, line);
if (!bTranslated) {
- TCHAR message[5000];
+ wchar_t message[5000];
mir_sntprintf(message, TranslateTS(FAILED_TO_LOAD_BASE), line, c);
MessageBox(NULL, message, TranslateTS(BOLTUN_ERROR), MB_ICONERROR | MB_TASKMODAL | MB_OK);
}
@@ -431,7 +431,7 @@ static INT_PTR CALLBACK EngineDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP Config.EngineMakeLowerCase = IsDlgButtonChecked(hwndDlg, IDC_ENGINE_LOWERCASE) == BST_CHECKED ? TRUE : FALSE;
Config.EngineUnderstandAlways = IsDlgButtonChecked(hwndDlg, IDC_ENGINE_UNDERSTAND_ALWAYS) == BST_CHECKED ? TRUE : FALSE;
UpdateEngine();
- TCHAR c[MAX_MIND_FILE];
+ wchar_t c[MAX_MIND_FILE];
bTranslated = GetDlgItemText(hwndDlg, IDC_MINDFILE, c, _countof(c));
if (bTranslated)
Config.MindFileName = c;
@@ -536,7 +536,7 @@ extern "C" int __declspec(dllexport) Load(void) mir_getLP(&pluginInfo);
GetModuleFileName(hInst, tszPath, _countof(tszPath));
- *(_tcsrchr(tszPath, _T('\\')) + 1) = _T('\0');
+ *(wcsrchr(tszPath, '\\') + 1) = '\0';
/*initialize miranda hooks and services on options dialog*/
HookEvent(ME_OPT_INITIALISE, MessageOptInit);
@@ -574,8 +574,8 @@ extern "C" int __declspec(dllexport) Load(void) int line;
blInit = LoadMind(Config.MindFileName, line);
if (!blInit) {
- TCHAR path[2000];
- mir_sntprintf(path, TranslateTS(FAILED_TO_LOAD_BASE), line, (const TCHAR*)Config.MindFileName);
+ wchar_t path[2000];
+ mir_sntprintf(path, TranslateTS(FAILED_TO_LOAD_BASE), line, (const wchar_t*)Config.MindFileName);
MessageBox(NULL, path, TranslateTS(BOLTUN_ERROR), MB_ICONERROR | MB_TASKMODAL | MB_OK);
}
return 0;
@@ -592,9 +592,9 @@ extern "C" int __declspec(dllexport) Unload(void) //It seems that it's now a Boltun problem.
//So in case of saving error we will remain silent
#if 0
- TCHAR path[MAX_PATH];
- mir_sntprintf(path, TranslateTS(FAILED_TO_SAVE_BASE), (const TCHAR*)Config.MindFileName);
- TCHAR* err = TranslateTS(BOLTUN_ERROR);
+ wchar_t path[MAX_PATH];
+ mir_sntprintf(path, TranslateTS(FAILED_TO_SAVE_BASE), (const wchar_t*)Config.MindFileName);
+ wchar_t* err = TranslateTS(BOLTUN_ERROR);
MessageBox(NULL, path, err, MB_ICONERROR | MB_TASKMODAL | MB_OK); */
#endif
}
diff --git a/plugins/Boltun/src/config.cpp b/plugins/Boltun/src/config.cpp index 27aefdf329..dd821a886b 100644 --- a/plugins/Boltun/src/config.cpp +++ b/plugins/Boltun/src/config.cpp @@ -36,31 +36,31 @@ #define DB_ENGINE_LOWERCASE "MakeLowerCase"
#define DB_ENGINE_UNDERSTAND_ALWAYS "UnderstandAlways"
-inline TCHAR* GetString(char* key, const TCHAR* def)
+inline wchar_t* GetString(char* key, const wchar_t* def)
{
DBVARIANT dbv;
- TCHAR* val;
+ wchar_t* val;
if (!db_get_ts(NULL, BOLTUN_KEY, key, &dbv))
{
size_t len = mir_wstrlen(dbv.ptszVal) + 1;
- val = new TCHAR[len];
- _tcscpy_s(val, len, dbv.ptszVal);
+ val = new wchar_t[len];
+ wcscpy_s(val, len, dbv.ptszVal);
db_free(&dbv);
}
else
{
size_t len = mir_wstrlen(def) + 1;
- val = new TCHAR[len];
- _tcscpy_s(val, len, def);
+ val = new wchar_t[len];
+ wcscpy_s(val, len, def);
}
return val;
}
-inline const TCHAR* SetString(char* key, const TCHAR* value)
+inline const wchar_t* SetString(char* key, const wchar_t* value)
{
size_t len = mir_tstrlen(value) + 1;
- TCHAR* val = new TCHAR[len];
- _tcscpy_s(val, len, value);
+ wchar_t* val = new wchar_t[len];
+ wcscpy_s(val, len, value);
db_set_ts(NULL, BOLTUN_KEY, key, val);
return val;
}
@@ -80,9 +80,9 @@ inline const TCHAR* SetString(char* key, const TCHAR* value) return value; }
#define BUILDSTRETTERS(x, str, def) \
- const TCHAR* BoltunConfig::Get##x() { \
+ const wchar_t* BoltunConfig::Get##x() { \
return GetString(str, def); } \
- const TCHAR* BoltunConfig::Set##x(const TCHAR* value) { \
+ const wchar_t* BoltunConfig::Set##x(const wchar_t* value) { \
return SetString(str, value); }
#define BUILDINIT(x) \
diff --git a/plugins/Boltun/src/config.h b/plugins/Boltun/src/config.h index 3cee967d4f..73587fe3e3 100644 --- a/plugins/Boltun/src/config.h +++ b/plugins/Boltun/src/config.h @@ -133,8 +133,8 @@ class BoltunConfig BUILDDEFETTERS(AnswerThinkTime, int);
BUILDDEFETTERS(PauseDepends, bool);
BUILDDEFETTERS(PauseRandom, bool);
- BUILDDEFETTERS(WarnText, TCHAR*);
- BUILDDEFETTERS(MindFileName, TCHAR*);
+ BUILDDEFETTERS(WarnText, wchar_t*);
+ BUILDDEFETTERS(MindFileName, wchar_t*);
BUILDDEFETTERS(EngineStaySilent, bool);
BUILDDEFETTERS(EngineMakeLowerCase, bool);
BUILDDEFETTERS(EngineUnderstandAlways, bool);
@@ -151,8 +151,8 @@ public: Property<int, BoltunConfig> AnswerThinkTime;
Property<bool, BoltunConfig> PauseDepends;
Property<bool, BoltunConfig> PauseRandom;
- PtrProperty<TCHAR, BoltunConfig> WarnText;
- PtrProperty<TCHAR, BoltunConfig> MindFileName;
+ PtrProperty<wchar_t, BoltunConfig> WarnText;
+ PtrProperty<wchar_t, BoltunConfig> MindFileName;
Property<bool, BoltunConfig> EngineStaySilent;
Property<bool, BoltunConfig> EngineMakeLowerCase;
Property<bool, BoltunConfig> EngineUnderstandAlways;
diff --git a/plugins/Boltun/src/stdafx.h b/plugins/Boltun/src/stdafx.h index 77b9614042..a4a084bdf2 100644 --- a/plugins/Boltun/src/stdafx.h +++ b/plugins/Boltun/src/stdafx.h @@ -74,20 +74,20 @@ //Plugin name
#define BOLTUN_NAME "Boltun"
-#define MIND_FILE_DESC LPGENT("Mind Files")
-#define ALL_FILES_DESC LPGENT("All Files")
+#define MIND_FILE_DESC LPGENW("Mind Files")
+#define ALL_FILES_DESC LPGENW("All Files")
//UI strings
#define BOLTUN_AUTO_CHAT LPGEN("Boltun/Auto Chat")
#define BOLTUN_NOT_TO_CHAT LPGEN("Boltun/Not to Chat")
#define BOLTUN_START_CHATTING LPGEN("Boltun/Start Chatting")
-#define DEFAULT_WARN_TEXT LPGENT("Hello. I'm Boltun! I'll talk to you, while my owner is away. Please write without mistakes!")
+#define DEFAULT_WARN_TEXT LPGENW("Hello. I'm Boltun! I'll talk to you, while my owner is away. Please write without mistakes!")
// Error messages
-#define BOLTUN_ERROR LPGENT("Boltun Error")
-#define FAILED_TO_LOAD_BASE LPGENT("Failed to load base of remarks. Error at line %d of %s. (Or few lines before).")
-#define FAILED_TO_SAVE_BASE LPGENT("Failed to save base of remarks to %s")
+#define BOLTUN_ERROR LPGENW("Boltun Error")
+#define FAILED_TO_LOAD_BASE LPGENW("Failed to load base of remarks. Error at line %d of %s. (Or few lines before).")
+#define FAILED_TO_SAVE_BASE LPGENW("Failed to save base of remarks to %s")
//Settings tab names
#define TAB_GENERAL LPGEN("General Settings")
|