diff options
| -rw-r--r-- | Swiften/Base/String.cpp | 18 | ||||
| -rw-r--r-- | Swiften/Base/String.h | 7 | ||||
| -rw-r--r-- | Swiften/Base/UnitTest/StringTest.cpp | 28 | ||||
| -rw-r--r-- | Swiften/LinkLocal/LinkLocalServiceInfo.cpp | 1 | ||||
| -rw-r--r-- | Swiften/Session/SessionTracer.h | 2 | 
5 files changed, 5 insertions, 51 deletions
| diff --git a/Swiften/Base/String.cpp b/Swiften/Base/String.cpp index 17d49c2..460df36 100644 --- a/Swiften/Base/String.cpp +++ b/Swiften/Base/String.cpp @@ -69,24 +69,6 @@ std::pair<String,String> String::getSplittedAtFirst(char c) const {  	}  } -size_t String::getLength() const { -	size_t size = 0, current = 0, end = data_.size(); -	while (current < end) { -		size++; -		current += sequenceLength(data_[current]); -	} -	return size; -} - -void String::removeAll(char c) { -	size_t lastPos = 0; -	size_t matchingIndex = 0; -	while ((matchingIndex = data_.find(c, lastPos)) != data_.npos) { -		data_.erase(matchingIndex, 1); -		lastPos = matchingIndex; -	} -} -  void String::replaceAll(char c, const String& s) {  	size_t lastPos = 0;  	size_t matchingIndex = 0; diff --git a/Swiften/Base/String.h b/Swiften/Base/String.h index c87d82b..7d2f928 100644 --- a/Swiften/Base/String.h +++ b/Swiften/Base/String.h @@ -13,6 +13,7 @@  #include <utility>  #include <vector>  #include <cassert> +#include <algorithm>  #define SWIFTEN_STRING_TO_CFSTRING(a) \  	CFStringCreateWithBytes(NULL, reinterpret_cast<const UInt8*>(a.getUTF8Data()), a.getUTF8Size(), kCFStringEncodingUTF8, false) @@ -48,13 +49,13 @@ namespace Swift {  			std::vector<String> split(char c) const; -			size_t getLength() const; -  			String getLowerCase() const {  				return boost::to_lower_copy(data_);  			} -			void removeAll(char c); +			void removeAll(char c) { +				data_.erase(std::remove(data_.begin(), data_.end(), c), data_.end()); +			}  			void replaceAll(char c, const String& s); diff --git a/Swiften/Base/UnitTest/StringTest.cpp b/Swiften/Base/UnitTest/StringTest.cpp index eff7b80..161b4f1 100644 --- a/Swiften/Base/UnitTest/StringTest.cpp +++ b/Swiften/Base/UnitTest/StringTest.cpp @@ -14,10 +14,6 @@ using namespace Swift;  class StringTest : public CppUnit::TestFixture  {  		CPPUNIT_TEST_SUITE(StringTest); -		CPPUNIT_TEST(testGetLength); -		CPPUNIT_TEST(testGetLength_EncodedLength2); -		CPPUNIT_TEST(testGetLength_EncodedLength3); -		CPPUNIT_TEST(testGetLength_EncodedLength4);  		CPPUNIT_TEST(testGetUnicodeCodePoints);  		CPPUNIT_TEST(testGetSplittedAtFirst);  		CPPUNIT_TEST(testGetSplittedAtFirst_CharacterAtEnd); @@ -39,30 +35,6 @@ class StringTest : public CppUnit::TestFixture  		CPPUNIT_TEST_SUITE_END();  	public: -		void testGetLength() { -			String testling("xyz$xyz"); - -			CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(7), testling.getLength()); -		} - -		void testGetLength_EncodedLength2() { -			String testling("xyz\xC2\xA2xyz"); - -			CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(7), testling.getLength()); -		} - -		void testGetLength_EncodedLength3() { -			String testling("xyz\xE2\x82\xACxyz"); - -			CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(7), testling.getLength()); -		} - -		void testGetLength_EncodedLength4() { -			String testling("xyz\xf4\x8a\xaf\x8dxyz"); - -			CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(7), testling.getLength()); -		} -  		void testGetUnicodeCodePoints() {  			String testling("$\xc2\xa2\xe2\x82\xac\xf4\x8a\xaf\x8d");  			std::vector<unsigned int> points = testling.getUnicodeCodePoints(); diff --git a/Swiften/LinkLocal/LinkLocalServiceInfo.cpp b/Swiften/LinkLocal/LinkLocalServiceInfo.cpp index d89b6f9..cdde354 100644 --- a/Swiften/LinkLocal/LinkLocalServiceInfo.cpp +++ b/Swiften/LinkLocal/LinkLocalServiceInfo.cpp @@ -46,7 +46,6 @@ ByteArray LinkLocalServiceInfo::toTXTRecord() const {  ByteArray LinkLocalServiceInfo::getEncoded(const String& s) {  	ByteArray sizeByte;  	sizeByte.resize(1); -	assert(s.getLength() < 256);  	sizeByte[0] = s.getUTF8Size();  	return sizeByte + ByteArray(s);  } diff --git a/Swiften/Session/SessionTracer.h b/Swiften/Session/SessionTracer.h index 13348fb..9315d2f 100644 --- a/Swiften/Session/SessionTracer.h +++ b/Swiften/Session/SessionTracer.h @@ -23,7 +23,7 @@ namespace Swift {  		private:  			void printData(char direction, const ByteArray& data) {  				std::cerr << direction << direction << " " << session->getLocalJID() << " "; -				for (unsigned int i = 0; i < 72 - session->getLocalJID().toString().getLength() - session->getRemoteJID().toString().getLength(); ++i) { +				for (unsigned int i = 0; i < 72 - session->getLocalJID().toString().getUTF8Size() - session->getRemoteJID().toString().getUTF8Size(); ++i) {  					std::cerr << direction;  				}  				std::cerr << " " << session->getRemoteJID()<< " " << direction << direction << std::endl; | 
 Swift
 Swift