|
|
@@ -112,10 +112,9 @@ public:
|
|
|
|
MString& set(const char *s) { return set(const_cast<char*>(s)); }
|
|
|
|
MString& set(const char *s) { return set(const_cast<char*>(s)); }
|
|
|
|
MString& set_P(PGM_P const s) { strncpy_P(str, s, SIZE); debug(F("pstring")); return *this; }
|
|
|
|
MString& set_P(PGM_P const s) { strncpy_P(str, s, SIZE); debug(F("pstring")); return *this; }
|
|
|
|
MString& set(FSTR_P const f) { return set_P(FTOP(f)); }
|
|
|
|
MString& set(FSTR_P const f) { return set_P(FTOP(f)); }
|
|
|
|
MString& set(const MString &s) { strncpy(str, s.str, SIZE); debug(F("MString")); return *this; }
|
|
|
|
|
|
|
|
MString& set(const bool &b) { return set(b ? F("true") : F("false")); }
|
|
|
|
MString& set(const bool &b) { return set(b ? F("true") : F("false")); }
|
|
|
|
MString& set(const char c) { str[0] = c; if (1 < SIZE) str[1] = '\0'; debug(F("char")); return *this; }
|
|
|
|
MString& set(const char c) { str[0] = c; if (1 < SIZE) str[1] = '\0'; debug(F("char")); return *this; }
|
|
|
|
MString& set(const int8_t &i) { SNPRINTF_P(str, SIZE, PSTR("%d"), i); debug(F("int8_t")); return *this; }
|
|
|
|
MString& set(const int8_t &i) { SNPRINTF_P(str, SIZE, PSTR("%d"), i); debug(F("int8_t")); return *this; }
|
|
|
|
MString& set(const short &i) { SNPRINTF_P(str, SIZE, PSTR("%d"), i); debug(F("short")); return *this; }
|
|
|
|
MString& set(const short &i) { SNPRINTF_P(str, SIZE, PSTR("%d"), i); debug(F("short")); return *this; }
|
|
|
|
MString& set(const int &i) { SNPRINTF_P(str, SIZE, PSTR("%d"), i); debug(F("int")); return *this; }
|
|
|
|
MString& set(const int &i) { SNPRINTF_P(str, SIZE, PSTR("%d"), i); debug(F("int")); return *this; }
|
|
|
|
MString& set(const long &l) { SNPRINTF_P(str, SIZE, PSTR("%ld"), l); debug(F("long")); return *this; }
|
|
|
|
MString& set(const long &l) { SNPRINTF_P(str, SIZE, PSTR("%ld"), l); debug(F("long")); return *this; }
|
|
|
@@ -130,6 +129,9 @@ public:
|
|
|
|
MString& set(const xyz_pos_t &v) { set(); return append(v); }
|
|
|
|
MString& set(const xyz_pos_t &v) { set(); return append(v); }
|
|
|
|
MString& set(const xyze_pos_t &v) { set(); return append(v); }
|
|
|
|
MString& set(const xyze_pos_t &v) { set(); return append(v); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <int S>
|
|
|
|
|
|
|
|
MString& set(const MString<S> &m) { strncpy(str, &m, SIZE); debug(F("MString")); return *this; }
|
|
|
|
|
|
|
|
|
|
|
|
MString& setn(char *s, int len) { int c = _MIN(len, SIZE); strncpy(str, s, c); str[c] = '\0'; debug(F("string")); return *this; }
|
|
|
|
MString& setn(char *s, int len) { int c = _MIN(len, SIZE); strncpy(str, s, c); str[c] = '\0'; debug(F("string")); return *this; }
|
|
|
|
MString& setn(const char *s, int len) { return setn(const_cast<char*>(s), len); }
|
|
|
|
MString& setn(const char *s, int len) { return setn(const_cast<char*>(s), len); }
|
|
|
|
MString& setn_P(PGM_P const s, int len) { int c = _MIN(len, SIZE); strncpy_P(str, s, c); str[c] = '\0'; debug(F("pstring")); return *this; }
|
|
|
|
MString& setn_P(PGM_P const s, int len) { int c = _MIN(len, SIZE); strncpy_P(str, s, c); str[c] = '\0'; debug(F("pstring")); return *this; }
|
|
|
@@ -157,7 +159,6 @@ public:
|
|
|
|
MString& append(const char *s) { return append(const_cast<char *>(s)); }
|
|
|
|
MString& append(const char *s) { return append(const_cast<char *>(s)); }
|
|
|
|
MString& append_P(PGM_P const s) { int sz = length(); if (sz < SIZE) strncpy_P(str + sz, s, SIZE - sz); debug(F("pstring")); return *this; }
|
|
|
|
MString& append_P(PGM_P const s) { int sz = length(); if (sz < SIZE) strncpy_P(str + sz, s, SIZE - sz); debug(F("pstring")); return *this; }
|
|
|
|
MString& append(FSTR_P const f) { return append_P(FTOP(f)); }
|
|
|
|
MString& append(FSTR_P const f) { return append_P(FTOP(f)); }
|
|
|
|
MString& append(const MString &s) { return append(s.str); }
|
|
|
|
|
|
|
|
MString& append(const bool &b) { return append(b ? F("true") : F("false")); }
|
|
|
|
MString& append(const bool &b) { return append(b ? F("true") : F("false")); }
|
|
|
|
MString& append(const char c) { int sz = length(); if (sz < SIZE) { str[sz] = c; if (sz < SIZE - 1) str[sz + 1] = '\0'; } return *this; }
|
|
|
|
MString& append(const char c) { int sz = length(); if (sz < SIZE) { str[sz] = c; if (sz < SIZE - 1) str[sz + 1] = '\0'; } return *this; }
|
|
|
|
#if ENABLED(FASTER_APPEND)
|
|
|
|
#if ENABLED(FASTER_APPEND)
|
|
|
@@ -186,6 +187,9 @@ public:
|
|
|
|
MString& append(const xyz_pos_t &v) { LOOP_NUM_AXES(i) { if (i) append(' '); append(AXIS_CHAR(i), v[i]); } debug(F("xyz")); return *this; }
|
|
|
|
MString& append(const xyz_pos_t &v) { LOOP_NUM_AXES(i) { if (i) append(' '); append(AXIS_CHAR(i), v[i]); } debug(F("xyz")); return *this; }
|
|
|
|
MString& append(const xyze_pos_t &v) { LOOP_LOGICAL_AXES(i) { if (i) append(' '); append(AXIS_CHAR(i), v[i]); } debug(F("xyze")); return *this; }
|
|
|
|
MString& append(const xyze_pos_t &v) { LOOP_LOGICAL_AXES(i) { if (i) append(' '); append(AXIS_CHAR(i), v[i]); } debug(F("xyze")); return *this; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<int S>
|
|
|
|
|
|
|
|
MString& append(const MString<S> &m) { return append(&m); }
|
|
|
|
|
|
|
|
|
|
|
|
// Append only if the given space is available
|
|
|
|
// Append only if the given space is available
|
|
|
|
MString& appendn(char *s, int len) { int sz = length(), c = _MIN(len, SIZE - sz); if (c > 0) { strncpy(str + sz, s, c); str[sz + c] = '\0'; } debug(F("string")); return *this; }
|
|
|
|
MString& appendn(char *s, int len) { int sz = length(), c = _MIN(len, SIZE - sz); if (c > 0) { strncpy(str + sz, s, c); str[sz + c] = '\0'; } debug(F("string")); return *this; }
|
|
|
|
MString& appendn(const char *s, int len) { return appendn(const_cast<char *>(s), len); }
|
|
|
|
MString& appendn(const char *s, int len) { return appendn(const_cast<char *>(s), len); }
|
|
|
@@ -227,7 +231,7 @@ public:
|
|
|
|
MString(T arg1, Args... more) { set(arg1); append(more...); }
|
|
|
|
MString(T arg1, Args... more) { set(arg1); append(more...); }
|
|
|
|
|
|
|
|
|
|
|
|
// Catch unhandled types to prevent infinite recursion
|
|
|
|
// Catch unhandled types to prevent infinite recursion
|
|
|
|
template<typename T> MString& append(T) { return append('?'); }
|
|
|
|
template<typename T> MString& append(T) { return append(TERN(MSTRING_DEBUG, typeid(T).name(), '?')); }
|
|
|
|
|
|
|
|
|
|
|
|
// Take a list of any number of arguments and append them to the string
|
|
|
|
// Take a list of any number of arguments and append them to the string
|
|
|
|
template<typename T, typename... Args>
|
|
|
|
template<typename T, typename... Args>
|
|
|
@@ -313,4 +317,5 @@ public:
|
|
|
|
#ifndef TS_SIZE
|
|
|
|
#ifndef TS_SIZE
|
|
|
|
#define TS_SIZE 63
|
|
|
|
#define TS_SIZE 63
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#define TS(V...) MString<TS_SIZE>(V)
|
|
|
|
typedef MString<TS_SIZE, DISABLED(UNSAFE_MSTRING)> TString;
|
|
|
|
|
|
|
|
#define TS(V...) TString(V)
|
|
|
|