BufferOutputStream: Add reset() method.

This commit is contained in:
lganzzzo 2021-11-16 04:58:50 +02:00
parent c0581f54da
commit 3b66aa7670
3 changed files with 14 additions and 0 deletions

1
.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1 @@
github: oatpp

View File

@ -118,6 +118,13 @@ void BufferOutputStream::setCurrentPosition(v_buff_size position) {
m_position = position;
}
void BufferOutputStream::reset(v_buff_size initialCapacity) {
delete [] m_data;
m_data = new v_char8[initialCapacity];
m_capacity = initialCapacity;
m_position = 0;
}
oatpp::String BufferOutputStream::toString() {
return oatpp::String((const char*) m_data, m_position);
}

View File

@ -115,6 +115,12 @@ public:
*/
void setCurrentPosition(v_buff_size position);
/**
* Reset stream buffer and its capacity. Also reset write position.
* @param initialCapacity
*/
void reset(v_buff_size initialCapacity = 2048);
/**
* Copy data to &id:oatpp::String;.
* @return