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/Base
parentb5d0be6e0d5b57effc5b7883d6e6e72aa2a1f062 (diff)
downloadswift-410d721ec495e29e15d45cbd921a9bb59133973d.zip
swift-410d721ec495e29e15d45cbd921a9bb59133973d.tar.bz2
Make ByteArray an std::vector<unsigned char>.
Diffstat (limited to 'Swiften/Base')
-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
4 files changed, 12 insertions, 12 deletions
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()));
}
};