From 3d6bc0b6181c6cdfc6c0a91960e9dac30ddfdba2 Mon Sep 17 00:00:00 2001 From: Vlad Voicu Date: Sat, 28 Jan 2012 03:28:22 +0200 Subject: Changed name from vector to List for PositionPairList 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::vectorcheck(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& 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& 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 - 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 > 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 > PositionPairVector; + typedef std::list > 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); diff --git a/Swift/QtUI/QtTextEdit.cpp b/Swift/QtUI/QtTextEdit.cpp index 2dabd7e..7e7683c 100644 --- a/Swift/QtUI/QtTextEdit.cpp +++ b/Swift/QtUI/QtTextEdit.cpp @@ -72,7 +72,7 @@ void QtTextEdit::underlineMisspells() { cursor.setCharFormat(normalFormat); std::string fragment = Q2PSTRING(cursor.selectedText()); checker_->checkFragment(fragment, misspelledPositions_); - for (PositionPairVector::iterator it = misspelledPositions_.begin(); it != misspelledPositions_.end(); ++it) { + for (PositionPairList::iterator it = misspelledPositions_.begin(); it != misspelledPositions_.end(); ++it) { if (textCursor().position() > boost::get<1>(*it)) { cursor.setPosition(boost::get<0>(*it), QTextCursor::MoveAnchor); cursor.setPosition(boost::get<1>(*it), QTextCursor::KeepAnchor); @@ -100,7 +100,7 @@ void QtTextEdit::handleReplaceMisspellWord(const QString& word, const boost::tup } boost::tuple QtTextEdit::getWordFromCursor(int cursorPosition) { - for (PositionPairVector::iterator it = misspelledPositions_.begin(); it != misspelledPositions_.end(); ++it) { + for (PositionPairList::iterator it = misspelledPositions_.begin(); it != misspelledPositions_.end(); ++it) { if (cursorPosition >= boost::get<0>(*it) && cursorPosition <= boost::get<1>(*it)) { return *it; } diff --git a/Swift/QtUI/QtTextEdit.h b/Swift/QtUI/QtTextEdit.h index 76087c9..297312d 100644 --- a/Swift/QtUI/QtTextEdit.h +++ b/Swift/QtUI/QtTextEdit.h @@ -30,7 +30,7 @@ namespace Swift { void handleTextChanged(); private: SpellChecker *checker_; - PositionPairVector misspelledPositions_; + PositionPairList misspelledPositions_; void underlineMisspells(); boost::tuple getWordFromCursor(int cursorPosition); }; -- cgit v0.10.2-6-g49f6