Skip to content

Commit 809df1c

Browse files
committed
Add suuport Arduino StringSumHelper class for Arduino String concatenation used in function arguments and config.
1 parent e4b08c3 commit 809df1c

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/json/MB_String.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
* v1.2.8
1010
* - Add support StringSumHelper class in Arduino
11-
*
11+
*
1212
* v1.2.7
1313
* - Fix string sub type checking issue
1414
*
@@ -458,7 +458,12 @@ namespace mb_string
458458
template <typename T>
459459
auto toStringPtr(const T &val) -> typename MB_ENABLE_IF<MB_IS_SAME<T, StringSumHelper>::value, MB_StringPtr>::type
460460
{
461+
#if defined(ESP8266)
462+
return MB_StringPtr(reinterpret_cast<uint32_t>(&val), getSubType(val), -1);
463+
464+
#else
461465
return MB_StringPtr(reinterpret_cast<uint32_t>(&val), getSubType(val), -1, &val);
466+
#endif
462467
}
463468

464469
template <typename T>
@@ -519,16 +524,23 @@ class MB_String
519524
*this = str;
520525
}
521526

527+
#if !defined(ESP8266)
522528
MB_String(StringSumHelper rval)
523529
{
524530
*this = rval;
525531
}
532+
#endif
526533

527534
MB_String(MB_StringPtr value)
528535
{
529536
*this = value;
530537
}
531538

539+
MB_String(String value)
540+
{
541+
*this = value;
542+
}
543+
532544
MB_String(bool value)
533545
{
534546
appendNum(value);
@@ -662,6 +674,7 @@ class MB_String
662674
return *this;
663675
}
664676

677+
#if !defined(ESP8266)
665678
MB_String &operator=(StringSumHelper rval)
666679
{
667680
String temp = rval;
@@ -675,6 +688,7 @@ class MB_String
675688
*this += temp;
676689
return *this;
677690
}
691+
#endif
678692

679693
MB_String &operator+=(const __FlashStringHelper *str)
680694
{
@@ -837,7 +851,11 @@ class MB_String
837851
else if (src.type() == mb_string_sub_type_arduino_string)
838852
*this += *addrTo<String *>(src.address());
839853
else if (src.type() == mb_string_sub_type_string_sum_helper)
854+
#if !defined(ESP8266)
840855
*this += *src.stringsumhelper();
856+
#else
857+
*this += *addrTo<String *>(src.address());
858+
#endif
841859
#if !defined(__AVR__)
842860
else if (src.type() == mb_string_sub_type_std_string)
843861
*this += *addrTo<std::string *>(src.address());

0 commit comments

Comments
 (0)