diff options
author | Vlad Voicu <vladv@rosedu.org> | 2012-01-28 01:28:22 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2012-03-09 15:04:01 (GMT) |
commit | 21224565867c695bc41028ce31e567554eb25a0a (patch) | |
tree | 1c9d6270d497a115ea431c5e10fae5afad8849a1 /SwifTools | |
parent | 65679c27623512a79de7c6d92c75d1a9530fb756 (diff) | |
download | swift-contrib-21224565867c695bc41028ce31e567554eb25a0a.zip swift-contrib-21224565867c695bc41028ce31e567554eb25a0a.tar.bz2 |
Changed name from vector to List for PositionPairList
Diffstat (limited to 'SwifTools')
-rw-r--r-- | SwifTools/HunspellChecker.cpp | 4 | ||||
-rw-r--r-- | SwifTools/HunspellChecker.h | 2 | ||||
-rw-r--r-- | SwifTools/SpellChecker.h | 2 | ||||
-rw-r--r-- | SwifTools/SpellParser.cpp | 4 | ||||
-rw-r--r-- | SwifTools/SpellParser.h | 4 | ||||
-rw-r--r-- | SwifTools/UnitTest/SpellParserTest.cpp | 18 |
6 files changed, 17 insertions, 17 deletions
diff --git a/SwifTools/HunspellChecker.cpp b/SwifTools/HunspellChecker.cpp index ba7cedd..6c1b4bb 100644 --- a/SwifTools/HunspellChecker.cpp +++ b/SwifTools/HunspellChecker.cpp @@ -37,10 +37,10 @@ void HunspellChecker::getSuggestions(const std::string& word, std::vector<std::s } } -void HunspellChecker::checkFragment(const std::string& fragment, PositionPairVector& misspelledPositions) { +void HunspellChecker::checkFragment(const std::string& fragment, PositionPairList& misspelledPositions) { if (!fragment.empty()) { parser_->check(fragment, misspelledPositions); - for (PositionPairVector::iterator it = misspelledPositions.begin(); it != misspelledPositions.end();) { + for (PositionPairList::iterator it = misspelledPositions.begin(); it != misspelledPositions.end();) { if (isCorrect(fragment.substr(boost::get<0>(*it), boost::get<1>(*it) - boost::get<0>(*it)))) { misspelledPositions.erase(it++); } else { diff --git a/SwifTools/HunspellChecker.h b/SwifTools/HunspellChecker.h index bf56778..12c0485 100644 --- a/SwifTools/HunspellChecker.h +++ b/SwifTools/HunspellChecker.h @@ -20,7 +20,7 @@ namespace Swift { virtual ~HunspellChecker(); virtual bool isCorrect(const std::string& word); virtual void getSuggestions(const std::string& word, std::vector<std::string>& list); - virtual void checkFragment(const std::string& fragment, PositionPairVector& misspelledPositions); + virtual void checkFragment(const std::string& fragment, PositionPairList& misspelledPositions); private: Hunspell* speller_; }; diff --git a/SwifTools/SpellChecker.h b/SwifTools/SpellChecker.h index a9cbe77..746fcaf 100644 --- a/SwifTools/SpellChecker.h +++ b/SwifTools/SpellChecker.h @@ -23,7 +23,7 @@ namespace Swift { }; virtual bool isCorrect(const std::string& word) = 0; virtual void getSuggestions(const std::string& word, std::vector<std::string>& list) = 0; - virtual void checkFragment(const std::string& fragment, PositionPairVector& misspelledPositions) = 0; + virtual void checkFragment(const std::string& fragment, PositionPairList& misspelledPositions) = 0; protected: SpellParser *parser_; }; diff --git a/SwifTools/SpellParser.cpp b/SwifTools/SpellParser.cpp index 8f5120b..440e2a1 100644 --- a/SwifTools/SpellParser.cpp +++ b/SwifTools/SpellParser.cpp @@ -36,7 +36,7 @@ struct counter typedef bool result_type; // the function operator gets called for each of the matched tokens template <typename Token> - bool operator()(Token const& t, PositionPairVector& wordPositions, std::size_t& position) const + bool operator()(Token const& t, PositionPairList& wordPositions, std::size_t& position) const { switch (t.id()) { case ID_WWW: @@ -57,7 +57,7 @@ struct counter } }; -void SpellParser::check(const std::string& fragment, PositionPairVector& wordPositions) { +void SpellParser::check(const std::string& fragment, PositionPairList& wordPositions) { std::size_t position = 0; // create the token definition instance needed to invoke the lexical analyzer word_count_tokens<lex::lexertl::lexer<> > word_count_functor; diff --git a/SwifTools/SpellParser.h b/SwifTools/SpellParser.h index 2bc562d..b18f4c2 100644 --- a/SwifTools/SpellParser.h +++ b/SwifTools/SpellParser.h @@ -20,10 +20,10 @@ namespace Swift { ID_WORD = 3, ID_CHAR = 4, }; - typedef std::list<boost::tuple<int, int> > PositionPairVector; + typedef std::list<boost::tuple<int, int> > PositionPairList; class SpellParser{ public: - void check(const std::string& fragment, PositionPairVector& wordPositions); + void check(const std::string& fragment, PositionPairList& wordPositions); }; } diff --git a/SwifTools/UnitTest/SpellParserTest.cpp b/SwifTools/UnitTest/SpellParserTest.cpp index 974f356..09e686c 100644 --- a/SwifTools/UnitTest/SpellParserTest.cpp +++ b/SwifTools/UnitTest/SpellParserTest.cpp @@ -29,23 +29,23 @@ class SpellParserTest : public CppUnit::TestFixture { parser_->check("fragment test", position_); int size = position_.size(); CPPUNIT_ASSERT_EQUAL(2, size); - CPPUNIT_ASSERT_EQUAL(0, boost::get<0>(position_[0])); - CPPUNIT_ASSERT_EQUAL(8, boost::get<1>(position_[0])); - CPPUNIT_ASSERT_EQUAL(9, boost::get<0>(position_[1])); - CPPUNIT_ASSERT_EQUAL(13, boost::get<1>(position_[1])); + CPPUNIT_ASSERT_EQUAL(0, boost::get<0>(position_.front())); + CPPUNIT_ASSERT_EQUAL(8, boost::get<1>(position_.front())); + CPPUNIT_ASSERT_EQUAL(9, boost::get<0>(position_.back())); + CPPUNIT_ASSERT_EQUAL(13, boost::get<1>(position_.back())); } void testWWWCheckFragment() { parser_->check("www.link.com fragment test", position_); int size = position_.size(); CPPUNIT_ASSERT_EQUAL(2, size); - CPPUNIT_ASSERT_EQUAL(13, boost::get<0>(position_[0])); - CPPUNIT_ASSERT_EQUAL(21, boost::get<1>(position_[0])); - CPPUNIT_ASSERT_EQUAL(22, boost::get<0>(position_[1])); - CPPUNIT_ASSERT_EQUAL(26, boost::get<1>(position_[1])); + CPPUNIT_ASSERT_EQUAL(13, boost::get<0>(position_.front())); + CPPUNIT_ASSERT_EQUAL(21, boost::get<1>(position_.front())); + CPPUNIT_ASSERT_EQUAL(22, boost::get<0>(position_.back())); + CPPUNIT_ASSERT_EQUAL(26, boost::get<1>(position_.back())); } private: SpellParser *parser_; - PositionPairVector position_; + PositionPairList position_; }; CPPUNIT_TEST_SUITE_REGISTRATION(SpellParserTest); |