-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
490ed28
commit 52bc382
Showing
44 changed files
with
501 additions
and
5,655 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,46 @@ | ||
#include "response_buffer.h" | ||
|
||
template<uint32_t BUFFER_SIZE> | ||
ResponseBuffer<BUFFER_SIZE>::ResponseBuffer() : bytes_used(0), bytes{0} { | ||
ResponseBuffer::ResponseBuffer() : index(0), size(0), bytes{nullptr} { | ||
} | ||
|
||
template<uint32_t BUFFER_SIZE> | ||
uint8_t *ResponseBuffer<BUFFER_SIZE>::get_raw_buffer() { | ||
return bytes[0]; | ||
uint8_t *ResponseBuffer::get_raw_buffer() { | ||
return bytes; | ||
} | ||
|
||
template<uint32_t BUFFER_SIZE> | ||
void ResponseBuffer<BUFFER_SIZE>::clear() { | ||
bytes_used = 0; | ||
void ResponseBuffer::clear() { | ||
index = 0; | ||
} | ||
|
||
template<uint32_t BUFFER_SIZE> | ||
uint32_t ResponseBuffer<BUFFER_SIZE>::get_size() const { | ||
return bytes_used; | ||
uint32_t ResponseBuffer::get_size() const { | ||
return index; | ||
} | ||
|
||
template<uint32_t BUFFER_SIZE> | ||
uint32_t ResponseBuffer<BUFFER_SIZE>::get_max_size() const { | ||
return BUFFER_SIZE; | ||
uint32_t ResponseBuffer::get_max_size() const { | ||
return size; | ||
} | ||
|
||
template<uint32_t BUFFER_SIZE> | ||
uint32_t ResponseBuffer<BUFFER_SIZE>::get_available_size() const { | ||
return -bytes_used; | ||
void ResponseBuffer::set_max_size(uint32_t value) { | ||
this->size = value; | ||
} | ||
|
||
template<uint32_t BUFFER_SIZE> | ||
bool ResponseBuffer<BUFFER_SIZE>::push(const uint8_t byte) { | ||
bool result = BUFFER_SIZE > bytes_used; | ||
uint32_t ResponseBuffer::get_available_size() const { | ||
return -index; | ||
} | ||
|
||
bool ResponseBuffer::push(const uint8_t byte) { | ||
bool result = size > index; | ||
if (result) { | ||
(*bytes[bytes_used]) = byte; | ||
++bytes_used; | ||
bytes[index] = byte; | ||
++index; | ||
} | ||
return result; | ||
} | ||
|
||
template<uint32_t BUFFER_SIZE> | ||
bool ResponseBuffer<BUFFER_SIZE>::push(const uint8_t *src, const uint32_t length) { | ||
bool result = BUFFER_SIZE >= (bytes_used + length); | ||
bool ResponseBuffer::push(const uint8_t *src, const uint32_t length) { | ||
bool result = size >= (index + length); | ||
if (result) { | ||
memcpy(bytes + bytes_used, src, length); | ||
bytes_used += length; | ||
memcpy(bytes + index, src, length); | ||
index += length; | ||
} | ||
return result; | ||
} | ||
|
||
template class ResponseBuffer<DEFAULT_RESPONSE_BUFFER_SIZE>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.