diff options
author | George Hazan <george.hazan@gmail.com> | 2015-01-26 00:17:21 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-01-26 00:17:21 +0000 |
commit | 0072a0880c077fc0a21fd57214e6c5bf8497402a (patch) | |
tree | a4c4a2667fbca02b195ebc5c268752ab3a407aea /protocols/WhatsApp/src/WhatsAPI++/ByteArray.cpp | |
parent | d32c7402ad63175d48579a2779d47800a2dd74c2 (diff) |
first version that logs in
git-svn-id: http://svn.miranda-ng.org/main/trunk@11913 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/WhatsApp/src/WhatsAPI++/ByteArray.cpp')
-rw-r--r-- | protocols/WhatsApp/src/WhatsAPI++/ByteArray.cpp | 75 |
1 files changed, 10 insertions, 65 deletions
diff --git a/protocols/WhatsApp/src/WhatsAPI++/ByteArray.cpp b/protocols/WhatsApp/src/WhatsAPI++/ByteArray.cpp index 579dd58516..7e98847cff 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/ByteArray.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/ByteArray.cpp @@ -13,57 +13,33 @@ ByteArrayOutputStream::ByteArrayOutputStream(int size)
{
- this->buf = new std::vector<unsigned char>();
- this->buf->reserve(size);
- this->position = 0;
+ buf.reserve(size);
+ position = 0;
}
void ByteArrayOutputStream::setLength(size_t length)
{
- this->buf->resize(length);
-}
-
-size_t ByteArrayOutputStream::getLength()
-{
- return this->buf->size();
-}
-
-size_t ByteArrayOutputStream::getCapacity()
-{
- return this->buf->capacity();
-}
-
-size_t ByteArrayOutputStream::getPosition()
-{
- return this->position;
+ buf.resize(length);
}
void ByteArrayOutputStream::setPosition(size_t count)
{
- this->position = count;
+ position = count;
}
-std::vector<unsigned char>* ByteArrayOutputStream::toByteArray()
-{
- std::vector<unsigned char>* array = new std::vector<unsigned char>(this->buf->size());
- for (size_t i = 0; i < this->buf->size(); i++)
- (*array)[i] = (*this->buf)[i];
- return array;
-}
-
-std::vector<unsigned char>* ByteArrayOutputStream::getBuffer()
+std::vector<unsigned char>& ByteArrayOutputStream::getBuffer()
{
- return this->buf;
+ return buf;
}
void ByteArrayOutputStream::write(int i)
{
- if (this->position == this->buf->size())
- this->buf->push_back((unsigned char)i);
+ if (this->position == this->buf.size())
+ buf.push_back((unsigned char)i);
else
- (*this->buf)[this->position] = (unsigned char)i;
- this->position = this->position + 1;
+ buf[position] = (unsigned char)i;
+ position++;
}
void ByteArrayOutputStream::write(unsigned char* b, size_t len)
@@ -81,13 +57,10 @@ void ByteArrayOutputStream::write(const std::string& s) write((unsigned char)s[i]);
}
-
ByteArrayOutputStream::~ByteArrayOutputStream()
{
- delete this->buf;
}
-
ByteArrayInputStream::ByteArrayInputStream(std::vector<unsigned char>* buf, size_t off, size_t length)
{
this->buf = buf;
@@ -138,31 +111,3 @@ int ByteArrayInputStream::read(std::vector<unsigned char>& b, size_t off, size_ ByteArrayInputStream::~ByteArrayInputStream()
{}
-
-void ByteArrayInputStream::print()
-{
- std::cout << "[";
- for (size_t i = 0; i < this->count; i++)
- std::cout << (*this->buf)[i] << " ";
-
- std::cout << std::endl;
- for (size_t i = 0; i < this->count; i++)
- std::cout << (int)((signed char)(*this->buf)[i]) << " ";
-
- std::cout << "]" << std::endl;
-}
-
-void ByteArrayOutputStream::print()
-{
- _LOGDATA("[");
-
- std::string chars(this->buf->begin(), this->buf->end());
- _LOGDATA("%s ", chars.c_str());
-
- std::string numbers = "";
- for (size_t i = 0; i < this->buf->size(); i++)
- numbers += Utilities::intToStr((int)((signed char)(*this->buf)[i])) + " ";
-
- _LOGDATA("%s", numbers.c_str());
- _LOGDATA("]");
-}
|