瀏覽代碼

Stream find functions const pointers are Teensy 2.0

main
PaulStoffregen 7 年之前
父節點
當前提交
dba739077b
共有 2 個檔案被更改,包括 12 行新增12 行删除
  1. +4
    -4
      teensy/Stream.cpp
  2. +8
    -8
      teensy/Stream.h

+ 4
- 4
teensy/Stream.cpp 查看文件

@@ -73,20 +73,20 @@ void Stream::setTimeout(unsigned long timeout) // sets the maximum number of mi
}

// find returns true if the target string is found
bool Stream::find(char *target)
bool Stream::find(const char *target)
{
return findUntil(target, NULL);
}

// reads data from the stream until the target string of given length is found
// returns true if target string is found, false if timed out
bool Stream::find(char *target, size_t length)
bool Stream::find(const char *target, size_t length)
{
return findUntil(target, length, NULL, 0);
}

// as find but search ends if the terminator string is found
bool Stream::findUntil(char *target, char *terminator)
bool Stream::findUntil(const char *target, char *terminator)
{
return findUntil(target, strlen(target), terminator, strlen(terminator));
}
@@ -94,7 +94,7 @@ bool Stream::findUntil(char *target, char *terminator)
// reads data from the stream until the target string of the given length is found
// search terminated if the terminator string is found
// returns true if target string is found, false if terminated or timed out
bool Stream::findUntil(char *target, size_t targetLen, char *terminator, size_t termLen)
bool Stream::findUntil(const char *target, size_t targetLen, char *terminator, size_t termLen)
{
size_t index = 0; // maximum target string length is 64k bytes!
size_t termIndex = 0;

+ 8
- 8
teensy/Stream.h 查看文件

@@ -33,14 +33,14 @@ class Stream : public Print
virtual void flush() = 0;

void setTimeout(unsigned long timeout);
bool find(char *target);
bool find(uint8_t *target) { return find ((char *)target); }
bool find(char *target, size_t length);
bool find(uint8_t *target, size_t length) { return find ((char *)target, length); }
bool findUntil(char *target, char *terminator);
bool findUntil(uint8_t *target, char *terminator) { return findUntil((char *)target, terminator); }
bool findUntil(char *target, size_t targetLen, char *terminate, size_t termLen);
bool findUntil(uint8_t *target, size_t targetLen, char *terminate, size_t termLen) {return findUntil((char *)target, targetLen, terminate, termLen); }
bool find(const char *target);
bool find(const uint8_t *target) { return find ((const char *)target); }
bool find(const char *target, size_t length);
bool find(const uint8_t *target, size_t length) { return find ((const char *)target, length); }
bool findUntil(const char *target, char *terminator);
bool findUntil(const uint8_t *target, char *terminator) { return findUntil((const char *)target, terminator); }
bool findUntil(const char *target, size_t targetLen, char *terminate, size_t termLen);
bool findUntil(const uint8_t *target, size_t targetLen, char *terminate, size_t termLen) {return findUntil((const char *)target, targetLen, terminate, termLen); }
long parseInt();
long parseInt(char skipChar);
float parseFloat();

Loading…
取消
儲存