![]() |
Elementa v8.0.0
Minimalistic library for any C++ application (C++11 and up)
|
A number of serial channels ready to use.
Constrained by the architecture of STL streams, Elementa serial channels have the following characteristics (there is no both sensible and efficient way of forcing the user to provide all these characteristics in a compiler-controlled fashion, thus it is the responsibility of the programmer to comply with them):

Classes | |
| class | elementa::base::SerChO_Null |
| Null output serial channel to discard anything written to it. More... | |
| class | elementa::base::SerChO_NullCoBuf |
| Null output serial channel that can count what is written and also buffer it. More... | |
| class | elementa::base::SerChO_AppCont< Cont > |
| Output ser. chan. that appends to a container without pre-allocated storage. More... | |
| class | elementa::base::SerChI_Constant |
| Input serial channel that provides a pre-defined char value endlessly. More... | |
| class | elementa::base::SerChI_Procedural |
| Input serial channel that provides values based on some procedure. More... | |
| class | elementa::base::InStreamBuf_MemoryPriv |
| Private class that needs to be here for the following channels to work. More... | |
| class | elementa::base::InOutStreamBuf_MemoryPriv |
| Private class that needs to be here for the following channels to work. More... | |
| class | elementa::base::SerChIO_Memory |
| Input + output ser. chan. associated to a pre-allocated region of memory. More... | |
| class | elementa::base::SerChI_Memory |
| Input + output ser. chan. associated to a pre-allocated region of memory. More... | |
Functions | |
| template<> | |
| SerChSize | elementa::base::serch_transfer< SerChIO_Memory, SerChIO_Memory > (SerChIO_Memory &chin, SerChIO_Memory &chout, SerChSize count) |
| Full specialization of serch_transfer for both channels being Memory. More... | |
| template<> | |
| SerChSize | elementa::base::serch_transfer< SerChI_Memory, SerChIO_Memory > (SerChI_Memory &chin, SerChIO_Memory &chout, SerChSize count) |
| Full specialization of serch_transfer for both channels being Memory. More... | |
| template<typename T > | |
| elementa::base::SerChIO_Memory::SerChIO_Memory (void *begin, T n) noexcept | |
| Template constructor. More... | |
| template<typename T > | |
| elementa::base::SerChIO_Memory::SerChIO_Memory (std::vector< T > &v, typename std::vector< T >::size_type offbegin=0, typename std::vector< T >::size_type offend=0) | |
| Template constructor for a region within a std::vector. More... | |
| template<typename T , std::size_t N> | |
| elementa::base::SerChIO_Memory::SerChIO_Memory (std::array< T, N > &a, typename std::array< T, N >::size_type offbegin=0, typename std::array< T, N >::size_type offend=0) | |
| Template constructor for a region within a std::array. More... | |
| template<typename T > | |
| elementa::base::SerChI_Memory::SerChI_Memory (const void *begin, T n) noexcept | |
| Template constructor. More... | |
| template<typename T > | |
| elementa::base::SerChI_Memory::SerChI_Memory (const std::vector< T > &v, typename std::vector< T >::size_type offbegin=0, typename std::vector< T >::size_type offend=0) | |
| Template constructor for a region within a std::vector. More... | |
| template<typename T , std::size_t N> | |
| elementa::base::SerChI_Memory::SerChI_Memory (const std::array< T, N > &a, typename std::array< T, N >::size_type offbegin=0, typename std::array< T, N >::size_type offend=0) | |
| Template constructor for a region within a std::array. More... | |
Variables | |
| SerChI_Constant | elementa::base::serchI_dummy |
| A singleton, dummy input channel that always produces space characters. | |
| class elementa::base::SerChO_Null |
Null output serial channel to discard anything written to it.
This class may serve to discard a sequence of data. If you need to count how many, or to buffer them, use SerChO_NullCoBuf instead.
Definition at line 80 of file channels.h.


|
inline |
Definition at line 84 of file channels.h.
| class elementa::base::SerChO_NullCoBuf |
Null output serial channel that can count what is written and also buffer it.
This class may serve to count the serialized data and also to buffer it for using it afterwards. If you need a buffer with unlimited storage, see SerChO_AppCont.
Definition at line 126 of file channels.h.


Public Member Functions | |
| SerChO_NullCoBuf (SerChSize buffer=0) | |
| Create a serial channel able to count and with a buffer of BUFFER chars. More... | |
| SerChSize | size (void) const |
| Return the buffer size defined in the constructor. More... | |
| void | reset (void) |
| Reset the count of the channel and, if any, clear the buffer. More... | |
| SerChSize | count (void) const |
| Return the current number of chars already serialized. More... | |
| const char * | buffer (void) const |
| Return nullptr if the buffer has size 0, or the buffer otherwise. More... | |
|
inline |
Create a serial channel able to count and with a buffer of BUFFER chars.
Definition at line 131 of file channels.h.
|
inline |
Return the buffer size defined in the constructor.
Definition at line 136 of file channels.h.
|
inline |
Reset the count of the channel and, if any, clear the buffer.
Definition at line 139 of file channels.h.
|
inline |
Return the current number of chars already serialized.
Definition at line 142 of file channels.h.
|
inline |
Return nullptr if the buffer has size 0, or the buffer otherwise.
Definition at line 145 of file channels.h.
| class elementa::base::SerChO_AppCont |
Output ser. chan. that appends to a container without pre-allocated storage.
If you need to output data to a container with pre-allocated storage, see SerChIO_Memory.
Definition at line 196 of file channels.h.


Public Member Functions | |
| SerChO_AppCont (Cont &cont) | |
| Create a serial channel to append chars at the end of CONT. More... | |
| Cont & | container (void) noexcept |
| Return a reference to the container. More... | |
|
inline |
Create a serial channel to append chars at the end of CONT.
CONT must outlive the channel, since the channel does not take ownership of it.
Definition at line 203 of file channels.h.
|
inlinenoexcept |
Return a reference to the container.
Definition at line 207 of file channels.h.
| class elementa::base::SerChI_Constant |
Input serial channel that provides a pre-defined char value endlessly.
Definition at line 251 of file channels.h.


Public Member Functions | |
| SerChI_Constant (char c) | |
|
inline |
Definition at line 255 of file channels.h.
| class elementa::base::SerChI_Procedural |
Input serial channel that provides values based on some procedure.
Definition at line 299 of file channels.h.


Public Types | |
| using | Procedure = std::function< SerChDatum(void) > |
| A procedure that generates the characters. More... | |
Public Member Functions | |
| SerChI_Procedural (Procedure &p) | |
| Constructor. P must outlive this channel: only a reference is taken. More... | |
| using elementa::base::SerChI_Procedural::Procedure = std::function< SerChDatum(void) > |
A procedure that generates the characters.
If there is a character available, SerChCharTraits::to_int_type(c) must be returned; otherwise, kSerChEOF must be returned.
Definition at line 306 of file channels.h.
|
inline |
Constructor. P must outlive this channel: only a reference is taken.
Definition at line 309 of file channels.h.
| class elementa::base::InStreamBuf_MemoryPriv |
Private class that needs to be here for the following channels to work.
Definition at line 363 of file channels.h.


Public Member Functions | |
| void | reset (const char *begin, const char *end) |
| SerChSize | transfer (InOutStreamBuf_MemoryPriv &other, SerChSize count) |
| class elementa::base::InOutStreamBuf_MemoryPriv |
Private class that needs to be here for the following channels to work.
Definition at line 382 of file channels.h.


Public Member Functions | |
| void | reset (char *begin, char *end) |
| SerChSize | transfer (InOutStreamBuf_MemoryPriv &other, SerChSize count) |
| class elementa::base::SerChIO_Memory |
Input + output ser. chan. associated to a pre-allocated region of memory.
Allow to access a memory region through the serial channel paradigm. That memory can be provided by containers such as std::vector, std::array or std::string.
This class is not thread-safe.
Definition at line 420 of file channels.h.


Public Member Functions | |
| template<typename T > | |
| SerChIO_Memory (void *begin, T n) noexcept | |
| Template constructor. More... | |
| SerChIO_Memory (std::string &str, std::string::size_type offbegin=0, std::string::size_type offend=0) | |
| Constructor for a region within a string. More... | |
| template<typename T > | |
| SerChIO_Memory (std::vector< T > &v, typename std::vector< T >::size_type offbegin=0, typename std::vector< T >::size_type offend=0) | |
| Template constructor for a region within a std::vector. More... | |
| template<typename T , std::size_t N> | |
| SerChIO_Memory (std::array< T, N > &a, typename std::array< T, N >::size_type offbegin=0, typename std::array< T, N >::size_type offend=0) | |
| Template constructor for a region within a std::array. More... | |
| SerChIO_Memory (const SerChIO_Memory &)=delete | |
| SerChIO_Memory (SerChIO_Memory &&)=delete | |
| SerChIO_Memory & | operator= (SerChIO_Memory &)=delete |
| SerChIO_Memory & | operator= (SerChIO_Memory &&)=delete |
| void | reset (void) |
| Reset the channel to its initial position and state. | |
| SerChSize | transfer (SerChIO_Memory &chout, SerChSize count=0) |
| Specialized version of serch_transfer when both channels are of memory. More... | |
| elementa::base::SerChIO_Memory::SerChIO_Memory | ( | std::string & | str, |
| std::string::size_type | offbegin = 0, |
||
| std::string::size_type | offend = 0 |
||
| ) |
Constructor for a region within a string.
| offbegin | is the offset from the beginning of the region used by the channel. |
| offend | is the offset from the ending, backwards, of the region used by the channel. |
|
inline |
Specialized version of serch_transfer when both channels are of memory.
This object becomes the input channel.
Definition at line 478 of file channels.h.
Referenced by elementa::base::serch_transfer< SerChIO_Memory, SerChIO_Memory >().
| class elementa::base::SerChI_Memory |
Input + output ser. chan. associated to a pre-allocated region of memory.
Allow to access a memory region through the serial channel paradigm. That memory can be provided by containers such as std::vector, std::array or std::string.
This class is not thread-safe.
Definition at line 525 of file channels.h.


Public Member Functions | |
| template<typename T > | |
| SerChI_Memory (const void *begin, T n) noexcept | |
| Template constructor. More... | |
| SerChI_Memory (const std::string &str, std::string::size_type offbegin=0, std::string::size_type offend=0) | |
| Constructor for a region within a string. More... | |
| template<typename T > | |
| SerChI_Memory (const std::vector< T > &v, typename std::vector< T >::size_type offbegin=0, typename std::vector< T >::size_type offend=0) | |
| Template constructor for a region within a std::vector. More... | |
| template<typename T , std::size_t N> | |
| SerChI_Memory (const std::array< T, N > &a, typename std::array< T, N >::size_type offbegin=0, typename std::array< T, N >::size_type offend=0) | |
| Template constructor for a region within a std::array. More... | |
| SerChI_Memory (const SerChI_Memory &)=delete | |
| SerChI_Memory (SerChI_Memory &&)=delete | |
| SerChI_Memory & | operator= (SerChI_Memory &)=delete |
| SerChI_Memory & | operator= (SerChI_Memory &&)=delete |
| void | reset (void) |
| Reset the channel to its initial position and state. | |
| SerChSize | transfer (SerChIO_Memory &chout, SerChSize count=0) |
| Specialized version of serch_transfer when both channels are of memory. More... | |
| elementa::base::SerChI_Memory::SerChI_Memory | ( | const std::string & | str, |
| std::string::size_type | offbegin = 0, |
||
| std::string::size_type | offend = 0 |
||
| ) |
Constructor for a region within a string.
| offbegin | is the offset from the beginning. |
| offend | is the offset from the ending backwards. |
|
inline |
Specialized version of serch_transfer when both channels are of memory.
This object becomes the input channel.
Definition at line 576 of file channels.h.
Referenced by elementa::base::serch_transfer< SerChI_Memory, SerChIO_Memory >().
|
inline |
#include <elementa/base/serial_channels/channels.h>
Full specialization of serch_transfer for both channels being Memory.
Definition at line 495 of file channels.h.
References ELE_CODE_TRACE_OFF, elementa::base::serch_st_to_string(), and elementa::base::SerChIO_Memory::transfer().
|
inline |
#include <elementa/base/serial_channels/channels.h>
Full specialization of serch_transfer for both channels being Memory.
Definition at line 593 of file channels.h.
References ELE_CODE_TRACE_OFF, elementa::base::serch_st_to_string(), and elementa::base::SerChI_Memory::transfer().
|
noexcept |
#include <elementa/base/serial_channels/channels.h>
Template constructor.
| T | must be an integral type for indicating length. |
| begin | is a pointer to the first char in memory. Cannot be null. |
| n | is the number of chars stored there. Cannot be <= 0. |
Definition at line 622 of file channels.h.
| elementa::base::SerChIO_Memory::SerChIO_Memory | ( | std::vector< T > & | v, |
| typename std::vector< T >::size_type | offbegin = 0, |
||
| typename std::vector< T >::size_type | offend = 0 |
||
| ) |
#include <elementa/base/serial_channels/channels.h>
Template constructor for a region within a std::vector.
| T | is the type of element of the vector; this constructor will define the region as a number of such elements, but will deal with them as bytes. |
| offbegin | is the first element in the vector to use by the channel. |
| offend | is the offset from the ending, backwards, where the channel ends having data. |
Definition at line 635 of file channels.h.
References ELE_CODE_INVARG, and elementa::base::SerChIO_Memory::reset().
| elementa::base::SerChIO_Memory::SerChIO_Memory | ( | std::array< T, N > & | a, |
| typename std::array< T, N >::size_type | offbegin = 0, |
||
| typename std::array< T, N >::size_type | offend = 0 |
||
| ) |
#include <elementa/base/serial_channels/channels.h>
Template constructor for a region within a std::array.
| T | is the type of element of the vector; this constructor will define the region as a number of such elements, but will deal with them as bytes. |
| offbegin | is the first element in the vector to use by the channel. |
| offend | is the offset from the ending, backwards, where the channel ends having data. |
Definition at line 652 of file channels.h.
References ELE_CODE_INVARG, and elementa::base::SerChIO_Memory::reset().
|
noexcept |
#include <elementa/base/serial_channels/channels.h>
Template constructor.
| T | must be an integral type for indicating length. |
| begin | is a pointer to the first char in memory. Cannot be null. |
| n | is the number of chars stored there. Cannot be <= 0. |
Definition at line 676 of file channels.h.
| elementa::base::SerChI_Memory::SerChI_Memory | ( | const std::vector< T > & | v, |
| typename std::vector< T >::size_type | offbegin = 0, |
||
| typename std::vector< T >::size_type | offend = 0 |
||
| ) |
#include <elementa/base/serial_channels/channels.h>
Template constructor for a region within a std::vector.
| T | is the type of element of the vector; this constructor will define the region as a number of such elements, but will deal with them as bytes. |
| offbegin | is the first element in the vector to use. |
| offend | is the offset from the ending, backwards. |
Definition at line 689 of file channels.h.
References ELE_CODE_INVARG, and elementa::base::SerChI_Memory::reset().
| elementa::base::SerChI_Memory::SerChI_Memory | ( | const std::array< T, N > & | a, |
| typename std::array< T, N >::size_type | offbegin = 0, |
||
| typename std::array< T, N >::size_type | offend = 0 |
||
| ) |
#include <elementa/base/serial_channels/channels.h>
Template constructor for a region within a std::array.
| T | is the type of element of the vector; this constructor will define the region as a number of such elements, but will deal with them as bytes. |
| offbegin | is the first element in the vector to use. |
| offend | is the offset from the ending, backwards. |
Definition at line 707 of file channels.h.
References ELE_CODE_INVARG, and elementa::base::SerChI_Memory::reset().