add Buffer::clear() and Buffer::set_string()
This commit is contained in:
parent
22b2cd426e
commit
47d15ca858
@ -119,7 +119,9 @@ public:
|
|||||||
m_cursors.push_back(iterator);
|
m_cursors.push_back(iterator);
|
||||||
return iterator;
|
return iterator;
|
||||||
}
|
}
|
||||||
|
void clear() { m_gap_buffer->clear(); }
|
||||||
auto get_string() { return m_gap_buffer->get_string(); }
|
auto get_string() { return m_gap_buffer->get_string(); }
|
||||||
|
void set_string(const std::string & s) { m_gap_buffer->set_string(s); }
|
||||||
size_t size() const { return m_gap_buffer->size(); }
|
size_t size() const { return m_gap_buffer->size(); }
|
||||||
uint8_t * address(size_t offset) const { return m_gap_buffer->address(offset); }
|
uint8_t * address(size_t offset) const { return m_gap_buffer->address(offset); }
|
||||||
Encoding::Type encoding() const { return m_encoding; }
|
Encoding::Type encoding() const { return m_encoding; }
|
||||||
|
@ -62,7 +62,7 @@ std::string GapBuffer::get_string()
|
|||||||
return std::string((char *)m_buffer, m_size);
|
return std::string((char *)m_buffer, m_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GapBuffer::set_string(std::string s)
|
void GapBuffer::set_string(const std::string & s)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
insert(0u, (const uint8_t *)s.c_str(), s.size());
|
insert(0u, (const uint8_t *)s.c_str(), s.size());
|
||||||
|
@ -72,7 +72,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Replace the buffer contents with a string.
|
* Replace the buffer contents with a string.
|
||||||
*/
|
*/
|
||||||
void set_string(std::string s);
|
void set_string(const std::string & s);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the size of the data stored within the buffer.
|
* Get the size of the data stored within the buffer.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user