Update mojo sdk to rev 1dc8a9a5db73d3718d99917fadf31f5fb2ebad4f
[chromium-blink-merge.git] / third_party / hunspell / google / bdict_writer.h
blobc34170805fa96d4b275f7a4424e35522e1fa56da
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_THIRD_PARTY_HUNSPELL_GOOGLE_BDICT_WRITER_H__
6 #define CHROME_THIRD_PARTY_HUNSPELL_GOOGLE_BDICT_WRITER_H__
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
13 namespace hunspell {
15 class DicNode;
17 // Class for creating a binary dictionary file from data read from Hunspell
18 // spellchecker files.
19 class BDictWriter {
20 public:
21 typedef std::vector< std::pair<std::string, std::vector<int> > > WordList;
23 BDictWriter();
24 ~BDictWriter();
26 // Affix setters.
27 void SetComment(const std::string& comment) {
28 comment_ = comment;
30 void SetAffixRules(const std::vector<std::string>& rules) {
31 affix_rules_ = rules;
33 void SetAffixGroups(const std::vector<std::string>& groups) {
34 affix_groups_ = groups;
36 void SetReplacements(
37 const std::vector< std::pair<std::string, std::string> >& replacements) {
38 replacements_ = replacements;
40 void SetOtherCommands(const std::vector<std::string>& commands) {
41 other_commands_ = commands;
44 // The words must be sorted already.
45 void SetWords(const WordList& words);
47 // Returns the serialized data for the entire file. You must call all the
48 // setters above before this.
49 std::string GetBDict() const;
51 private:
52 // Converts the affix members to a string.
53 void SerializeAff(std::string* output) const;
55 // Affix members.
56 std::string comment_;
57 std::vector<std::string> affix_rules_;
58 std::vector<std::string> affix_groups_;
59 std::vector< std::pair<std::string, std::string> > replacements_;
60 std::vector<std::string> other_commands_;
62 // Root of the generated trie. Filled by SetWords.
63 DicNode* trie_root_;
65 DISALLOW_EVIL_CONSTRUCTORS(BDictWriter);
68 } // namespace hunspell
70 #endif // CHROME_THIRD_PARTY_HUNSPELL_GOOGLE_BDICT_WRITER_H__