1 #ifndef SAFE_STRING_READER_H
2 #define SAFE_STRING_READER_H
37 #define createSafeStringReader(name, size, ...) \
38 char name ## _INPUT_BUFFER[(size)+2]; \
39 char name ## _TOKEN_BUFFER[(size)+2]; \
40 SafeString name ## _SF_INPUT((size)+2, name ## _INPUT_BUFFER, "", #name "_InputBuffer"); \
41 SafeStringReader name(name ## _SF_INPUT, (size)+2, name ## _TOKEN_BUFFER, #name, __VA_ARGS__ );
76 explicit SafeStringReader(
SafeString& _sfInput,
size_t bufSize,
char *tokenBuf,
const char* _name,
const char* delimiters,
bool skipToDelimiterFlag =
false, uint8_t echoInput =
false,
unsigned long timeout_ms = 0 );
77 explicit SafeStringReader(
SafeString& _sfInput,
size_t bufSize,
char *tokenBuf,
const char* _name,
const char delimiter,
bool skipToDelimiterFlag =
false, uint8_t echoInput =
false,
unsigned long timeout_ms = 0 );
200 void init(
SafeString& _sfInput,
const char* delimiters,
bool skipToDelimiterFlag, uint8_t echoInput,
unsigned long timeout_ms);
203 const char* delimiters;
204 bool skipToDelimiterFlag;
206 bool emptyTokensReturned;
208 unsigned long timeout_ms;
212 char internalCharDelimiter[2];
To create SafeStrings use one of the four (4) macros createSafeString or cSF, createSafeStringFromCha...
To create a SafeStringReader use the macro createSafeStringReader see the detailed description.
int getDelimiter()
getDelimiter() returns the delimiter that terminated the last token only valid when read() returns tr...
void connect(Stream &stream)
connect(Stream& stream) specifies the Stream to read chars from params stream – the Stream to read fr...
void flushInput()
flushInput() clears any buffered input and Stream RX buffer then sets skipToDelimiterFlag true Once t...
void setTimeout(unsigned long ms)
setTimeout sets the timeout to wait for more chars.
const char * debugInputBuffer(const __FlashStringHelper *title, bool verbose=true)
const char * debugInputBuffer(const char *title, bool verbose=true)
const char * debugInputBuffer(bool verbose=true)
debugInputBuffer These methods let you print out the current contents of the input buffer that the St...
void skipToDelimiter()
skipToDelimiter() discards the next token read Once the next delimiter is read or if the timeout is s...
SafeStringReader(SafeString &_sfInput, size_t bufSize, char *tokenBuf, const char *_name, const char *delimiters, bool skipToDelimiterFlag=false, uint8_t echoInput=false, unsigned long timeout_ms=0)
void echoOn()
echoOn(), echoOff() control echoing back to the input Stream all chars read default if echoOff();
bool read()
read() returns true if a delimited token has been read from the stream.
size_t getReadCount()
getReadCount() The SafeStringReader counts the number of chars read since the last connect( ) call.
const char * debugInputBuffer(SafeString &stitle, bool verbose=true)
void returnEmptyTokens(bool flag=true)
returnEmptyTokens By default empty tokens are not returned, i.e.
SafeStringReader(SafeString &_sfInput, size_t bufSize, char *tokenBuf, const char *_name, const char delimiter, bool skipToDelimiterFlag=false, uint8_t echoInput=false, unsigned long timeout_ms=0)
bool isSkippingToDelimiter()
isSkippingToDelimiter returns true if currently skipping to next delimiter
bool end()
end() returns true if have another token, terminates last token if any, disconnect from stream,...
SafeStringReader & operator=(char c)