SafeString  4.1.27
SafeString is a safe, robust and debuggable replacement for string processing in Arduino
SafeStringReader.h File Reference
#include <Arduino.h>
#include "SafeString.h"
#include "SafeStringNameSpaceStart.h"
#include "SafeStringNameSpaceEnd.h"

Go to the source code of this file.

Classes

class  SafeStringReader
 To create a SafeStringReader use the macro createSafeStringReader see the detailed description. More...
 

Macros

#define createSafeStringReader(name, size, ...)
 createSafeStringReader( ) params name - name of this SafeStringReader variable (DO NOT use " " just use the plain name see the examples) size - the maximum length of the delimited token that can be read, NOT including the delimiter If more then size chars read without finding a delimiter they are discarded and all chars upto the next delimiter are also discarded. More...
 

Macro Definition Documentation

◆ createSafeStringReader

#define createSafeStringReader (   name,
  size,
  ... 
)
Value:
char name ## _INPUT_BUFFER[(size)+2]; \
char name ## _TOKEN_BUFFER[(size)+2]; \
SafeString name ## _SF_INPUT((size)+2, name ## _INPUT_BUFFER, "", #name "_InputBuffer"); \
SafeStringReader name(name ## _SF_INPUT, (size)+2, name ## _TOKEN_BUFFER, #name, __VA_ARGS__ );

createSafeStringReader( ) params name - name of this SafeStringReader variable (DO NOT use " " just use the plain name see the examples) size - the maximum length of the delimited token that can be read, NOT including the delimiter If more then size chars read without finding a delimiter they are discarded and all chars upto the next delimiter are also discarded.

I.e. tokens longer than size are igorned and not returned. delimiters - either a char ('
') or a string of delimiters ("\r\n,.") skipToDelimiterFlag - true if all data upto the first delimiter received should be ignored, default false echoInput - true if all chars read (including delimiters) are to be echoed back to the Stream being read from, default false timeout_ms - the ms timeout, if no more chars read for this timeout, the current input is returned as the token. In this case getDelimiter() returns -1, default 0 i.e. never times out must read a delimiter

example createSafeStringReader(sfReader,20,'
',false,true,100); This creates a SafeStringReader sfReader which can read delimited tokens upto 20 chars long (not including the delimiter), no initial skipToDelimiter, echo is ON, timeout is 100ms If no '
' is received and no new chars read for 100ms the currently read char will be returned as the token

Definition at line 37 of file SafeStringReader.h.