Wiki
Clone wikiArduino StrScanner / API
StrScanner API
Constructors
Constructor Name | Description |
---|---|
StrScanner(String) |
Give as parameter the string you want to analyse. |
StrScanner(String, String) |
Give as parameters the string to analyse and the delimiter string between a word and the next. |
Functions
Return type | Function name | Description |
---|---|---|
void |
useDelimiter(String) |
Uses the passed string as a delimiter |
bool |
hasNext() |
Returns true if there is another element to analyse |
bool |
hasNextBool() |
Returns true if there is another element to analyse, and it is a bool |
bool |
hasNextByte() |
Returns true if there is another element to analyse, and it is a byte |
bool |
hasNextChar() |
Returns true if there is another element to analyse, and it is a char |
bool |
hasNextDouble() |
Returns true if there is another element to analyse, and it is a double |
bool |
hasNextInt() |
Returns true if there is another element to analyse, and it is an int |
String |
next() |
Returns the next available String and moves on to the next one. |
bool |
nextBool() |
Returns the next available boolean and moves on to the next one. |
byte |
nextByte() |
Returns the next available byte and moves on to the next one. |
bool |
nextChar() |
Returns the next available character and moves on to the next one. |
double |
nextDouble() |
Returns the next available double and moves on to the next one. |
int |
nextInt() |
Returns the next available int and moves on to the next one. |
Caveats
- The boolean values that the scanner can recognise are the following:
- 0-1
- true-false (case insensitive)
- t-f (case insensitive)
- yes-no (case insensitive)
- y-n (case insensitive)
- The default delimiter is the empty string, this is a special case in which the scanner returns one character at a time. To understand better, look at the delimiter page.
- You can change delimiter at any given point in time during your program, but the StrScanner will continue analyzing the String from the last place left, this means that the next() function will, as first result, give you the next entry analysed with the old delimiter.
Updated