OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_TOOLS_CONVERT_DICT_AFF_READER_H__ | 5 #ifndef CHROME_TOOLS_CONVERT_DICT_AFF_READER_H__ |
6 #define CHROME_TOOLS_CONVERT_DICT_AFF_READER_H__ | 6 #define CHROME_TOOLS_CONVERT_DICT_AFF_READER_H__ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <stdio.h> | 9 #include <stdio.h> |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 namespace convert_dict { | 13 namespace convert_dict { |
14 | 14 |
15 class AffReader { | 15 class AffReader { |
16 public: | 16 public: |
17 AffReader(const std::string& filename); | 17 explicit explicit AffReader(const std::string& filename); |
18 ~AffReader(); | 18 ~AffReader(); |
19 | 19 |
20 bool Read(); | 20 bool Read(); |
21 | 21 |
22 // Returns whether this file uses indexed affixes, or, on false, whether the | 22 // Returns whether this file uses indexed affixes, or, on false, whether the |
23 // rule string will be specified literally in the .dic file. This must be | 23 // rule string will be specified literally in the .dic file. This must be |
24 // called after Read(). | 24 // called after Read(). |
25 bool has_indexed_affixes() const { return has_indexed_affixes_; } | 25 bool has_indexed_affixes() const { return has_indexed_affixes_; } |
26 | 26 |
27 // Returns a string representing the encoding of the dictionary. This will | 27 // Returns a string representing the encoding of the dictionary. This will |
(...skipping 25 matching lines...) Expand all Loading... |
53 // are 1-based, but we don't use the 0th item, so lookups will have to | 53 // are 1-based, but we don't use the 0th item, so lookups will have to |
54 // subtract one to get the index. This is how hunspell stores this data. | 54 // subtract one to get the index. This is how hunspell stores this data. |
55 std::vector<std::string> GetAffixGroups() const; | 55 std::vector<std::string> GetAffixGroups() const; |
56 | 56 |
57 private: | 57 private: |
58 // Command-specific handlers. These are given the string folling the | 58 // Command-specific handlers. These are given the string folling the |
59 // command. The input rule may be modified arbitrarily by the function. | 59 // command. The input rule may be modified arbitrarily by the function. |
60 int AddAffixGroup(std::string* rule); // Returns the new affix group ID. | 60 int AddAffixGroup(std::string* rule); // Returns the new affix group ID. |
61 void AddAffix(std::string* rule); // SFX/PFX | 61 void AddAffix(std::string* rule); // SFX/PFX |
62 void AddReplacement(std::string* rule); | 62 void AddReplacement(std::string* rule); |
63 //void HandleFlag(std::string* rule); | 63 // void HandleFlag(std::string* rule); |
64 | 64 |
65 // Used to handle "other" commands. The "raw" just saves the line as-is. | 65 // Used to handle "other" commands. The "raw" just saves the line as-is. |
66 // The "encoded" version converts the line to UTF-8 and saves it. | 66 // The "encoded" version converts the line to UTF-8 and saves it. |
67 void HandleRawCommand(const std::string& line); | 67 void HandleRawCommand(const std::string& line); |
68 void HandleEncodedCommand(const std::string& line); | 68 void HandleEncodedCommand(const std::string& line); |
69 | 69 |
70 FILE* file_; | 70 FILE* file_; |
71 | 71 |
72 // Comments from the beginning of the file. This is everything before the | 72 // Comments from the beginning of the file. This is everything before the |
73 // first command. We want to store this since it often contains the copyright | 73 // first command. We want to store this since it often contains the copyright |
(...skipping 23 matching lines...) Expand all Loading... |
97 // is the replacment. | 97 // is the replacment. |
98 std::vector< std::pair<std::string, std::string> > replacements_; | 98 std::vector< std::pair<std::string, std::string> > replacements_; |
99 | 99 |
100 // All other commands. | 100 // All other commands. |
101 std::vector<std::string> other_commands_; | 101 std::vector<std::string> other_commands_; |
102 }; | 102 }; |
103 | 103 |
104 } // namespace convert_dict | 104 } // namespace convert_dict |
105 | 105 |
106 #endif // CHROME_TOOLS_CONVERT_DICT_AFF_READER_H__ | 106 #endif // CHROME_TOOLS_CONVERT_DICT_AFF_READER_H__ |
OLD | NEW |