FastLED 3.10.10
Loading...
Searching...
No Matches

◆ compare() [5/6]

int fl::basic_string::compare ( fl::size pos1,
fl::size count1,
const char * s ) const

Definition at line 1206 of file basic_string.cpp.hpp.

1206 {
1207 if (!s) {
1208 if (pos1 >= mLength) return 0;
1209 fl::size actualCount1 = count1;
1210 if (actualCount1 == npos || pos1 + actualCount1 > mLength) {
1211 actualCount1 = mLength - pos1;
1212 }
1213 return (actualCount1 > 0) ? 1 : 0;
1214 }
1215 if (pos1 > mLength) return (s[0] == '\0') ? 0 : -1;
1216 fl::size actualCount1 = count1;
1217 if (actualCount1 == npos || pos1 + actualCount1 > mLength) {
1218 actualCount1 = mLength - pos1;
1219 }
1220 fl::size sLen = fl::strlen(s);
1221 fl::size minLen = (actualCount1 < sLen) ? actualCount1 : sLen;
1222 int result = fl::strncmp(c_str() + pos1, s, minLen);
1223 if (result != 0) return result;
1224 if (actualCount1 < sLen) return -1;
1225 if (actualCount1 > sLen) return 1;
1226 return 0;
1227}
static constexpr fl::size npos
const char * c_str() const FL_NO_EXCEPT
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31
FASTLED_FORCE_INLINE int strncmp(const char *s1, const char *s2, size_t n) FL_NO_EXCEPT
Definition cstring.h:64
FASTLED_FORCE_INLINE size_t strlen(const char *s) FL_NO_EXCEPT
Definition cstring.h:56

References c_str(), fl::FL_NO_EXCEPT, mLength, npos, fl::strlen(), and fl::strncmp().

+ Here is the call graph for this function: