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