StringView#
-
class StringView#
- Header-file:
#include <datasystem/utils/string_view.h>
- Namespace:
datasystem
字符串视图类,主要用于高效地传递和访问字符串数据,而无需复制或分配内存。
公共函数
-
constexpr StringView() noexcept#
默认构造函数,构造一个空字符串视图实例。
- 返回:
StringView实例。
-
constexpr StringView(const char *str)#
保存字符串指针上的并构造实例,这个过程不会发生拷贝。
- 参数:
str - 需要保存的字符串指针。
- 返回:
StringView实例。
-
constexpr StringView(const char *str, size_t len)#
保存字符串指针上的并构造实例,这个过程不会发生拷贝。
- 参数:
str - 需要保存的字符串指针。
len - 字符串长度。
- 返回:
StringView实例。
-
StringView(const std::string &str)#
保存字符串的指针上与字符串大小并构造实例,这个过程不会发生拷贝。
- 参数:
str - 字符串。
-
~StringView()#
默认析构函数。
-
constexpr const char *data() const noexcept#
获取 StringView 的数据指针。
- 返回:
StringView的数据指针。
-
constexpr size_t size() const noexcept#
获取 StringView 的数据大小。
- 返回:
StringView的数据大小。
-
constexpr size_t empty() const noexcept#
判断 StringView 是否为空。
- 返回:
true表示StringView为空。