summaryrefslogtreecommitdiff
path: root/plugins/Boltun/src/Engine/Mind.h
blob: d11eb6cd780a293f3ad7785d5003f07f98191107 (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
//***********************************************************
//	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 <vector>
#include <map>
#include <set>
#include "WordsList.h"

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;
	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;
private:
	int referenceCount;
} MindData;

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

	std::vector<std::tstring> Parse(std::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(std::tstring filename);
	void Save(std::tstring filename) const;
	void LoadSmiles(std::tstring filename);
	void LoadSmiles(void* smiles, size_t size);
};

#endif