summaryrefslogtreecommitdiff
path: root/plugins/Boltun/src/Engine/Mind.h
blob: 23e0a41bd3ebfb5db9dbd72d3ffbf2587947b98d (plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//***********************************************************
//	Copyright © 2008 Valentin Pavlyuchenko
//
//	This file is part of Boltun.
//
//    Boltun is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 2 of the License, or
//    (at your option) any later version.
//
//    Boltun is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//	  along with Boltun. If not, see <http://www.gnu.org/licenses/>.
//
//***********************************************************

#ifndef MindH
#define MindH

#include <string>
#include <vector>
#include <map>
#include <set>
#include "WordsList.h"
#include <tchar.h>
#include "tstring.h"


class Mind;

typedef struct
{
	friend class Mind;
	std::vector<tstring> initial;
	std::set<tstring> question;
	std::set<tstring> special;
	std::vector<tstring> escape;
	std::vector<tstring> failure;
	std::vector<tstring> repeats;
    unsigned int maxSmileLen;
	std::set<tstring> smiles;
	std::multimap<WordsList, tstring> keywords;
	std::multimap<WordsList, tstring> qkeywords;
	std::multimap<tstring, tstring> widelyUsed;
	std::multimap<WordsList, tstring> specialEscapes;
	std::multimap<WordsList, tstring> qspecialEscapes;
	std::multimap<tstring, tstring> study;
	std::map<tstring, tstring> aliases;
	std::map<tstring, std::vector<tstring>> raliases;
private:
	int referenceCount;
} MindData;

class Mind
{
private:
	MindData *data;
	bool fileTypeMark;	

	std::vector<tstring> Parse(tstring s);
public:
	Mind();
	~Mind();
	Mind(const Mind& mind);
	Mind& operator= (const Mind& mind);

	class CorruptedMind
	{
	public:
		int line;
		CorruptedMind(int aline)
			: line(aline)
		{
		};
	};

	const MindData *GetData() const;
	void Load(tstring filename);
	void Save(tstring filename) const;
	void LoadSmiles(tstring filename);
	void LoadSmiles(void* smiles, size_t size);
};

#endif