Skip to content

Commit e96f80d

Browse files
committed
restore streamstring.cpp when string is not stream
1 parent 1fd80d1 commit e96f80d

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

cores/esp8266/StreamString.cpp

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/**
2+
StreamString.cpp
3+
4+
Copyright (c) 2015 Markus Sattler. All rights reserved.
5+
This file is part of the esp8266 core for Arduino environment.
6+
7+
This library is free software; you can redistribute it and/or
8+
modify it under the terms of the GNU Lesser General Public
9+
License as published by the Free Software Foundation; either
10+
version 2.1 of the License, or (at your option) any later version.
11+
12+
This library is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
Lesser General Public License for more details.
16+
17+
You should have received a copy of the GNU Lesser General Public
18+
License along with this library; if not, write to the Free Software
19+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20+
21+
*/
22+
23+
24+
#include "StreamString.h"
25+
26+
#if !STRING_IS_STREAM
27+
28+
size_t StreamString::write(const uint8_t *data, size_t size) {
29+
if(size && data) {
30+
const unsigned int newlen = length() + size;
31+
if(reserve(newlen + 1)) {
32+
memcpy((void *) (wbuffer() + len()), (const void *) data, size);
33+
setLen(newlen);
34+
*(wbuffer() + newlen) = 0x00; // add null for string end
35+
return size;
36+
}
37+
DEBUGV(":stream2string: OOM (%d->%d)\n", length(), newlen+1);
38+
}
39+
return 0;
40+
}
41+
42+
size_t StreamString::write(uint8_t data) {
43+
return concat((char) data);
44+
}
45+
46+
int StreamString::available() {
47+
return length();
48+
}
49+
50+
int StreamString::read() {
51+
if(length()) {
52+
char c = charAt(0);
53+
remove(0, 1);
54+
return c;
55+
56+
}
57+
return -1;
58+
}
59+
60+
int StreamString::peek() {
61+
if(length()) {
62+
char c = charAt(0);
63+
return c;
64+
}
65+
return -1;
66+
}
67+
68+
void StreamString::flush() {
69+
}
70+
71+
#endif // !STRING_IS_STREAM

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy