FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
Loading...
Searching...
No Matches
streambuf.h File Reference

C++-like std::iostream facilities. More...

#include "flash.h"
#include "interrupts.h"
#include "queue.h"
Include dependency graph for streambuf.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  streams::ostreambuf
 Output API based on a ring buffer. More...
 
class  streams::istreambuf
 Input API based on a ring buffer. More...
 

Namespaces

namespace  streams
 Defines C++-like streams API, based on circular buffers for input or output.
 

Macros

#define REGISTER_OSTREAMBUF_LISTENERS(HANDLER1, ...)
 Register the necessary callbacks that will be notified when a streams::ostreambuf is put new content (character or string). More...
 
#define REGISTER_OSTREAMBUF_NO_LISTENERS()    void streams::ostreambuf_on_put_dispatch(ostreambuf&) {}
 Register no callback at all to streams::ostreambuf. More...
 
#define DECL_OSTREAMBUF_LISTENERS_FRIEND    friend struct streams::dispatch_handler;
 This macro shall be used in a class containing a private callback method bool on_put(streams::ostreambuf&), registered by REGISTER_OSTREAMBUF_LISTENERS. More...
 

Detailed Description

C++-like std::iostream facilities.

Definition in file streambuf.h.

Macro Definition Documentation

◆ REGISTER_OSTREAMBUF_LISTENERS

#define REGISTER_OSTREAMBUF_LISTENERS (   HANDLER1,
  ... 
)
Value:
void streams::ostreambuf_on_put_dispatch(ostreambuf& obuf) \
{ \
streams::dispatch_handler::ostreambuf_on_put<HANDLER1, ##__VA_ARGS__>(obuf);\
}

Register the necessary callbacks that will be notified when a streams::ostreambuf is put new content (character or string).

This is used by hardware and software UATX and UART.

Each handler registered here will be notified until one mentions it has handled the notification.

Warning
this macro must be called only once, with all interested handlers classes; calling it more than once will lead to errors at link time.
Note
you do not need to call this macro if you do not use streams::ostreambuf in your program.
Parameters
HANDLER1a class which registered instance will be notified, through its bool on_put(streams::ostreambuf&) method when any ostreambuffer has new content put into it.
...other classes similar to HANDLER1.
See also
REGISTER_OSTREAMBUF_NO_LISTENERS()
interrupt::register_handler

Definition at line 49 of file streambuf.h.

◆ REGISTER_OSTREAMBUF_NO_LISTENERS

#define REGISTER_OSTREAMBUF_NO_LISTENERS ( )     void streams::ostreambuf_on_put_dispatch(ostreambuf&) {}

Register no callback at all to streams::ostreambuf.

You normally do not need this macro, except if you:

  • use streams::ostreambuf
  • but you do not use UATX, or UART
  • you do not need to be called back when content is put to your ostreambuf instances
See also
REGISTER_OSTREAMBUF_LISTENERS()

Definition at line 64 of file streambuf.h.

◆ DECL_OSTREAMBUF_LISTENERS_FRIEND

#define DECL_OSTREAMBUF_LISTENERS_FRIEND    friend struct streams::dispatch_handler;

This macro shall be used in a class containing a private callback method bool on_put(streams::ostreambuf&), registered by REGISTER_OSTREAMBUF_LISTENERS.

It declares the class where it is used as a friend of all necessary functions so that the private callback method can be called properly.

Definition at line 73 of file streambuf.h.