| 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_DIC_READER_H__ | 5 #ifndef CHROME_TOOLS_CONVERT_DICT_DIC_READER_H__ |
| 6 #define CHROME_TOOLS_CONVERT_DICT_DIC_READER_H__ | 6 #define CHROME_TOOLS_CONVERT_DICT_DIC_READER_H__ |
| 7 | 7 |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 class FilePath; |
| 14 |
| 13 namespace convert_dict { | 15 namespace convert_dict { |
| 14 | 16 |
| 15 class AffReader; | 17 class AffReader; |
| 16 | 18 |
| 17 // Reads Hunspell .dic files. | 19 // Reads Hunspell .dic files. |
| 18 class DicReader { | 20 class DicReader { |
| 19 public: | 21 public: |
| 20 // Associated with each word is a list of affix group IDs. This will typically | 22 // Associated with each word is a list of affix group IDs. This will typically |
| 21 // be only one long, but may be more if there are multiple groups of | 23 // be only one long, but may be more if there are multiple groups of |
| 22 // independent affix rules for a base word. | 24 // independent affix rules for a base word. |
| 23 typedef std::pair<std::string, std::vector<int> > WordEntry; | 25 typedef std::pair<std::string, std::vector<int> > WordEntry; |
| 24 typedef std::vector<WordEntry> WordList; | 26 typedef std::vector<WordEntry> WordList; |
| 25 | 27 |
| 26 explicit DicReader(const std::string& filename); | 28 explicit DicReader(const FilePath& path); |
| 27 ~DicReader(); | 29 ~DicReader(); |
| 28 | 30 |
| 29 // Non-numeric affixes will be added to the given AffReader and converted into | 31 // Non-numeric affixes will be added to the given AffReader and converted into |
| 30 // indices. | 32 // indices. |
| 31 bool Read(AffReader* aff_reader); | 33 bool Read(AffReader* aff_reader); |
| 32 | 34 |
| 33 // Returns the words read by Read(). These will be in order. | 35 // Returns the words read by Read(). These will be in order. |
| 34 const WordList& words() const { return words_; } | 36 const WordList& words() const { return words_; } |
| 35 | 37 |
| 36 private: | 38 private: |
| 37 FILE* file_; | 39 FILE* file_; |
| 38 FILE* additional_words_file_; | 40 FILE* additional_words_file_; |
| 39 | 41 |
| 40 // Contains all words and their corresponding affix index. | 42 // Contains all words and their corresponding affix index. |
| 41 WordList words_; | 43 WordList words_; |
| 42 }; | 44 }; |
| 43 | 45 |
| 44 } // namespace convert_dict | 46 } // namespace convert_dict |
| 45 | 47 |
| 46 #endif // CHROME_TOOLS_CONVERT_DICT_DIC_READER_H__ | 48 #endif // CHROME_TOOLS_CONVERT_DICT_DIC_READER_H__ |
| OLD | NEW |