1 #ifndef _C4_STD_STRING_HPP_
2 #define _C4_STD_STRING_HPP_
6 #ifndef C4CORE_SINGLE_HEADER
21 C4_ALWAYS_INLINE c4::substr
to_substr(std::string &s) noexcept
24 #error this function will have undefined behavior
27 return c4::substr(&s[0], s.size());
35 C4_ALWAYS_INLINE c4::csubstr
to_csubstr(std::string
const& s) noexcept
38 #error this function will have undefined behavior
41 return c4::csubstr(&s[0], s.size());
46 C4_ALWAYS_INLINE
bool operator== (c4::csubstr ss, std::string
const& s) {
return ss.compare(
to_csubstr(s)) == 0; }
47 C4_ALWAYS_INLINE
bool operator!= (c4::csubstr ss, std::string
const& s) {
return ss.compare(
to_csubstr(s)) != 0; }
48 C4_ALWAYS_INLINE
bool operator>= (c4::csubstr ss, std::string
const& s) {
return ss.compare(
to_csubstr(s)) >= 0; }
49 C4_ALWAYS_INLINE
bool operator> (c4::csubstr ss, std::string
const& s) {
return ss.compare(
to_csubstr(s)) > 0; }
50 C4_ALWAYS_INLINE
bool operator<= (c4::csubstr ss, std::string
const& s) {
return ss.compare(
to_csubstr(s)) <= 0; }
51 C4_ALWAYS_INLINE
bool operator< (c4::csubstr ss, std::string
const& s) {
return ss.compare(
to_csubstr(s)) < 0; }
53 C4_ALWAYS_INLINE
bool operator== (std::string
const& s, c4::csubstr ss) {
return ss.compare(
to_csubstr(s)) == 0; }
54 C4_ALWAYS_INLINE
bool operator!= (std::string
const& s, c4::csubstr ss) {
return ss.compare(
to_csubstr(s)) != 0; }
55 C4_ALWAYS_INLINE
bool operator>= (std::string
const& s, c4::csubstr ss) {
return ss.compare(
to_csubstr(s)) <= 0; }
56 C4_ALWAYS_INLINE
bool operator> (std::string
const& s, c4::csubstr ss) {
return ss.compare(
to_csubstr(s)) < 0; }
57 C4_ALWAYS_INLINE
bool operator<= (std::string
const& s, c4::csubstr ss) {
return ss.compare(
to_csubstr(s)) >= 0; }
58 C4_ALWAYS_INLINE
bool operator< (std::string
const& s, c4::csubstr ss) {
return ss.compare(
to_csubstr(s)) > 0; }
63 inline size_t to_chars(c4::substr buf, std::string
const& s)
66 size_t len = buf.len < s.size() ? buf.len : s.size();
72 C4_ASSERT(s.data() !=
nullptr);
73 C4_ASSERT(buf.str !=
nullptr);
74 memcpy(buf.str, s.data(), len);
89 C4_ASSERT(buf.str !=
nullptr);
90 memcpy(&(*s)[0], buf.str, buf.len);
bool from_chars(csubstr buf, uint8_t *v) noexcept
csubstr to_csubstr(substr s) noexcept
neutral version for use in generic code
substr to_substr(substr s) noexcept
neutral version for use in generic code
bool operator!=(const char(&s)[N], basic_substring< C > const that) noexcept
bool operator>(const char(&s)[N], basic_substring< C > const that) noexcept
bool operator>=(const char(&s)[N], basic_substring< C > const that) noexcept
bool operator<=(const char(&s)[N], basic_substring< C > const that) noexcept
bool operator==(const char(&s)[N], basic_substring< C > const that) noexcept
bool operator<(const char(&s)[N], basic_substring< C > const that) noexcept
size_t to_chars(substr buf, uint8_t v) noexcept