[ox/std] Add nodiscard to some string functions

This commit is contained in:
Gary Talent 2024-04-09 22:40:37 -05:00
parent af7c89564c
commit 5eec9085f8

View File

@ -80,6 +80,7 @@ constexpr bool endsWith(CRStringView base, CRStringView ending) noexcept {
return base.len() >= endingLen && ox_strcmp(base.data() + (base.len() - endingLen), ending) == 0; return base.len() >= endingLen && ox_strcmp(base.data() + (base.len() - endingLen), ending) == 0;
} }
[[nodiscard]]
constexpr std::size_t find(CRStringView str, char search) noexcept { constexpr std::size_t find(CRStringView str, char search) noexcept {
std::size_t i = 0; std::size_t i = 0;
for (; i < str.len(); ++i) { for (; i < str.len(); ++i) {
@ -90,6 +91,7 @@ constexpr std::size_t find(CRStringView str, char search) noexcept {
return i; return i;
} }
[[nodiscard]]
constexpr std::size_t find(CRStringView str, CRStringView search) noexcept { constexpr std::size_t find(CRStringView str, CRStringView search) noexcept {
std::size_t i = 0; std::size_t i = 0;
for (; i < str.len(); ++i) { for (; i < str.len(); ++i) {
@ -101,6 +103,7 @@ constexpr std::size_t find(CRStringView str, CRStringView search) noexcept {
} }
template<std::size_t smallSz = 0> template<std::size_t smallSz = 0>
[[nodiscard]]
constexpr ox::Vector<ox::StringView, smallSz> split(CRStringView str, char del) noexcept { constexpr ox::Vector<ox::StringView, smallSz> split(CRStringView str, char del) noexcept {
ox::Vector<ox::StringView, smallSz> out; ox::Vector<ox::StringView, smallSz> out;
constexpr auto nextSeg = [](CRStringView current, char del) { constexpr auto nextSeg = [](CRStringView current, char del) {
@ -117,6 +120,7 @@ constexpr ox::Vector<ox::StringView, smallSz> split(CRStringView str, char del)
} }
template<std::size_t smallSz = 0> template<std::size_t smallSz = 0>
[[nodiscard]]
constexpr ox::Vector<ox::StringView, smallSz> split(CRStringView str, CRStringView del) noexcept { constexpr ox::Vector<ox::StringView, smallSz> split(CRStringView str, CRStringView del) noexcept {
ox::Vector<ox::StringView, smallSz> out; ox::Vector<ox::StringView, smallSz> out;
constexpr auto nextSeg = [](CRStringView current, CRStringView del) { constexpr auto nextSeg = [](CRStringView current, CRStringView del) {