Start work on asl::string_view
This commit is contained in:
14
MODULE.bazel.lock
generated
14
MODULE.bazel.lock
generated
@ -64,20 +64,20 @@
|
|||||||
"@@apple_support~//crosstool:setup.bzl%apple_cc_configure_extension": {
|
"@@apple_support~//crosstool:setup.bzl%apple_cc_configure_extension": {
|
||||||
"general": {
|
"general": {
|
||||||
"bzlTransitiveDigest": "PjIds3feoYE8SGbbIq2SFTZy3zmxeO2tQevJZNDo7iY=",
|
"bzlTransitiveDigest": "PjIds3feoYE8SGbbIq2SFTZy3zmxeO2tQevJZNDo7iY=",
|
||||||
"usagesDigest": "+hz7IHWN6A1oVJJWNDB6yZRG+RYhF76wAYItpAeIUIg=",
|
"usagesDigest": "aLmqbvowmHkkBPve05yyDNGN7oh7QE9kBADr3QIZTZs=",
|
||||||
"recordedFileInputs": {},
|
"recordedFileInputs": {},
|
||||||
"recordedDirentsInputs": {},
|
"recordedDirentsInputs": {},
|
||||||
"envVariables": {},
|
"envVariables": {},
|
||||||
"generatedRepoSpecs": {
|
"generatedRepoSpecs": {
|
||||||
"local_config_apple_cc_toolchains": {
|
|
||||||
"bzlFile": "@@apple_support~//crosstool:setup.bzl",
|
|
||||||
"ruleClassName": "_apple_cc_autoconf_toolchains",
|
|
||||||
"attributes": {}
|
|
||||||
},
|
|
||||||
"local_config_apple_cc": {
|
"local_config_apple_cc": {
|
||||||
"bzlFile": "@@apple_support~//crosstool:setup.bzl",
|
"bzlFile": "@@apple_support~//crosstool:setup.bzl",
|
||||||
"ruleClassName": "_apple_cc_autoconf",
|
"ruleClassName": "_apple_cc_autoconf",
|
||||||
"attributes": {}
|
"attributes": {}
|
||||||
|
},
|
||||||
|
"local_config_apple_cc_toolchains": {
|
||||||
|
"bzlFile": "@@apple_support~//crosstool:setup.bzl",
|
||||||
|
"ruleClassName": "_apple_cc_autoconf_toolchains",
|
||||||
|
"attributes": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"recordedRepoMappingEntries": [
|
"recordedRepoMappingEntries": [
|
||||||
@ -92,7 +92,7 @@
|
|||||||
"@@platforms//host:extension.bzl%host_platform": {
|
"@@platforms//host:extension.bzl%host_platform": {
|
||||||
"general": {
|
"general": {
|
||||||
"bzlTransitiveDigest": "xelQcPZH8+tmuOHVjL9vDxMnnQNMlwj0SlvgoqBkm4U=",
|
"bzlTransitiveDigest": "xelQcPZH8+tmuOHVjL9vDxMnnQNMlwj0SlvgoqBkm4U=",
|
||||||
"usagesDigest": "pCYpDQmqMbmiiPI1p2Kd3VLm5T48rRAht5WdW0X2GlA=",
|
"usagesDigest": "meSzxn3DUCcYEhq4HQwExWkWtU4EjriRBQLsZN+Q0SU=",
|
||||||
"recordedFileInputs": {},
|
"recordedFileInputs": {},
|
||||||
"recordedDirentsInputs": {},
|
"recordedDirentsInputs": {},
|
||||||
"envVariables": {},
|
"envVariables": {},
|
||||||
|
@ -15,6 +15,7 @@ cc_library(
|
|||||||
"option.hpp",
|
"option.hpp",
|
||||||
"print.hpp",
|
"print.hpp",
|
||||||
"span.hpp",
|
"span.hpp",
|
||||||
|
"string_view.hpp",
|
||||||
"utility.hpp",
|
"utility.hpp",
|
||||||
],
|
],
|
||||||
srcs = [
|
srcs = [
|
||||||
@ -42,5 +43,6 @@ cc_library(
|
|||||||
"meta",
|
"meta",
|
||||||
"option",
|
"option",
|
||||||
"span",
|
"span",
|
||||||
|
"string_view",
|
||||||
"utility",
|
"utility",
|
||||||
]]
|
]]
|
||||||
|
38
asl/string_view.hpp
Normal file
38
asl/string_view.hpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "asl/integers.hpp"
|
||||||
|
#include "asl/meta.hpp"
|
||||||
|
|
||||||
|
namespace asl
|
||||||
|
{
|
||||||
|
|
||||||
|
class string_view
|
||||||
|
{
|
||||||
|
const char* m_data{};
|
||||||
|
int64_t m_size{};
|
||||||
|
|
||||||
|
public:
|
||||||
|
constexpr string_view() = default;
|
||||||
|
|
||||||
|
constexpr string_view(nullptr_t) : string_view() {} // NOLINT(*-explicit-conversions)
|
||||||
|
|
||||||
|
constexpr string_view(const char* data, int64_t size)
|
||||||
|
: m_data{data}
|
||||||
|
, m_size{size}
|
||||||
|
{}
|
||||||
|
|
||||||
|
constexpr string_view(const char* data) // NOLINT(*-explicit-conversions)
|
||||||
|
: m_data{data}
|
||||||
|
, m_size{static_cast<int64_t>(__builtin_strlen(data))}
|
||||||
|
{}
|
||||||
|
|
||||||
|
constexpr string_view(const string_view&) = default;
|
||||||
|
constexpr string_view(string_view&&) = default;
|
||||||
|
|
||||||
|
constexpr string_view& operator=(const string_view&) = default;
|
||||||
|
constexpr string_view& operator=(string_view&&) = default;
|
||||||
|
|
||||||
|
~string_view() = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace asl
|
3
asl/tests/string_view_tests.cpp
Normal file
3
asl/tests/string_view_tests.cpp
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#include "asl/string_view.hpp"
|
||||||
|
#include "asl/testing/testing.hpp"
|
||||||
|
|
Reference in New Issue
Block a user