2626#include < stdlib.h>
2727#include < string.h>
2828#include < ctype.h>
29- #define PROGMEM
29+ #include < pgmspace.h >
3030
3131// An inherited class for holding the result of a concatenation. These
3232// result objects are assumed to be writable by subsequent concatenations.
3333class StringSumHelper ;
3434
35- typedef char * __FlashStringHelper;
36- // #define F(str) []() -> const char * { static const char tmp[] ICACHE_RODATA_ATTR = str; return &tmp[0]; }()
37- #define F (str ) str
35+ // an abstract class used as a means to proide a unique pointer type
36+ // but really has no body
37+ class __FlashStringHelper ;
38+ #define F (string_literal ) (reinterpret_cast <const __FlashStringHelper *>(PSTR(string_literal)))
39+
3840
3941// The string class
4042class String {
@@ -53,6 +55,7 @@ class String {
5355 // be false).
5456 String (const char *cstr = " " );
5557 String (const String &str);
58+ String (const __FlashStringHelper *str);
5659#ifdef __GXX_EXPERIMENTAL_CXX0X__
5760 String (String &&rval);
5861 String (StringSumHelper &&rval);
@@ -81,6 +84,7 @@ class String {
8184 // marked as invalid ("if (s)" will be false).
8285 String & operator =(const String &rhs);
8386 String & operator =(const char *cstr);
87+ String & operator = (const __FlashStringHelper *str);
8488#ifdef __GXX_EXPERIMENTAL_CXX0X__
8589 String & operator =(String &&rval);
8690 String & operator =(StringSumHelper &&rval);
@@ -101,6 +105,7 @@ class String {
101105 unsigned char concat (unsigned long num);
102106 unsigned char concat (float num);
103107 unsigned char concat (double num);
108+ unsigned char concat (const __FlashStringHelper * str);
104109
105110 // if there's not enough memory for the concatenated value, the string
106111 // will be left unchanged (but this isn't signalled in any way)
@@ -144,6 +149,10 @@ class String {
144149 concat (num);
145150 return (*this );
146151 }
152+ String & operator += (const __FlashStringHelper *str){
153+ concat (str);
154+ return (*this );
155+ }
147156
148157 friend StringSumHelper & operator +(const StringSumHelper &lhs, const String &rhs);
149158 friend StringSumHelper & operator +(const StringSumHelper &lhs, const char *cstr);
@@ -155,6 +164,7 @@ class String {
155164 friend StringSumHelper & operator +(const StringSumHelper &lhs, unsigned long num);
156165 friend StringSumHelper & operator +(const StringSumHelper &lhs, float num);
157166 friend StringSumHelper & operator +(const StringSumHelper &lhs, double num);
167+ friend StringSumHelper & operator +(const StringSumHelper &lhs, const __FlashStringHelper *rhs);
158168
159169 // comparison (only works w/ Strings and "strings")
160170 operator StringIfHelperType () const {
@@ -237,6 +247,7 @@ class String {
237247
238248 // copy and move
239249 String & copy (const char *cstr, unsigned int length);
250+ String & copy (const __FlashStringHelper *pstr, unsigned int length);
240251#ifdef __GXX_EXPERIMENTAL_CXX0X__
241252 void move (String &rhs);
242253#endif
0 commit comments