summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVlad Voicu <vladv@rosedu.org>2012-01-28 01:28:22 (GMT)
committervlad <vlad@tyrion.(none)>2012-10-13 13:55:44 (GMT)
commit3d6bc0b6181c6cdfc6c0a91960e9dac30ddfdba2 (patch)
treeb5196fc36721783a02492061fbbc865338ed6863
parenteca3a097403adbd85fe3b0cf366f29ecc37cacc6 (diff)
downloadswift-contrib-3d6bc0b6181c6cdfc6c0a91960e9dac30ddfdba2.zip
swift-contrib-3d6bc0b6181c6cdfc6c0a91960e9dac30ddfdba2.tar.bz2
Changed name from vector to List for PositionPairList
-rw-r--r--SwifTools/HunspellChecker.cpp4
-rw-r--r--SwifTools/HunspellChecker.h2
-rw-r--r--SwifTools/SpellChecker.h2
-rw-r--r--SwifTools/SpellParser.cpp4
-rw-r--r--SwifTools/SpellParser.h4
-rw-r--r--SwifTools/UnitTest/SpellParserTest.cpp18
-rw-r--r--Swift/QtUI/QtTextEdit.cpp4
-rw-r--r--Swift/QtUI/QtTextEdit.h2
8 files changed, 20 insertions, 20 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);
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<int, int> 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<int,int> getWordFromCursor(int cursorPosition);
};