sgns::base::Blob¶
#include <blob.hpp>
Inherits from std::array< uint8_t, size_ >
Public Functions¶
| Name | |
|---|---|
| Blob() | |
| constexpr | Blob(const std::array< uint8_t, size_ > & l) constructor enabling initializer list |
| std::string | toString() const |
| std::string | toReadableString() const |
| std::string | toHex() const |
| std::vector< uint8_t > | ToVec() const |
| size_t | size() |
| outcome::result< Blob< size_ > > | fromString(std::string_view data) |
| outcome::result< Blob< size_ > > | fromReadableString(std::string_view data) |
| outcome::result< Blob< size_ > > | fromHex(std::string_view hex) |
| outcome::result< Blob< size_ > > | fromHexWithPrefix(std::string_view hex) |
| outcome::result< Blob< size_ > > | fromSpan(gsl::span< uint8_t > span) |
Detailed Description¶
Base type which represents blob of fixed size.
std::string is convenient to use but it is not safe. We can not specify the fixed length for string.
For std::array it is possible, so we prefer it over std::string.
Public Functions Documentation¶
function Blob¶
Initialize blob value
function Blob¶
constructor enabling initializer list
Parameters:
- l initializer list
function toString¶
Converts current blob to std::string
function toReadableString¶
Converts current blob to a readable std::string
function toHex¶
Converts current blob to hex string.
function ToVec¶
function size¶
In compile-time returns size of current blob.
function fromString¶
Parameters:
- data arbitrary string containing
Return: result containing Blob object if string has proper size
Create Blob from arbitrary string, putting its bytes into the blob
function fromReadableString¶
function fromHex¶
Parameters:
- hex hex string
Return: result containing Blob object if hex string has proper size and is in hex format
Create Blob from hex string
function fromHexWithPrefix¶
Parameters:
- hex hex string
Return: result containing Blob object if hex string has proper size and is in hex format
Create Blob from hex string prefixed with 0x
function fromSpan¶
Parameters:
- span input byte span
Return: result containing Blob object if span has proper size
Create Blob from span of uint8_t
Updated on 2026-03-04 at 13:10:43 -0800