Support converting util::blob to util::span explicitly
This commit is contained in:
parent
b9ed814cfe
commit
2ea0427b0f
1 changed files with 16 additions and 0 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <psemek/util/span.hpp>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
@ -49,6 +51,9 @@ namespace psemek::util
|
||||||
std::string string() const;
|
std::string string() const;
|
||||||
std::string_view string_view() const;
|
std::string_view string_view() const;
|
||||||
|
|
||||||
|
util::span<char> span();
|
||||||
|
util::span<char const> span() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<char[]> data_;
|
std::unique_ptr<char[]> data_;
|
||||||
std::size_t size_ = 0;
|
std::size_t size_ = 0;
|
||||||
|
|
@ -125,4 +130,15 @@ namespace psemek::util
|
||||||
{
|
{
|
||||||
return std::string_view(data_.get(), size_);
|
return std::string_view(data_.get(), size_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline util::span<char> blob::span()
|
||||||
|
{
|
||||||
|
return {data_.get(), size_};
|
||||||
|
}
|
||||||
|
|
||||||
|
inline util::span<char const> blob::span() const
|
||||||
|
{
|
||||||
|
return {data_.get(), size_};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue