|
FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
|
Output API based on a ring buffer. More...
#include <fastarduino/streambuf.h>


Public Member Functions | |
| ostreambuf (const ostreambuf &)=delete | |
| ostreambuf & | operator= (const ostreambuf &)=delete |
| void | pubsync () |
| Wait until all buffer content has been pulled by a consumer. More... | |
| void | sputc (char c) |
| Append a character to the buffer. More... | |
| void | sputn (const char *content, size_t size) |
| Append several characters to the buffer. More... | |
| void | sputn (const char *str) |
| Append a string to the buffer. More... | |
| void | sputn (const flash::FlashStorage *str) |
| Append a string, stored on flash memory, to the buffer. More... | |
| bool | overflow () const |
Indicate if a buffer overflow has occurred since last time pubsync() or reset_overflow() was called. More... | |
| QUEUE & | queue () |
| Return the underlying queue. More... | |
Protected Member Functions | |
| void | put_ (char c, bool call_on_put=true) |
| Append a character to the buffer. More... | |
| void | reset_overflow () |
| Reset the overflow flag. More... | |
Friends | |
| class | ios_base |
| class | ostream |
Output API based on a ring buffer.
Provides general methods to push characters or strings to the buffer; the buffer is supposed to be consumed by another class (e.g. serial::hard::UATX). The API provides a protected "hook" (virtual on_put()) that get notified every time new content is successfully pushed to the buffer, or when the buffer is full while new content addition is attempted.
| buffer | the original ring buffer containing all pushed content; once passed to the constructor, it should never be used directly as it will be consumed by a containers::Queue. |
Definition at line 95 of file streambuf.h.
|
inline |
Wait until all buffer content has been pulled by a consumer.
This method clear the count of overflows that have occurred until now.
Definition at line 113 of file streambuf.h.
|
inline |
Append a character to the buffer.
If the buffer is full, then overflow() flag will be set.
| c | the character to append |
Definition at line 125 of file streambuf.h.
|
inline |
Append several characters to the buffer.
If the buffer is full, then overflow() flag will be set. Once all characters have been appended, on_put() will be called, even if an overflow has occurred.
| content | the array of characters to be appended |
| size | the number of characters in content to append |
Definition at line 141 of file streambuf.h.
|
inline |
Append a string to the buffer.
The ‘’\0'end character of @p str is not transmitted. If the buffer is full, thenoverflow()flag will be set. Once all string content has been appended,on_put()` will be called, even if an overflow has occurred.
| str | the '\0' ended string (standard C-string) to append |
Definition at line 158 of file streambuf.h.
|
inline |
Append a string, stored on flash memory, to the buffer.
The ‘’\0'end character of @p str is not transmitted. If the buffer is full, thenoverflow()flag will be set. Once all string content has been appended,on_put()` will be called, even if an overflow has occurred. Example:
| str | the '\0' ended string (standard C-string), stored on flash, to append |
Definition at line 181 of file streambuf.h.
|
inline |
Indicate if a buffer overflow has occurred since last time pubsync() or reset_overflow() was called.
Definition at line 194 of file streambuf.h.
|
inline |
Return the underlying queue.
Normally you will not need this method.
Definition at line 203 of file streambuf.h.
|
inlineprotected |
Append a character to the buffer.
If the buffer is full, then overflow() flag will be set.
| c | the character to append |
| call_on_put | true if on_put() should be called after c has been appended, false otherwise; when directly calling this method, you should keep the default value. |
Definition at line 219 of file streambuf.h.
|
inlineprotected |
|
friend |
Definition at line 242 of file streambuf.h.
|
friend |
Definition at line 243 of file streambuf.h.