-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMultiFind.h
61 lines (53 loc) · 1.28 KB
/
MultiFind.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// (c) Copyright 2014 MCQN Ltd
#ifndef MULTIFIND_H
#define MULTIFIND_H
#if (ARDUINO >= 100)
#include <Arduino.h>
#else
#include <WProgram.h>
#include <pins_arduino.h>
#endif
class FindItem
{
public:
FindItem(const char* aFindString =NULL);
void reset();
// FIXME Current algorithm doesn't cope with repeated strings
// FIXME i.e. I think it wouldn't find "frefred" in "frefrefred"
bool checkChar(char aChar);
protected:
const char* iFindString;
int iCurrentPos;
int iLength;
};
class MultiFind
{
public:
MultiFind(FindItem* aItemsToFind, int aCount);
// Find one of the given items
// @param aStream - stream to search
// @return -1 if it failed to find any of them
// otherwise the index of the found item
int find(Stream& aStream);
protected:
// Because the version in Stream is protected and so inaccessible to us
int timedRead(Stream& aStream);
FindItem* iItems;
int iCount;
};
class MultiFindNonBlocking
{
public:
MultiFindNonBlocking(FindItem* aItemsToFind, int aCount);
void reset();
// Find one of the given items
// @param aStream - stream to search
// @return -1 if it failed to find any of them
// otherwise the index of the found item
int find(Stream& aStream);
protected:
FindItem* iItems;
int iCount;
};
#endif