]> git.lyx.org Git - lyx.git/blob - src/PersonalWordList.h
#7043 add the implementation of a persistent personal word list for LyX spell checker...
[lyx.git] / src / PersonalWordList.h
1 // -*- C++ -*-
2 /**
3  * \file PersonalWordList.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Stephan Witt
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef PERSONAL_WORD_LIST_H
13 #define PERSONAL_WORD_LIST_H
14
15 #include "support/strfwd.h"
16 #include "support/docstring_list.h"
17 #include "support/FileName.h"
18
19 #include <string>
20
21 namespace lyx {
22
23 /// A PersonalWordList holds a word list with persistent state
24 class PersonalWordList {
25 public:
26         /// the word list has an associated language
27         PersonalWordList(std::string lang) { lang_ = lang; }
28         /// the location of the file to hold to word list
29         lyx::support::FileName dictfile() const;
30         /// (re)load the word list from file
31         void load();
32         /// save word list to file
33         void save();
34         /// check for presence of given word
35         bool exists(docstring const & word) const;
36         /// add given word to list
37         void insert(docstring const & word);
38         /// remove given word from list
39         void remove(docstring const & word);
40         /// is word list modified after load/save?
41         bool isDirty() const { return dirty_; }
42         /// first item in word list
43         docstring_list::const_iterator begin() const;
44         /// end of word list
45         docstring_list::const_iterator end() const;
46 private:
47         docstring_list words_;
48         std::string lang_;
49         bool dirty_;
50         bool equalwords(docstring const & w1, docstring const & w2) const;
51         std::string header() const { return "# personal word list"; }
52         void dirty(bool flag) { dirty_ = flag; }
53 };
54
55 } // namespace lyx
56
57 #endif // PERSONAL_WORD_LIST_H