<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-cn">
		<id>http://wiki.ywrobot.net/index.php?action=history&amp;feed=atom&amp;title=Stream.h</id>
		<title>Stream.h - 版本历史</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.ywrobot.net/index.php?action=history&amp;feed=atom&amp;title=Stream.h"/>
		<link rel="alternate" type="text/html" href="http://wiki.ywrobot.net/index.php?title=Stream.h&amp;action=history"/>
		<updated>2026-05-14T11:01:51Z</updated>
		<subtitle>本wiki的该页面的版本历史</subtitle>
		<generator>MediaWiki 1.26.2</generator>

	<entry>
		<id>http://wiki.ywrobot.net/index.php?title=Stream.h&amp;diff=87&amp;oldid=prev</id>
		<title>YWrobot CYB：创建页面，内容为“&lt;pre style=&quot;color:blue&quot;&gt; /*   Stream.h - base class for character-based streams.   Copyright (c) 2010 David A. Mellis.  All right reserved.    This library is free s...”</title>
		<link rel="alternate" type="text/html" href="http://wiki.ywrobot.net/index.php?title=Stream.h&amp;diff=87&amp;oldid=prev"/>
				<updated>2016-04-25T02:18:47Z</updated>
		
		<summary type="html">&lt;p&gt;创建页面，内容为“&amp;lt;pre style=&amp;quot;color:blue&amp;quot;&amp;gt; /*   Stream.h - base class for character-based streams.   Copyright (c) 2010 David A. Mellis.  All right reserved.    This library is free s...”&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;pre style=&amp;quot;color:blue&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
  Stream.h - base class for character-based streams.&lt;br /&gt;
  Copyright (c) 2010 David A. Mellis.  All right reserved.&lt;br /&gt;
&lt;br /&gt;
  This library is free software; you can redistribute it and/or&lt;br /&gt;
  modify it under the terms of the GNU Lesser General Public&lt;br /&gt;
  License as published by the Free Software Foundation; either&lt;br /&gt;
  version 2.1 of the License, or (at your option) any later version.&lt;br /&gt;
&lt;br /&gt;
  This library is distributed in the hope that it will be useful,&lt;br /&gt;
  but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU&lt;br /&gt;
  Lesser General Public License for more details.&lt;br /&gt;
&lt;br /&gt;
  You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
  License along with this library; if not, write to the Free Software&lt;br /&gt;
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA&lt;br /&gt;
&lt;br /&gt;
  parsing functions based on TextFinder library by Michael Margolis&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
#ifndef Stream_h&lt;br /&gt;
#define Stream_h&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;inttypes.h&amp;gt;&lt;br /&gt;
#include &amp;quot;Print.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
// compatability macros for testing&lt;br /&gt;
/*&lt;br /&gt;
#define   getInt()            parseInt()&lt;br /&gt;
#define   getInt(skipChar)    parseInt(skipchar)&lt;br /&gt;
#define   getFloat()          parseFloat()&lt;br /&gt;
#define   getFloat(skipChar)  parseFloat(skipChar)&lt;br /&gt;
#define   getString( pre_string, post_string, buffer, length)&lt;br /&gt;
readBytesBetween( pre_string, terminator, buffer, length)&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
class Stream : public Print&lt;br /&gt;
{&lt;br /&gt;
  protected:&lt;br /&gt;
    unsigned long _timeout;      // number of milliseconds to wait for the next char before aborting timed read&lt;br /&gt;
    unsigned long _startMillis;  // used for timeout measurement&lt;br /&gt;
    int timedRead();    // private method to read stream with timeout&lt;br /&gt;
    int timedPeek();    // private method to peek stream with timeout&lt;br /&gt;
    int peekNextDigit(); // returns the next numeric digit in the stream or -1 if timeout&lt;br /&gt;
&lt;br /&gt;
  public:&lt;br /&gt;
    virtual int available() = 0;&lt;br /&gt;
    virtual int read() = 0;&lt;br /&gt;
    virtual int peek() = 0;&lt;br /&gt;
    virtual void flush() = 0;&lt;br /&gt;
&lt;br /&gt;
    Stream() {_timeout=1000;}&lt;br /&gt;
&lt;br /&gt;
// parsing methods&lt;br /&gt;
&lt;br /&gt;
  void setTimeout(unsigned long timeout);  // sets maximum milliseconds to wait for stream data, default is 1 second&lt;br /&gt;
&lt;br /&gt;
  bool find(char *target);   // reads data from the stream until the target string is found&lt;br /&gt;
  // returns true if target string is found, false if timed out (see setTimeout)&lt;br /&gt;
&lt;br /&gt;
  bool find(char *target, size_t length);   // reads data from the stream until the target string of given length is found&lt;br /&gt;
  // returns true if target string is found, false if timed out&lt;br /&gt;
&lt;br /&gt;
  bool findUntil(char *target, char *terminator);   // as find but search ends if the terminator string is found&lt;br /&gt;
&lt;br /&gt;
  bool findUntil(char *target, size_t targetLen, char *terminate, size_t termLen);   // as above but search ends if the terminate string is found&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  long parseInt(); // returns the first valid (long) integer value from the current position.&lt;br /&gt;
  // initial characters that are not digits (or the minus sign) are skipped&lt;br /&gt;
  // integer is terminated by the first character that is not a digit.&lt;br /&gt;
&lt;br /&gt;
  float parseFloat();               // float version of parseInt&lt;br /&gt;
&lt;br /&gt;
  size_t readBytes( char *buffer, size_t length); // read chars from stream into buffer&lt;br /&gt;
  // terminates if length characters have been read or timeout (see setTimeout)&lt;br /&gt;
  // returns the number of characters placed in the buffer (0 means no valid data found)&lt;br /&gt;
&lt;br /&gt;
  size_t readBytesUntil( char terminator, char *buffer, size_t length); // as readBytes with terminator character&lt;br /&gt;
  // terminates if length characters have been read, timeout, or if the terminator character  detected&lt;br /&gt;
  // returns the number of characters placed in the buffer (0 means no valid data found)&lt;br /&gt;
&lt;br /&gt;
  // Arduino String functions to be added here&lt;br /&gt;
  String readString();&lt;br /&gt;
  String readStringUntil(char terminator);&lt;br /&gt;
&lt;br /&gt;
  protected:&lt;br /&gt;
  long parseInt(char skipChar); // as above but the given skipChar is ignored&lt;br /&gt;
  // as above but the given skipChar is ignored&lt;br /&gt;
  // this allows format characters (typically commas) in values to be ignored&lt;br /&gt;
&lt;br /&gt;
  float parseFloat(char skipChar);  // as above but the given skipChar is ignored&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>YWrobot CYB</name></author>	</entry>

	</feed>