24#ifndef FASTLED_STR_INLINED_SIZE
25#define FASTLED_STR_INLINED_SIZE 64
44template <
typename T>
struct rect;
45template <
typename T>
struct vec2;
46template <
typename T>
struct vec3;
47template <
typename T>
class Slice;
48template <
typename T,
typename Allocator>
class HeapVector;
51template <fl::size N>
class StrN;
53template <
typename T>
class WeakPtr;
54template <
typename T>
class Ptr;
56template <
typename T>
struct Hash;
58template <
typename T>
struct EqualTo;
60template <
typename Key,
typename Hash,
typename KeyEqual>
class HashSet;
96 return c ==
' ' || c ==
'\t' || c ==
'\n' || c ==
'\r';
98 static float parseFloat(
const char *str, fl::size len);
99 static int parseInt(
const char *str, fl::size len);
100 static int parseInt(
const char *str);
101 static bool isDigit(
char c) {
return c >=
'0' && c <=
'9'; }
116 void grow(fl::size newLength);
122 bool copy(
const char *str, fl::size len) {
126 memcpy(
mData, str, len);
138template <fl::size SIZE = FASTLED_STR_INLINED_SIZE>
class StrN {
146 static constexpr fl::size
npos =
static_cast<fl::size
>(-1);
154 fl::size len = strlen(str);
156 if (len + 1 <= SIZE) {
165 fl::size len = strlen(str);
167 if (len + 1 <= SIZE) {
181 template <
int N>
StrN(
const char (&str)[N]) {
198 void assign(
const char* str, fl::size len) {
200 if (len + 1 <= SIZE) {
218 void copy(
const char *str, fl::size len) {
220 if (len + 1 <= SIZE) {
230 fl::size len = other.
size();
231 if (len + 1 <= SIZE) {
248 return write(str, n);
251 fl::size
write(
const char *str, fl::size n) {
255 fl::size grow_length =
MAX(3, newLen * 3 / 2);
263 if (newLen + 1 <= SIZE) {
273 memcpy(newData->data() +
mLength, str, n);
274 newData->data()[newLen] =
'\0';
286 return write(str, 1);
301 fl::size
write(
const uint64_t &val) {
336 static char dummy =
'\0';
344 static char dummy =
'\0';
347 return c_str()[index];
377 if (newCapacity + 1 <= SIZE) {
393 newData->data()[
mLength] =
'\0';
398 void clear(
bool freeMemory =
false) {
408 fl::size
find(
const char &value)
const {
409 for (fl::size i = 0; i <
mLength; ++i) {
410 if (
c_str()[i] == value) {
425 return found -
begin;
437 fl::size
find(
const char &value, fl::size start_pos)
const {
441 for (fl::size i = start_pos; i <
mLength; ++i) {
442 if (
c_str()[i] == value) {
450 fl::size
find(
const char*
substr, fl::size start_pos)
const {
457 return found -
c_str();
487 fl::size prefix_len = strlen(prefix);
491 return strncmp(
c_str(), prefix, prefix_len) == 0;
508 fl::size suffix_len = strlen(suffix);
512 return strncmp(
c_str() +
mLength - suffix_len, suffix, suffix_len) == 0;
597 static const fl::size
npos =
static_cast<fl::size
>(-1);
599 static int strcmp(
const string& a,
const string& b);
602 string(
const char *str) :
StrN<FASTLED_STR_INLINED_SIZE>(str) {}
603 string(
const char *str, fl::size len) :
StrN<FASTLED_STR_INLINED_SIZE>() {
606 string(fl::size len,
char c) :
StrN<FASTLED_STR_INLINED_SIZE>() {
609 string(
const string &other) :
StrN<FASTLED_STR_INLINED_SIZE>(other) {}
610 template <fl::size M>
618 copy(str, strlen(str));
623 string(
const std::string &str) {
624 copy(str.c_str(), str.size());
626 string &
operator=(
const std::string &str) {
627 copy(str.c_str(), str.size());
631 string &
append(
const std::string &str) {
632 write(str.c_str(), str.size());
713 template <typename T, typename = fl::enable_if_t<fl::is_integral<T>::value>>
721 for (fl::size i = 0; i < slice.
size(); ++i) {
737 template <
typename T, fl::size N>
745 write(str, strlen(str));
748 string &
append(
const char *str, fl::size len) {
763 write(
static_cast<u32
>(c));
836 append(
"shared_ptr(null)");
846 string &
append(
const JsonUiInternal& val);
852 template <
typename T, fl::size N>
867 string &
append(
const float &_val,
int precision) {
885 template <
typename Key,
typename Hash,
typename KeyEqual>
900 template <
typename T>
912 void swap(
string &other);
926 fl::size additional_chars = count -
mLength;
929 for (fl::size i = 0; i < additional_chars; ++i) {
966 result.append(value, precision);
974inline string operator+(
const char* lhs,
const string& rhs) {
981inline string operator+(
const string& lhs,
const char* rhs) {
988inline string operator+(
const string& lhs,
const string& rhs) {
constexpr fl::size size() const
StrN & operator=(const StrN &other)
StrN & operator=(const StrN< M > &other)
fl::size find(const StrN< M > &other, fl::size start_pos) const
bool ends_with(const StrN< M > &suffix) const
void copy(const StrN< M > &other)
bool operator<(const StrN &other) const
fl::size write(const uint64_t &val)
fl::size find(const StrN< M > &other) const
static constexpr fl::size npos
StrN & operator=(const char(&str)[N])
StrN substr(fl::size start, fl::size length) const
void reserve(fl::size newCapacity)
bool starts_with(char c) const
fl::size find(const char &value) const
bool ends_with(const char *suffix) const
bool contains(const StrN< M > &other) const
fl::size write(const char *str, fl::size n)
fl::size find(const char *substr) const
bool starts_with(const StrN< M > &prefix) const
void copy(const char *str, fl::size len)
bool operator!=(const StrN &other) const
const char * c_str() const
void clear(bool freeMemory=false)
bool starts_with(const char *prefix) const
fl::size write(const i32 &val)
bool contains(const char *substr) const
fl::size find(const char &value, fl::size start_pos) const
fl::size capacity() const
StringHolderPtr mHeapData
fl::size write(const u16 &n)
fl::size write(const u32 &val)
bool ends_with(char c) const
StrN substring(fl::size start, fl::size end) const
char & operator[](fl::size index)
StrN(const char(&str)[N])
fl::size write(const u8 *data, fl::size n)
void assign(const char *str, fl::size len)
StrN(const StrN< M > &other)
fl::size find(const char *substr, fl::size start_pos) const
fl::size write(const i8 val)
void copy(const char *str)
char operator[](fl::size index) const
bool operator==(const StrN &other) const
bool contains(char c) const
const char * begin() const
const char * cbegin() const
StrN substr(fl::size start) const
const char * cend() const
bool operator<(const StrN< M > &other) const
fl::size capacity() const
bool hasCapacity(fl::size newLength) const
StringHolder(const StringHolder &other)=delete
StringHolder(const char *str)
void grow(fl::size newLength)
const char * data() const
bool copy(const char *str, fl::size len)
StringHolder & operator=(const StringHolder &other)=delete
FL_DISABLE_WARNING_POP void to_string(string *dst) const
A dynamic bitset implementation that can be resized at runtime.
Result type for promise operations.
const_iterator begin() const
const_iterator end() const
string & append(long long val)
string(const char *str, fl::size len)
string & append(const i8 &c)
string & append(const bitset_dynamic &bs)
string & append(const char *str)
string & append(const HashSet< Key, Hash, KeyEqual > &set)
bool operator==(const string &other) const
string & append(const fl::span< T > &slice)
string & append(const u16 &val)
bool operator>(const string &other) const
string & append(const fl::InlinedVector< T, N > &vec)
string & operator=(const char *str)
string & append(const vec2< T > &pt)
string & operator=(const string &other)
string & append(const u8 &c)
string & append(const i32 &c)
string & append(const double &val)
string & append(const float &_val, int precision)
bool operator>=(const string &other) const
string & append(const BitsetFixed< N > &bs)
bool operator<=(const string &other) const
string & append(const fl::optional< T > &opt)
string & append(const fl::shared_ptr< T > &val)
string & append(const char *str, fl::size len)
void resize(fl::size count, char ch)
string & append(const vec3< T > &pt)
string(const string &other)
string(const StrN< M > &other)
bool operator!=(const string &other) const
string & append(const bool &val)
string & append(const uint64_t &val)
string & append(const WeakPtr< T > &val)
static void compileTimeAssertions()
string & operator+=(const T &val)
string & append(const BitsetInlined< N > &bs)
string & append(const fl::HeapVector< T > &vec)
bool operator<(const string &other) const
static int strcmp(const string &a, const string &b)
string(fl::size len, char c)
static const fl::size npos
string & append(const rect< T > &rect)
string & append(const fl::FixedVector< T, N > &vec)
string & operator+=(const string &other)
string & append(const float &_val)
string & append(const u32 &val)
const char * data() const
void resize(fl::size count)
string & append(const StrN &str)
string & append(const i16 &val)
string & append(const T &val)
#define FASTLED_NAMESPACE_END
#define FASTLED_NAMESPACE_BEGIN
Implements the FastLED namespace macros.
To * bit_cast_ptr(void *storage) noexcept
void * memcopy(void *dst, const void *src, fl::size num)
string to_string(T value)
shared_ptr< T > make_shared(Args &&... args)
string operator+(const char *lhs, const string &rhs)
#define FASTLED_SMART_PTR(type)
Representation of an RGB pixel (Red, Green, Blue)