mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 09:02:00 +00:00
Class WriteBufferFromOwnString now can return StringRef too.
This commit is contained in:
parent
b7ee466cd7
commit
b1aba679d0
@ -2,6 +2,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <IO/WriteBufferFromVector.h>
|
||||
#include <common/StringRef.h>
|
||||
|
||||
|
||||
namespace DB
|
||||
@ -29,6 +30,8 @@ class WriteBufferFromOwnString : public detail::StringHolder, public WriteBuffer
|
||||
public:
|
||||
WriteBufferFromOwnString() : WriteBufferFromString(value) {}
|
||||
|
||||
StringRef stringRef() const { return isFinished() ? StringRef(value) : StringRef(value.data(), pos - value.data()); }
|
||||
|
||||
std::string & str()
|
||||
{
|
||||
finish();
|
||||
|
@ -64,6 +64,14 @@ public:
|
||||
set(nullptr, 0);
|
||||
}
|
||||
|
||||
bool isFinished() const { return is_finished; }
|
||||
|
||||
void restart()
|
||||
{
|
||||
set(reinterpret_cast<Position>(vector.data()), vector.size());
|
||||
is_finished = false;
|
||||
}
|
||||
|
||||
~WriteBufferFromVector() override
|
||||
{
|
||||
if (!is_finished)
|
||||
|
Loading…
Reference in New Issue
Block a user