1 /* 2 * Copyright 2005-2007 Gerald Schmidt. 3 * 4 * This file is part of Xml Copy Editor. 5 * 6 * Xml Copy Editor is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version 2 9 * of the License, or (at your option) any later version. 10 * 11 * Xml Copy Editor is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with Xml Copy Editor; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 */ 20 21 #ifndef HOUSESTYLE_H 22 #define HOUSESTYLE_H 23 24 #include <string> 25 #include <vector> 26 #include <set> 27 #include <map> 28 #include <utility> 29 #include <boost/shared_ptr.hpp> 30 #include "stringset.h" 31 #include "contexthandler.h" 32 #include "xmlrulereader.h" 33 #include "housestylereader.h" 34 #include "xmlfilterreader.h" 35 #include "wrapaspell.h" 36 #include "casehandler.h" 37 38 enum { 39 HS_TYPE_SPELL = 0, 40 HS_TYPE_STYLE 41 }; 42 43 class HouseStyle 44 { 45 public: 46 HouseStyle ( 47 int type, 48 const std::string& bufferParameter, 49 const wxString& ruleDirectoryParameter, 50 const wxString& ruleFileParameter, 51 const wxString& filterDirectoryParameter, 52 const wxString& filterFileParameter, 53 const wxString& pathSeparatorParameter, 54 #ifdef __WXMSW__ 55 const wxString& aspellDataPathParameter, 56 const wxString& aspellDictPathParameter, 57 #endif 58 int contextRangeParameter ); 59 ~HouseStyle(); 60 bool createReport(); 61 const wxString &getLastError(); 62 const std::vector<ContextMatch> &getMatchVector(); 63 private: 64 int type; 65 std::string buffer; 66 wxString ruleDirectory 67 , ruleFile 68 , filterDirectory 69 , filterFile 70 , pathSeparator 71 , error 72 #ifdef __WXMSW__ 73 , aspellDataPath 74 , aspellDictPath 75 #endif 76 ; 77 int contextRange; 78 boost::shared_ptr<std::vector<boost::shared_ptr<Rule> > > ruleVector; 79 std::map<std::string, std::map<std::string, std::set<std::string> > > 80 filterMap; 81 std::vector<ContextMatch> matchVector; 82 boost::shared_ptr<StringSet<char> > dictionary, passiveDictionary; 83 void collectFilter ( 84 const std::string& fileName, 85 std::set<std::string>& excludeSet, 86 int *filterCount ); 87 void collectRules ( 88 const std::string& fileName, 89 boost::shared_ptr<std::vector<boost::shared_ptr<Rule> > > ruleVector, 90 std::set<string>& excludeSet, 91 int *ruleCount ); 92 int updateFilter(); 93 int updateRules(); 94 }; 95 96 #endif 97