23
23
24
24
#ifdef __cplusplus
25
25
26
+ #include " Printable.h"
27
+
26
28
#include < stdlib.h>
27
29
#include < string.h>
28
30
#include < ctype.h>
29
- #if defined(__AVR__)
30
- #include " avr/pgmspace.h"
31
- #else
32
- #include " deprecated-avr-comp/avr/pgmspace.h"
33
- #endif
34
31
35
32
// When compiling programs with this class, the following gcc parameters
36
33
// dramatically increase performance and memory (RAM) efficiency, typically
37
34
// with little or no increase in code size.
38
35
// -felide-constructors
39
36
// -std=c++0x
40
37
41
- class __FlashStringHelper ;
42
- #define F (string_literal ) (reinterpret_cast <const __FlashStringHelper *>(PSTR(string_literal)))
38
+ class String ;
39
+
40
+ // Default implemtation of 'F' macro for cores than can use
41
+ // string literals directly as (const char *).
42
+ // For cores that require special interface to program memory,
43
+ // the default 'F' macro can be undefined at core
44
+ // implementation level and redefined as needed.
45
+ #define F (string_literal ) (string_literal)
46
+
47
+ // Base Class for strings stored in program memory.
48
+ // For cores that require special interface to program memory,
49
+ // this class can be extended at the core implementation
50
+ // level in order to support String and Print operations from
51
+ // program memory.
52
+ class FlashString : public Printable
53
+ {
54
+ public:
55
+ virtual String toString () const = 0;
56
+ };
43
57
44
58
// An inherited class for holding the result of a concatenation. These
45
59
// result objects are assumed to be writable by subsequent concatenations.
@@ -62,7 +76,7 @@ class String
62
76
// be false).
63
77
String (const char *cstr = " " );
64
78
String (const String &str);
65
- String (const __FlashStringHelper *str );
79
+ String (const FlashString &fstr );
66
80
#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
67
81
String (String &&rval);
68
82
String (StringSumHelper &&rval);
@@ -89,7 +103,7 @@ class String
89
103
// marked as invalid ("if (s)" will be false).
90
104
String & operator = (const String &rhs);
91
105
String & operator = (const char *cstr);
92
- String & operator = (const __FlashStringHelper *str );
106
+ String & operator = (const FlashString &fstr );
93
107
#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
94
108
String & operator = (String &&rval);
95
109
String & operator = (StringSumHelper &&rval);
@@ -110,7 +124,7 @@ class String
110
124
unsigned char concat (unsigned long num);
111
125
unsigned char concat (float num);
112
126
unsigned char concat (double num);
113
- unsigned char concat (const __FlashStringHelper * str );
127
+ unsigned char concat (const FlashString &fstr );
114
128
115
129
// if there's not enough memory for the concatenated value, the string
116
130
// will be left unchanged (but this isn't signalled in any way)
@@ -124,7 +138,7 @@ class String
124
138
String & operator += (unsigned long num) {concat (num); return (*this );}
125
139
String & operator += (float num) {concat (num); return (*this );}
126
140
String & operator += (double num) {concat (num); return (*this );}
127
- String & operator += (const __FlashStringHelper *str ){concat (str ); return (*this );}
141
+ String & operator += (const FlashString &fstr ){concat (fstr ); return (*this );}
128
142
129
143
friend StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs);
130
144
friend StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr);
@@ -136,7 +150,7 @@ class String
136
150
friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num);
137
151
friend StringSumHelper & operator + (const StringSumHelper &lhs, float num);
138
152
friend StringSumHelper & operator + (const StringSumHelper &lhs, double num);
139
- friend StringSumHelper & operator + (const StringSumHelper &lhs, const __FlashStringHelper * rhs);
153
+ friend StringSumHelper & operator + (const StringSumHelper &lhs, const FlashString & rhs);
140
154
141
155
// comparison (only works w/ Strings and "strings")
142
156
operator StringIfHelperType () const { return buffer ? &String::StringIfHelper : 0 ; }
@@ -222,7 +236,6 @@ class String
222
236
223
237
// copy and move
224
238
String & copy (const char *cstr, unsigned int length);
225
- String & copy (const __FlashStringHelper *pstr, unsigned int length);
226
239
#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
227
240
void move (String &rhs);
228
241
#endif
0 commit comments