|
|
|
|
|
|
|
|
String Stream::readString(size_t max) |
|
|
String Stream::readString(size_t max) |
|
|
{ |
|
|
{ |
|
|
String str; |
|
|
String str; |
|
|
size_t length = str.length(); |
|
|
|
|
|
|
|
|
size_t length = 0; |
|
|
while (length < max) { |
|
|
while (length < max) { |
|
|
int c = timedRead(); |
|
|
int c = timedRead(); |
|
|
if (c < 0) { |
|
|
if (c < 0) { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
if (c == 0) break; |
|
|
if (c == 0) break; |
|
|
str += (char)c; |
|
|
str += (char)c; |
|
|
|
|
|
length++; |
|
|
} |
|
|
} |
|
|
return str; |
|
|
return str; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
String Stream::readStringUntil(char terminator, size_t max) |
|
|
String Stream::readStringUntil(char terminator, size_t max) |
|
|
{ |
|
|
{ |
|
|
String str; |
|
|
String str; |
|
|
size_t length = str.length(); |
|
|
|
|
|
|
|
|
size_t length = 0; |
|
|
while (length < max) { |
|
|
while (length < max) { |
|
|
int c = timedRead(); |
|
|
int c = timedRead(); |
|
|
if (c < 0) { |
|
|
if (c < 0) { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
if (c == 0 || c == terminator) break; |
|
|
if (c == 0 || c == terminator) break; |
|
|
str += (char)c; |
|
|
str += (char)c; |
|
|
|
|
|
length++; |
|
|
} |
|
|
} |
|
|
return str; |
|
|
return str; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|