2011-11-29 18:53:44 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <IO/ReadBufferFromMemory.h>
|
2011-11-29 18:53:44 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2021-08-24 12:57:49 +00:00
|
|
|
/// Allows to read from std::string-like object.
|
2017-01-03 01:42:17 +00:00
|
|
|
class ReadBufferFromString : public ReadBufferFromMemory
|
2011-11-29 18:53:44 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-04-16 05:40:17 +00:00
|
|
|
/// std::string or something similar
|
2011-11-29 18:53:44 +00:00
|
|
|
template <typename S>
|
2021-04-16 17:49:38 +00:00
|
|
|
explicit ReadBufferFromString(const S & s) : ReadBufferFromMemory(s.data(), s.size()) {}
|
2011-11-29 18:53:44 +00:00
|
|
|
|
2021-08-24 12:57:49 +00:00
|
|
|
explicit ReadBufferFromString(std::string_view s) : ReadBufferFromMemory(s.data(), s.size()) {}
|
|
|
|
};
|
2022-01-05 11:51:50 +00:00
|
|
|
|
|
|
|
class ReadBufferFromOwnString : public String, public ReadBufferFromString
|
|
|
|
{
|
|
|
|
public:
|
2023-08-15 04:16:22 +00:00
|
|
|
template <typename S>
|
|
|
|
explicit ReadBufferFromOwnString(S && s_) : String(std::forward<S>(s_)), ReadBufferFromString(*this)
|
|
|
|
{
|
|
|
|
}
|
2022-01-05 11:51:50 +00:00
|
|
|
};
|
|
|
|
|
2011-11-29 18:53:44 +00:00
|
|
|
}
|