summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-03-12 16:22:03 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-03-12 16:22:03 (GMT)
commit410d721ec495e29e15d45cbd921a9bb59133973d (patch)
tree9d1dfd3f5d85ecdf41ba1296b518b65c269edc2a /Swiften
parentb5d0be6e0d5b57effc5b7883d6e6e72aa2a1f062 (diff)
downloadswift-contrib-410d721ec495e29e15d45cbd921a9bb59133973d.zip
swift-contrib-410d721ec495e29e15d45cbd921a9bb59133973d.tar.bz2
Make ByteArray an std::vector<unsigned char>.
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Avatars/AvatarFileStorage.cpp2
-rw-r--r--Swiften/Base/ByteArray.cpp2
-rw-r--r--Swiften/Base/ByteArray.h14
-rw-r--r--Swiften/Base/Paths.cpp6
-rw-r--r--Swiften/Base/UnitTest/ByteArrayTest.cpp2
-rw-r--r--Swiften/Compress/ZLibCodecompressor.cpp2
-rw-r--r--Swiften/Disco/CapsFileStorage.cpp2
-rw-r--r--Swiften/FileTransfer/FileReadBytestream.cpp2
-rw-r--r--Swiften/FileTransfer/FileWriteBytestream.cpp2
-rw-r--r--Swiften/Network/PlatformDomainNameServiceQuery.cpp4
-rw-r--r--Swiften/SASL/DIGESTMD5Properties.cpp2
-rw-r--r--Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp2
-rw-r--r--Swiften/Session/BasicSessionStream.cpp4
-rw-r--r--Swiften/Session/SessionTracer.h2
-rw-r--r--Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp2
-rw-r--r--Swiften/StreamStack/XMPPLayer.cpp2
-rw-r--r--Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp4
-rw-r--r--Swiften/VCards/VCardFileStorage.cpp2
18 files changed, 29 insertions, 29 deletions
diff --git a/Swiften/Avatars/AvatarFileStorage.cpp b/Swiften/Avatars/AvatarFileStorage.cpp
index 5caf794..500bb78 100644
--- a/Swiften/Avatars/AvatarFileStorage.cpp
+++ b/Swiften/Avatars/AvatarFileStorage.cpp
@@ -58,7 +58,7 @@ void AvatarFileStorage::addAvatar(const std::string& hash, const ByteArray& avat
}
}
boost::filesystem::ofstream file(avatarPath, boost::filesystem::ofstream::binary|boost::filesystem::ofstream::out);
- file.write(avatar.getData(), avatar.getSize());
+ file.write(reinterpret_cast<const char*>(avatar.getData()), avatar.getSize());
file.close();
}
diff --git a/Swiften/Base/ByteArray.cpp b/Swiften/Base/ByteArray.cpp
index 7701268..928e145 100644
--- a/Swiften/Base/ByteArray.cpp
+++ b/Swiften/Base/ByteArray.cpp
@@ -31,7 +31,7 @@ void ByteArray::readFromFile(const std::string& file) {
while (input.good()) {
size_t oldSize = data_.size();
data_.resize(oldSize + BUFFER_SIZE);
- input.read(&data_[oldSize], BUFFER_SIZE);
+ input.read(reinterpret_cast<char*>(&data_[oldSize]), BUFFER_SIZE);
data_.resize(oldSize + input.gcount());
}
input.close();
diff --git a/Swiften/Base/ByteArray.h b/Swiften/Base/ByteArray.h
index d274663..26adedc 100644
--- a/Swiften/Base/ByteArray.h
+++ b/Swiften/Base/ByteArray.h
@@ -16,7 +16,7 @@ namespace Swift {
class ByteArray
{
public:
- typedef std::vector<char>::const_iterator const_iterator;
+ typedef std::vector<unsigned char>::const_iterator const_iterator;
ByteArray() : data_() {}
@@ -43,11 +43,11 @@ namespace Swift {
}
}
- const char* getData() const {
+ const unsigned char* getData() const {
return data_.empty() ? NULL : &data_[0];
}
- char* getData() {
+ unsigned char* getData() {
return data_.empty() ? NULL : &data_[0];
}
@@ -95,11 +95,11 @@ namespace Swift {
}
- const char& operator[](size_t i) const {
+ const unsigned char& operator[](size_t i) const {
return data_[i];
}
- char& operator[](size_t i) {
+ unsigned char& operator[](size_t i) {
return data_[i];
}
@@ -112,7 +112,7 @@ namespace Swift {
}
std::string toString() const {
- return std::string(getData(), getSize());
+ return std::string(reinterpret_cast<const char*>(getData()), getSize());
}
void readFromFile(const std::string& file);
@@ -122,7 +122,7 @@ namespace Swift {
}
private:
- std::vector<char> data_;
+ std::vector<unsigned char> data_;
};
}
diff --git a/Swiften/Base/Paths.cpp b/Swiften/Base/Paths.cpp
index 0e69b61..43eee57 100644
--- a/Swiften/Base/Paths.cpp
+++ b/Swiften/Base/Paths.cpp
@@ -24,13 +24,13 @@ boost::filesystem::path Paths::getExecutablePath() {
ByteArray path;
uint32_t size = 4096;
path.resize(size);
- if (_NSGetExecutablePath(path.getData(), &size) == 0) {
+ if (_NSGetExecutablePath(reinterpret_cast<char*>(path.getData()), &size) == 0) {
return boost::filesystem::path(path.toString().c_str()).parent_path();
}
#elif defined(SWIFTEN_PLATFORM_LINUX)
ByteArray path;
path.resize(4096);
- size_t size = readlink("/proc/self/exe", path.getData(), path.getSize());
+ size_t size = readlink("/proc/self/exe", reinterpret_cast<char*>(path.getData()), path.getSize());
if (size > 0) {
path.resize(size);
return boost::filesystem::path(path.toString().c_str()).parent_path();
@@ -38,7 +38,7 @@ boost::filesystem::path Paths::getExecutablePath() {
#elif defined(SWIFTEN_PLATFORM_WINDOWS)
ByteArray data;
data.resize(2048);
- GetModuleFileName(NULL, data.getData(), data.getSize());
+ GetModuleFileName(NULL, reinterpret_cast<char*>(data.getData()), data.getSize());
return boost::filesystem::path(data.toString().c_str()).parent_path();
#endif
return boost::filesystem::path();
diff --git a/Swiften/Base/UnitTest/ByteArrayTest.cpp b/Swiften/Base/UnitTest/ByteArrayTest.cpp
index 1d742fc..cb10dd4 100644
--- a/Swiften/Base/UnitTest/ByteArrayTest.cpp
+++ b/Swiften/Base/UnitTest/ByteArrayTest.cpp
@@ -20,7 +20,7 @@ class ByteArrayTest : public CppUnit::TestFixture {
void testGetData_NoData() {
ByteArray testling;
- CPPUNIT_ASSERT_EQUAL(static_cast<const char*>(NULL), static_cast<const char*>(testling.getData()));
+ CPPUNIT_ASSERT_EQUAL(reinterpret_cast<const char*>(NULL), reinterpret_cast<const char*>(testling.getData()));
}
};
diff --git a/Swiften/Compress/ZLibCodecompressor.cpp b/Swiften/Compress/ZLibCodecompressor.cpp
index 39f318b..c093fb3 100644
--- a/Swiften/Compress/ZLibCodecompressor.cpp
+++ b/Swiften/Compress/ZLibCodecompressor.cpp
@@ -27,7 +27,7 @@ ZLibCodecompressor::~ZLibCodecompressor() {
ByteArray ZLibCodecompressor::process(const ByteArray& input) {
ByteArray output;
stream_.avail_in = input.getSize();
- stream_.next_in = reinterpret_cast<Bytef*>(const_cast<char*>(input.getData()));
+ stream_.next_in = reinterpret_cast<Bytef*>(const_cast<unsigned char*>(input.getData()));
int outputPosition = 0;
do {
output.resize(outputPosition + CHUNK_SIZE);
diff --git a/Swiften/Disco/CapsFileStorage.cpp b/Swiften/Disco/CapsFileStorage.cpp
index 2334acf..1e53854 100644
--- a/Swiften/Disco/CapsFileStorage.cpp
+++ b/Swiften/Disco/CapsFileStorage.cpp
@@ -29,7 +29,7 @@ DiscoInfo::ref CapsFileStorage::getDiscoInfo(const std::string& hash) const {
DiscoInfoParser parser;
PayloadParserTester tester(&parser);
- tester.parse(std::string(data.getData(), data.getSize()));
+ tester.parse(data.toString());
return boost::dynamic_pointer_cast<DiscoInfo>(parser.getPayload());
}
else {
diff --git a/Swiften/FileTransfer/FileReadBytestream.cpp b/Swiften/FileTransfer/FileReadBytestream.cpp
index 7ed33af..c08747b 100644
--- a/Swiften/FileTransfer/FileReadBytestream.cpp
+++ b/Swiften/FileTransfer/FileReadBytestream.cpp
@@ -28,7 +28,7 @@ ByteArray FileReadBytestream::read(size_t size) {
ByteArray result;
result.resize(size);
assert(stream->good());
- stream->read(result.getData(), size);
+ stream->read(reinterpret_cast<char*>(result.getData()), size);
result.resize(stream->gcount());
return result;
}
diff --git a/Swiften/FileTransfer/FileWriteBytestream.cpp b/Swiften/FileTransfer/FileWriteBytestream.cpp
index b864b6f..4d29bd1 100644
--- a/Swiften/FileTransfer/FileWriteBytestream.cpp
+++ b/Swiften/FileTransfer/FileWriteBytestream.cpp
@@ -26,7 +26,7 @@ void FileWriteBytestream::write(const ByteArray& data) {
stream = new boost::filesystem::ofstream(file, std::ios_base::out|std::ios_base::binary);
}
assert(stream->good());
- stream->write(data.getData(), data.getSize());
+ stream->write(reinterpret_cast<const char*>(data.getData()), data.getSize());
}
}
diff --git a/Swiften/Network/PlatformDomainNameServiceQuery.cpp b/Swiften/Network/PlatformDomainNameServiceQuery.cpp
index d3b3561..24adde5 100644
--- a/Swiften/Network/PlatformDomainNameServiceQuery.cpp
+++ b/Swiften/Network/PlatformDomainNameServiceQuery.cpp
@@ -146,12 +146,12 @@ void PlatformDomainNameServiceQuery::runBlocking() {
}
ByteArray entry;
entry.resize(NS_MAXDNAME);
- entryLength = dn_expand(messageStart, messageEnd, currentEntry, entry.getData(), entry.getSize());
+ entryLength = dn_expand(messageStart, messageEnd, currentEntry, reinterpret_cast<char*>(entry.getData()), entry.getSize());
if (entryLength < 0) {
emitError();
return;
}
- record.hostname = std::string(entry.getData());
+ record.hostname = std::string(reinterpret_cast<const char*>(entry.getData()));
records.push_back(record);
currentEntry += entryLength;
answersCount--;
diff --git a/Swiften/SASL/DIGESTMD5Properties.cpp b/Swiften/SASL/DIGESTMD5Properties.cpp
index c7a2474..dfff9c8 100644
--- a/Swiften/SASL/DIGESTMD5Properties.cpp
+++ b/Swiften/SASL/DIGESTMD5Properties.cpp
@@ -25,7 +25,7 @@ namespace {
}
ByteArray stripQuotes(const ByteArray& v) {
- const char* data = v.getData();
+ const char* data = reinterpret_cast<const char*>(v.getData());
size_t size = v.getSize();
if (v[0] == '"') {
data++;
diff --git a/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp b/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp
index 72d535a..2dd7bf4 100644
--- a/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp
+++ b/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp
@@ -65,7 +65,7 @@ bool SCRAMSHA1ClientAuthenticator::setChallenge(const boost::optional<ByteArray>
}
initialServerMessage = *challenge;
- std::map<char, std::string> keys = parseMap(std::string(initialServerMessage.getData(), initialServerMessage.getSize()));
+ std::map<char, std::string> keys = parseMap(initialServerMessage.toString());
// Extract the salt
ByteArray salt = Base64::decode(keys['s']);
diff --git a/Swiften/Session/BasicSessionStream.cpp b/Swiften/Session/BasicSessionStream.cpp
index ddb833e..c783e01 100644
--- a/Swiften/Session/BasicSessionStream.cpp
+++ b/Swiften/Session/BasicSessionStream.cpp
@@ -193,11 +193,11 @@ void BasicSessionStream::handleConnectionFinished(const boost::optional<Connecti
}
void BasicSessionStream::handleDataRead(const ByteArray& data) {
- onDataRead(std::string(data.getData(), data.getSize()));
+ onDataRead(data.toString());
}
void BasicSessionStream::handleDataWritten(const ByteArray& data) {
- onDataWritten(std::string(data.getData(), data.getSize()));
+ onDataWritten(data.toString());
}
};
diff --git a/Swiften/Session/SessionTracer.h b/Swiften/Session/SessionTracer.h
index 7c6f3fa..cce45eb 100644
--- a/Swiften/Session/SessionTracer.h
+++ b/Swiften/Session/SessionTracer.h
@@ -27,7 +27,7 @@ namespace Swift {
std::cerr << direction;
}
std::cerr << " " << session->getRemoteJID()<< " " << direction << direction << std::endl;
- std::cerr << std::string(data.getData(), data.getSize()) << std::endl;
+ std::cerr << data.toString() << std::endl;
}
boost::shared_ptr<Session> session;
diff --git a/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp b/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp
index 6c69a5f..9d5e745 100644
--- a/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp
+++ b/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp
@@ -121,7 +121,7 @@ class XMPPLayerTest : public CppUnit::TestFixture {
class DummyLowLayer : public LowLayer {
public:
virtual void writeData(const ByteArray& data) {
- writtenData += std::string(data.getData(), data.getSize());
+ writtenData += data.toString();
}
std::string writtenData;
diff --git a/Swiften/StreamStack/XMPPLayer.cpp b/Swiften/StreamStack/XMPPLayer.cpp
index a1e7ba3..684dfe6 100644
--- a/Swiften/StreamStack/XMPPLayer.cpp
+++ b/Swiften/StreamStack/XMPPLayer.cpp
@@ -52,7 +52,7 @@ void XMPPLayer::writeDataInternal(const ByteArray& data) {
void XMPPLayer::handleDataRead(const ByteArray& data) {
onDataRead(data);
inParser_ = true;
- if (!xmppParser_->parse(std::string(data.getData(), data.getSize()))) {
+ if (!xmppParser_->parse(data.toString())) {
inParser_ = false;
onError();
return;
diff --git a/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp b/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp
index 8a3bf97..bc39c1b 100644
--- a/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp
+++ b/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp
@@ -57,8 +57,8 @@ void OpenSSLCertificate::parse() {
// Subject name
ByteArray subjectNameData;
subjectNameData.resize(256);
- X509_NAME_oneline(X509_get_subject_name(cert.get()), subjectNameData.getData(), subjectNameData.getSize());
- this->subjectName = std::string(subjectNameData.getData());
+ X509_NAME_oneline(X509_get_subject_name(cert.get()), reinterpret_cast<char*>(subjectNameData.getData()), subjectNameData.getSize());
+ this->subjectName = std::string(reinterpret_cast<const char*>(subjectNameData.getData()));
// Common name
int cnLoc = X509_NAME_get_index_by_NID(subjectName, NID_commonName, -1);
diff --git a/Swiften/VCards/VCardFileStorage.cpp b/Swiften/VCards/VCardFileStorage.cpp
index 3f84678..e18b7a0 100644
--- a/Swiften/VCards/VCardFileStorage.cpp
+++ b/Swiften/VCards/VCardFileStorage.cpp
@@ -56,7 +56,7 @@ boost::shared_ptr<VCard> VCardFileStorage::getVCard(const JID& jid) const {
VCardParser parser;
PayloadParserTester tester(&parser);
- tester.parse(std::string(data.getData(), data.getSize()));
+ tester.parse(data.toString());
return boost::dynamic_pointer_cast<VCard>(parser.getPayload());
}
else {