![]() |
Elementa v8.0.0
Minimalistic library for any C++ application (C++11 and up)
|
Basic definitions for serial channels.
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):
\code std::ios_base::iostate rdstate(void) const; // Read complete state, all bits. // Non-virtually declared in ios, base of istream/ostream/iostream, // which inherits it without modifying -hiding- it with new // implementations. \endcode \code void setstate(std::ios_base::iostate st); // Set complete state, all bits, to the current state OR the one ST. // Non-virtually declared in ios, base of istream/ostream/iostream, // which inherits it without modifying -hiding- it with new // implementations. \endcode \code void clear(); // Set complete state, all bits, to a good state (no error). // Non-virtually declared in ios, base of istream/ostream/iostream, // which inherits it without modifying -hiding- it with new // implementations. \endcode \code bool good(void) const; // Whether the channel is ok and working. // Non-virtually declared in ios, base of istream/ostream/iostream, // which inherits it without modifying -hiding- it with new // implementations. \endcode \code bool fail(void) const; // Whether there has been any logical error. // Non-virtually declared in ios, base of istream/ostream/iostream, // which inherits it without modifying -hiding- it with new // implementations. \endcode \code bool bad(void) const; // Whether there has been any error in an I/O operation. // Non-virtually declared in ios, base of istream/ostream/iostream, // which inherits it without modifying -hiding- it with new // implementations. \endcode \code bool eof(void) const; // Whether the channel is exhausted. NOTE: THIS FLAG IS SET ONLY // IF THE CHANNEL IS TRYING TO GET A CHAR WHEN NONE EXISTS, E.G., // AFTER READING THE LAST CHAR OF THE CHANNEL, EOF() IS NOT YET SET. // Non-virtually declared in ios, base of istream/ostream/iostream, // which inherits it without modifying -hiding- it with new // implementations. \endcode \code explicit operator bool(void) const; // True if channel ok and working. // Non-virtually declared in basic_ios, being istream/ostream/ // iostream instantiations of that template, thus // having it without modification. \endcode \code bool operator!(void) const; // True if channel is not ok. // Non-virtually declared in basic_ios, being istream/ostream/ // iostream instantiations of that template, thus // having it without modification. \endcode

Classes | |
| class | elementa::base::is_InSerCh< T > |
| With this template you can check whether T is an input serial channel. More... | |
| class | elementa::base::is_In_InOut_SerCh< T > |
| With this template you can check whether T is an input or inout channel. More... | |
| class | elementa::base::is_OutSerCh< T > |
| With this template you can check whether T is an output serial channel. More... | |
| class | elementa::base::is_Out_InOut_SerCh< T > |
| With this template you can check whether T is an output or inout channel. More... | |
| class | elementa::base::is_InOutSerCh< T > |
| With this template you can check whether T is an in + out serial channel. More... | |
| class | elementa::base::is_SerCh< T > |
| With this template you can check whether T is any kind of serial channel. More... | |
| class | elementa::base::SerChError |
| Base class for exceptions associated to some serial channel operation. More... | |
| class | elementa::base::SerChErr_Exhausted |
| Error to throw when the channel is exhausted but it should not be. More... | |
| class | elementa::base::SerChErr_FewData |
| Error to throw when the channel provides less data than it should on read() More... | |
| class | elementa::base::SerChErr_TooManyData |
| Error to throw when the channel does not admit too many data. More... | |
| class | elementa::base::SerChErr_State |
| Errors thrown by serch_isgood and other functions. More... | |
| class | elementa::base::SerChErr_Unopened |
| Errors thrown by channels that must be opened. More... | |
| class | elementa::base::SerChErr_Loc |
| Errors related to locations on channels. More... | |
| class | elementa::base::SerChErr_Cont |
| Errors related to container-based channels. More... | |
| class | elementa::base::SerChLoc |
| Location in a channel, at least in linear form, either at reading or writing. More... | |
| class | elementa::base::SerChLocText |
| A location into a text channel consisting of a row and a column. More... | |
Typedefs | |
| using | elementa::base::SerChSize = std::streamsize |
| Type of the size of any channel. More... | |
| using | elementa::base::SerChDatum = std::streambuf::int_type |
| Type that can hold either a char or eof. More... | |
| using | elementa::base::SerChCharTraits = std::char_traits< char > |
| To have access to the methods of char_traits corresponding to these channs. More... | |
| using | elementa::base::RootSerCh = std::ios |
| Class that is at the root of any serial channel in Elementa. More... | |
| using | elementa::base::OutSerCh = std::ostream |
| "Base class" that represents any output serial channel in Elementa. More... | |
| using | elementa::base::InSerCh = std::istream |
| "Base class" that represents any input serial channel in Elementa. More... | |
| using | elementa::base::InOutSerCh = std::iostream |
| "Base class" that represents any input + output serial channel in Elementa. More... | |
Functions | |
| void | elementa::base::serch_isgood (RootSerCh &serchconst, const std::string &place="", const RTTextWithEnum::Combination &flags={RTTextWith::kAll_}) |
| Throw an exception if the channel is not good; do nothing otherwise. More... | |
| bool | elementa::base::serch_iseofbutok (RootSerCh &serchconst, const std::string &place="", const RTTextWithEnum::Combination &flags={RTTextWith::kAll_}) |
| Return TRUE if the channel is eof() (maybe bad/fail); throw if !eof nor good. More... | |
| bool | elementa::base::serch_isexhausted (InSerCh &serch, const std::string &place="", const RTTextWithEnum::Combination &flags={RTTextWith::kAll_}) |
| Return TRUE if it is eof or exhausted; then throw if the channel is bad/fail. More... | |
| void | elementa::base::serch_hasreadN (InSerCh &chin, char *dest, SerChSize n, const std::string &place="", const RTTextWithEnum::Combination &flags={RTTextWith::kAll_}) |
| Make sure that N chars are read from CHIN; throws if any error. | |
| void | elementa::base::serch_haswrittenN (OutSerCh &chout, const char *org, SerChSize n, const std::string &place="", const RTTextWithEnum::Combination &flags={RTTextWith::kAll_}) |
| Make sure that N chars are written to CHOUT; throws if any error. | |
| std::string | elementa::base::serch_st_to_string (std::ios_base::iostate st) noexcept |
| Converts an io state into a string. More... | |
| std::string | elementa::base::serch_st_to_string (RootSerCh &ch) noexcept |
| Converts the state of a serial channel into a string. More... | |
| std::ios_base::iostate | elementa::base::serch_copy_st (RootSerCh &chorg, RootSerCh &chdest) |
| Copy the state of CHORG into DEST, returning that state. | |
| template<class SCOrg , class SCDest > | |
| SerChSize | elementa::base::serch_transfer (SCOrg &chin, SCDest &chout, SerChSize count=0) |
| Write COUNT items read from channel CHIN into channel CHOUT. More... | |
| template<class SCOrg , class SCDest > | |
| SerChSize | elementa::base::serch_transfer (SCOrg &&chin, SCDest &&chout, SerChSize count=1) |
| Version of serch_transfer for using rvalues (but without moving then). More... | |
Variables | |
| constexpr SerChDatum | elementa::base::kSerChEOF = std::streambuf::traits_type::eof() |
| Const that holds the eof value. More... | |
| class elementa::base::is_InSerCh |
With this template you can check whether T is an input serial channel.
Static Public Attributes | |
| static constexpr bool | value |
|
staticconstexpr |
| class elementa::base::is_In_InOut_SerCh |
With this template you can check whether T is an input or inout channel.
Static Public Attributes | |
| static constexpr bool | value |
|
staticconstexpr |
| class elementa::base::is_OutSerCh |
With this template you can check whether T is an output serial channel.
Static Public Attributes | |
| static constexpr bool | value |
|
staticconstexpr |
| class elementa::base::is_Out_InOut_SerCh |
With this template you can check whether T is an output or inout channel.
Static Public Attributes | |
| static constexpr bool | value |
|
staticconstexpr |
| class elementa::base::is_InOutSerCh |
With this template you can check whether T is an in + out serial channel.
Static Public Attributes | |
| static constexpr bool | value |
|
staticconstexpr |
| class elementa::base::is_SerCh |
With this template you can check whether T is any kind of serial channel.
Static Public Attributes | |
| static constexpr bool | value |
|
staticconstexpr |
| class elementa::base::SerChError |
Base class for exceptions associated to some serial channel operation.


Public Types | |
Types, consts., etc. | |
| using | StdBase = std::runtime_error |
Public Member Functions | |
| SerChError (const std::string &explanation) | |
| ELE_CLASS_EXCOVERRIDE (SerChError) | |
Launching methods | |
| virtual Exc & | asERR (const std::string &context) noexcept |
| Transform it to be thrown as ERR with the given context. More... | |
| virtual Exc & | asEXC (const std::string &place, const RTTextWithEnum::Combination &flags={RTTextWith::kAll_}) noexcept |
| Transform it to be thrown as EXC with the given place and flags. More... | |
Catching methods | |
| const char * | what (void) const noexcept override |
| Return the complete message. It will live as long as this exception. More... | |
| const char * | explanation (void) const noexcept |
| Return the explanation only. It will live as long as this exception. More... | |
| const char * | context (void) const noexcept |
| Return the place (EXC) or context (ERR) only. Will live as long as this. More... | |
|
inherited |
Definition at line 119 of file exceptions.h.
|
inline |
|
virtualnoexceptinherited |
Transform it to be thrown as ERR with the given context.
Reimplemented in elementa::base::unimplemented, elementa::base::todo, elementa::base::notreach, elementa::base::invstate, elementa::base::internal_error, elementa::base::notfound, elementa::base::invarg, and elementa::base::outofrange.
|
virtualnoexceptinherited |
Transform it to be thrown as EXC with the given place and flags.
The flags are explained in debugging.h, runtime_src_place() function.
Referenced by elementa::base::Szer_Char::deser(), and elementa::base::Szer_NatBin< NatType >::deser().
|
inlineoverridenoexceptinherited |
Return the complete message. It will live as long as this exception.
The message will be one-line except if the explanation or place/context contain some CR.
Definition at line 161 of file exceptions.h.
|
inlinenoexceptinherited |
Return the explanation only. It will live as long as this exception.
Definition at line 164 of file exceptions.h.
|
inlinenoexceptinherited |
Return the place (EXC) or context (ERR) only. Will live as long as this.
Definition at line 167 of file exceptions.h.
| class elementa::base::SerChErr_Exhausted |
Error to throw when the channel is exhausted but it should not be.


Public Types | |
Types, consts., etc. | |
| using | StdBase = std::runtime_error |
Public Member Functions | |
| SerChErr_Exhausted (const std::string &explanation) | |
| ELE_CLASS_EXCOVERRIDE (SerChErr_Exhausted) | |
| ELE_CLASS_EXCOVERRIDE (SerChError) | |
Launching methods | |
| virtual Exc & | asERR (const std::string &context) noexcept |
| Transform it to be thrown as ERR with the given context. More... | |
| virtual Exc & | asEXC (const std::string &place, const RTTextWithEnum::Combination &flags={RTTextWith::kAll_}) noexcept |
| Transform it to be thrown as EXC with the given place and flags. More... | |
Catching methods | |
| const char * | what (void) const noexcept override |
| Return the complete message. It will live as long as this exception. More... | |
| const char * | explanation (void) const noexcept |
| Return the explanation only. It will live as long as this exception. More... | |
| const char * | context (void) const noexcept |
| Return the place (EXC) or context (ERR) only. Will live as long as this. More... | |
|
inherited |
Definition at line 119 of file exceptions.h.
|
inline |
|
virtualnoexceptinherited |
Transform it to be thrown as ERR with the given context.
Reimplemented in elementa::base::unimplemented, elementa::base::todo, elementa::base::notreach, elementa::base::invstate, elementa::base::internal_error, elementa::base::notfound, elementa::base::invarg, and elementa::base::outofrange.
|
virtualnoexceptinherited |
Transform it to be thrown as EXC with the given place and flags.
The flags are explained in debugging.h, runtime_src_place() function.
Referenced by elementa::base::Szer_Char::deser(), and elementa::base::Szer_NatBin< NatType >::deser().
|
inlineoverridenoexceptinherited |
Return the complete message. It will live as long as this exception.
The message will be one-line except if the explanation or place/context contain some CR.
Definition at line 161 of file exceptions.h.
|
inlinenoexceptinherited |
Return the explanation only. It will live as long as this exception.
Definition at line 164 of file exceptions.h.
|
inlinenoexceptinherited |
Return the place (EXC) or context (ERR) only. Will live as long as this.
Definition at line 167 of file exceptions.h.
| class elementa::base::SerChErr_FewData |
Error to throw when the channel provides less data than it should on read()


Public Types | |
Types, consts., etc. | |
| using | StdBase = std::runtime_error |
Public Member Functions | |
| SerChErr_FewData (const std::string &explanation) | |
| ELE_CLASS_EXCOVERRIDE (SerChError) | |
Launching methods | |
| virtual Exc & | asERR (const std::string &context) noexcept |
| Transform it to be thrown as ERR with the given context. More... | |
| virtual Exc & | asEXC (const std::string &place, const RTTextWithEnum::Combination &flags={RTTextWith::kAll_}) noexcept |
| Transform it to be thrown as EXC with the given place and flags. More... | |
Catching methods | |
| const char * | what (void) const noexcept override |
| Return the complete message. It will live as long as this exception. More... | |
| const char * | explanation (void) const noexcept |
| Return the explanation only. It will live as long as this exception. More... | |
| const char * | context (void) const noexcept |
| Return the place (EXC) or context (ERR) only. Will live as long as this. More... | |
|
inherited |
Definition at line 119 of file exceptions.h.
|
inline |
|
virtualnoexceptinherited |
Transform it to be thrown as ERR with the given context.
Reimplemented in elementa::base::unimplemented, elementa::base::todo, elementa::base::notreach, elementa::base::invstate, elementa::base::internal_error, elementa::base::notfound, elementa::base::invarg, and elementa::base::outofrange.
|
virtualnoexceptinherited |
Transform it to be thrown as EXC with the given place and flags.
The flags are explained in debugging.h, runtime_src_place() function.
Referenced by elementa::base::Szer_Char::deser(), and elementa::base::Szer_NatBin< NatType >::deser().
|
inlineoverridenoexceptinherited |
Return the complete message. It will live as long as this exception.
The message will be one-line except if the explanation or place/context contain some CR.
Definition at line 161 of file exceptions.h.
|
inlinenoexceptinherited |
Return the explanation only. It will live as long as this exception.
Definition at line 164 of file exceptions.h.
|
inlinenoexceptinherited |
Return the place (EXC) or context (ERR) only. Will live as long as this.
Definition at line 167 of file exceptions.h.
| class elementa::base::SerChErr_TooManyData |
Error to throw when the channel does not admit too many data.


Public Types | |
Types, consts., etc. | |
| using | StdBase = std::runtime_error |
Public Member Functions | |
| SerChErr_TooManyData (const std::string &explanation) | |
| ELE_CLASS_EXCOVERRIDE (SerChError) | |
Launching methods | |
| virtual Exc & | asERR (const std::string &context) noexcept |
| Transform it to be thrown as ERR with the given context. More... | |
| virtual Exc & | asEXC (const std::string &place, const RTTextWithEnum::Combination &flags={RTTextWith::kAll_}) noexcept |
| Transform it to be thrown as EXC with the given place and flags. More... | |
Catching methods | |
| const char * | what (void) const noexcept override |
| Return the complete message. It will live as long as this exception. More... | |
| const char * | explanation (void) const noexcept |
| Return the explanation only. It will live as long as this exception. More... | |
| const char * | context (void) const noexcept |
| Return the place (EXC) or context (ERR) only. Will live as long as this. More... | |
|
inherited |
Definition at line 119 of file exceptions.h.
|
inline |
|
virtualnoexceptinherited |
Transform it to be thrown as ERR with the given context.
Reimplemented in elementa::base::unimplemented, elementa::base::todo, elementa::base::notreach, elementa::base::invstate, elementa::base::internal_error, elementa::base::notfound, elementa::base::invarg, and elementa::base::outofrange.
|
virtualnoexceptinherited |
Transform it to be thrown as EXC with the given place and flags.
The flags are explained in debugging.h, runtime_src_place() function.
Referenced by elementa::base::Szer_Char::deser(), and elementa::base::Szer_NatBin< NatType >::deser().
|
inlineoverridenoexceptinherited |
Return the complete message. It will live as long as this exception.
The message will be one-line except if the explanation or place/context contain some CR.
Definition at line 161 of file exceptions.h.
|
inlinenoexceptinherited |
Return the explanation only. It will live as long as this exception.
Definition at line 164 of file exceptions.h.
|
inlinenoexceptinherited |
Return the place (EXC) or context (ERR) only. Will live as long as this.
Definition at line 167 of file exceptions.h.
| class elementa::base::SerChErr_State |


Public Types | |
Types, consts., etc. | |
| using | StdBase = std::runtime_error |
Public Member Functions | |
| SerChErr_State (const std::string &explanation) | |
| ELE_CLASS_EXCOVERRIDE (SerChError) | |
Launching methods | |
| virtual Exc & | asERR (const std::string &context) noexcept |
| Transform it to be thrown as ERR with the given context. More... | |
| virtual Exc & | asEXC (const std::string &place, const RTTextWithEnum::Combination &flags={RTTextWith::kAll_}) noexcept |
| Transform it to be thrown as EXC with the given place and flags. More... | |
Catching methods | |
| const char * | what (void) const noexcept override |
| Return the complete message. It will live as long as this exception. More... | |
| const char * | explanation (void) const noexcept |
| Return the explanation only. It will live as long as this exception. More... | |
| const char * | context (void) const noexcept |
| Return the place (EXC) or context (ERR) only. Will live as long as this. More... | |
|
inherited |
Definition at line 119 of file exceptions.h.
|
inline |
|
virtualnoexceptinherited |
Transform it to be thrown as ERR with the given context.
Reimplemented in elementa::base::unimplemented, elementa::base::todo, elementa::base::notreach, elementa::base::invstate, elementa::base::internal_error, elementa::base::notfound, elementa::base::invarg, and elementa::base::outofrange.
|
virtualnoexceptinherited |
Transform it to be thrown as EXC with the given place and flags.
The flags are explained in debugging.h, runtime_src_place() function.
Referenced by elementa::base::Szer_Char::deser(), and elementa::base::Szer_NatBin< NatType >::deser().
|
inlineoverridenoexceptinherited |
Return the complete message. It will live as long as this exception.
The message will be one-line except if the explanation or place/context contain some CR.
Definition at line 161 of file exceptions.h.
|
inlinenoexceptinherited |
Return the explanation only. It will live as long as this exception.
Definition at line 164 of file exceptions.h.
|
inlinenoexceptinherited |
Return the place (EXC) or context (ERR) only. Will live as long as this.
Definition at line 167 of file exceptions.h.
| class elementa::base::SerChErr_Unopened |


Public Types | |
Types, consts., etc. | |
| using | StdBase = std::runtime_error |
Public Member Functions | |
| SerChErr_Unopened (const std::string &explanation) | |
| ELE_CLASS_EXCOVERRIDE (SerChError) | |
Launching methods | |
| virtual Exc & | asERR (const std::string &context) noexcept |
| Transform it to be thrown as ERR with the given context. More... | |
| virtual Exc & | asEXC (const std::string &place, const RTTextWithEnum::Combination &flags={RTTextWith::kAll_}) noexcept |
| Transform it to be thrown as EXC with the given place and flags. More... | |
Catching methods | |
| const char * | what (void) const noexcept override |
| Return the complete message. It will live as long as this exception. More... | |
| const char * | explanation (void) const noexcept |
| Return the explanation only. It will live as long as this exception. More... | |
| const char * | context (void) const noexcept |
| Return the place (EXC) or context (ERR) only. Will live as long as this. More... | |
|
inherited |
Definition at line 119 of file exceptions.h.
|
inline |
|
virtualnoexceptinherited |
Transform it to be thrown as ERR with the given context.
Reimplemented in elementa::base::unimplemented, elementa::base::todo, elementa::base::notreach, elementa::base::invstate, elementa::base::internal_error, elementa::base::notfound, elementa::base::invarg, and elementa::base::outofrange.
|
virtualnoexceptinherited |
Transform it to be thrown as EXC with the given place and flags.
The flags are explained in debugging.h, runtime_src_place() function.
Referenced by elementa::base::Szer_Char::deser(), and elementa::base::Szer_NatBin< NatType >::deser().
|
inlineoverridenoexceptinherited |
Return the complete message. It will live as long as this exception.
The message will be one-line except if the explanation or place/context contain some CR.
Definition at line 161 of file exceptions.h.
|
inlinenoexceptinherited |
Return the explanation only. It will live as long as this exception.
Definition at line 164 of file exceptions.h.
|
inlinenoexceptinherited |
Return the place (EXC) or context (ERR) only. Will live as long as this.
Definition at line 167 of file exceptions.h.
| class elementa::base::SerChErr_Loc |


Public Types | |
Types, consts., etc. | |
| using | StdBase = std::runtime_error |
Public Member Functions | |
| SerChErr_Loc (const std::string &explanation) | |
| ELE_CLASS_EXCOVERRIDE (SerChError) | |
Launching methods | |
| virtual Exc & | asERR (const std::string &context) noexcept |
| Transform it to be thrown as ERR with the given context. More... | |
| virtual Exc & | asEXC (const std::string &place, const RTTextWithEnum::Combination &flags={RTTextWith::kAll_}) noexcept |
| Transform it to be thrown as EXC with the given place and flags. More... | |
Catching methods | |
| const char * | what (void) const noexcept override |
| Return the complete message. It will live as long as this exception. More... | |
| const char * | explanation (void) const noexcept |
| Return the explanation only. It will live as long as this exception. More... | |
| const char * | context (void) const noexcept |
| Return the place (EXC) or context (ERR) only. Will live as long as this. More... | |
|
inherited |
Definition at line 119 of file exceptions.h.
|
inline |
|
virtualnoexceptinherited |
Transform it to be thrown as ERR with the given context.
Reimplemented in elementa::base::unimplemented, elementa::base::todo, elementa::base::notreach, elementa::base::invstate, elementa::base::internal_error, elementa::base::notfound, elementa::base::invarg, and elementa::base::outofrange.
|
virtualnoexceptinherited |
Transform it to be thrown as EXC with the given place and flags.
The flags are explained in debugging.h, runtime_src_place() function.
Referenced by elementa::base::Szer_Char::deser(), and elementa::base::Szer_NatBin< NatType >::deser().
|
inlineoverridenoexceptinherited |
Return the complete message. It will live as long as this exception.
The message will be one-line except if the explanation or place/context contain some CR.
Definition at line 161 of file exceptions.h.
|
inlinenoexceptinherited |
Return the explanation only. It will live as long as this exception.
Definition at line 164 of file exceptions.h.
|
inlinenoexceptinherited |
Return the place (EXC) or context (ERR) only. Will live as long as this.
Definition at line 167 of file exceptions.h.
| class elementa::base::SerChErr_Cont |


Public Types | |
Types, consts., etc. | |
| using | StdBase = std::runtime_error |
Public Member Functions | |
| SerChErr_Cont (const std::string &explanation) | |
| ELE_CLASS_EXCOVERRIDE (SerChError) | |
Launching methods | |
| virtual Exc & | asERR (const std::string &context) noexcept |
| Transform it to be thrown as ERR with the given context. More... | |
| virtual Exc & | asEXC (const std::string &place, const RTTextWithEnum::Combination &flags={RTTextWith::kAll_}) noexcept |
| Transform it to be thrown as EXC with the given place and flags. More... | |
Catching methods | |
| const char * | what (void) const noexcept override |
| Return the complete message. It will live as long as this exception. More... | |
| const char * | explanation (void) const noexcept |
| Return the explanation only. It will live as long as this exception. More... | |
| const char * | context (void) const noexcept |
| Return the place (EXC) or context (ERR) only. Will live as long as this. More... | |
|
inherited |
Definition at line 119 of file exceptions.h.
|
inline |
|
virtualnoexceptinherited |
Transform it to be thrown as ERR with the given context.
Reimplemented in elementa::base::unimplemented, elementa::base::todo, elementa::base::notreach, elementa::base::invstate, elementa::base::internal_error, elementa::base::notfound, elementa::base::invarg, and elementa::base::outofrange.
|
virtualnoexceptinherited |
Transform it to be thrown as EXC with the given place and flags.
The flags are explained in debugging.h, runtime_src_place() function.
Referenced by elementa::base::Szer_Char::deser(), and elementa::base::Szer_NatBin< NatType >::deser().
|
inlineoverridenoexceptinherited |
Return the complete message. It will live as long as this exception.
The message will be one-line except if the explanation or place/context contain some CR.
Definition at line 161 of file exceptions.h.
|
inlinenoexceptinherited |
Return the explanation only. It will live as long as this exception.
Definition at line 164 of file exceptions.h.
|
inlinenoexceptinherited |
Return the place (EXC) or context (ERR) only. Will live as long as this.
Definition at line 167 of file exceptions.h.
| class elementa::base::SerChLoc |
Location in a channel, at least in linear form, either at reading or writing.
This class implements locations that can be both incremented and decremented. The location always points to the next character to read/write in the channel. This class can be derived to provided more sophisticated locations (rather than simply linear), as, e.g., in the SerChLocText class.


Public Types | |
Types, consts, etc. | |
| using | Ptr = std::shared_ptr< SerChLoc > |
| Safe pointer for polymorphic behaviours. More... | |
Public Member Functions | |
| virtual Clonable * | emptyClone (void) const |
| Derived classes can override this to provide a clone that is "empty". More... | |
Constructors | |
| SerChLoc (void) noexcept | |
| Default constructor: establish 0 as the current location in the channel. More... | |
| SerChLoc (const SerChLoc &oth) | |
| Copy constructor: the stored value is cleared. More... | |
| SerChLoc & | operator= (const SerChLoc &oth) |
| Copy assignment: the stored value is cleared. More... | |
| SerChLoc (SerChLoc &&oth) | |
| Move constructor: the stored value of OTH is moved to this. More... | |
| SerChLoc & | operator= (SerChLoc &&oth) |
| Move assignment: the stored value of OTH is moved to this. More... | |
| virtual | ~SerChLoc (void) |
| Destructor. More... | |
Methods that can be overriden | |
| virtual SerChLoc * | clone (void) const |
| Clone the location. More... | |
| virtual void | reset (void) noexcept |
| Reset the location to the beginning. More... | |
| virtual void | inc (char c=' ') |
| Increment the location after reading/writing char C. More... | |
| virtual void | inc (const char *t, SerChSize n) |
| Increment the location after reading/writing a block T of N chars. More... | |
| virtual void | dec (char c) |
| Decrement the location after un-reading/un-writing char C. More... | |
| virtual void | dec (const char *t, SerChSize n) |
| Decrement the location after un-reading/un-writing a block T of N chars. More... | |
| virtual bool | operator== (const SerChLoc &o) const |
| Equality. More... | |
| virtual bool | operator!= (const SerChLoc &o) const |
| Unequality. More... | |
| virtual std::string | to_string (bool compact=false) const noexcept |
| Convert the location to a string. More... | |
Getters | |
| SerChSize | linear (void) const noexcept |
| Get the current location. More... | |
| using elementa::base::SerChLoc::Ptr = std::shared_ptr<SerChLoc> |
|
inlinenoexcept |
|
inline |
|
inline |
|
inlinevirtual |
|
inlinenoexcept |
|
inlinevirtual |
Clone the location.
Implements elementa::patterns::Clonable.
Reimplemented in elementa::base::SerChLocText.
|
inlinevirtualnoexcept |
Reset the location to the beginning.
Reimplemented in elementa::base::SerChLocText.
Definition at line 824 of file basics.h.
Referenced by SerChLoc().
|
inlinevirtual |
Increment the location after reading/writing char C.
Virtual for derived classes to enrich this behavior.
Reimplemented in elementa::base::SerChLocText.
|
inlinevirtual |
Increment the location after reading/writing a block T of N chars.
Virtual for derived classes to enrich this behavior.
Reimplemented in elementa::base::SerChLocText.
|
virtual |
Decrement the location after un-reading/un-writing char C.
Throw if that decrement is not possible according to the current location value.
Reimplemented in elementa::base::SerChLocText.
|
virtual |
Decrement the location after un-reading/un-writing a block T of N chars.
Throw if that decrement is not possible according to the current location value.
Reimplemented in elementa::base::SerChLocText.
|
inlinevirtual |
|
inlinevirtual |
|
virtualnoexcept |
Convert the location to a string.
If COMPACT == TRUE, return an equal or shorter string.
Reimplemented in elementa::base::SerChLocText.
|
inlinevirtualinherited |
Derived classes can override this to provide a clone that is "empty".
"Emptiness" here means that the clone is not actually a clone of the derived object, but a new object of the same class of the derived object, without no content (i.e., right after creation).
Reimplemented in elementa::adts::graphs::SparseGraph< Vertex, Edge >.
Definition at line 93 of file clonable.h.
References ELE_CODE_UNIMPLEMENTED.
| class elementa::base::SerChLocText |
A location into a text channel consisting of a row and a column.


Public Types | |
Types, consts, etc. | |
| using | Ptr = std::shared_ptr< SerChLoc > |
| Safe pointer for polymorphic behaviours. More... | |
Public Member Functions | |
| SerChLocText (char endofline='\n') noexcept | |
| Default constructor: location pointing to the 1st character of the text. More... | |
| SerChLocText (const SerChLocText &oth) | |
| Copy constructor: the stored value is cleared. More... | |
| SerChLocText & | operator= (const SerChLocText &oth) |
| Copy assignment: the stored value is cleared. More... | |
| SerChLocText (SerChLocText &&oth) | |
| Move constructor: the stored value of OTH is moved to this. More... | |
| SerChLocText & | operator= (SerChLocText &&oth) |
| Move assignment: the stored value of OTH is moved to this. More... | |
| virtual | ~SerChLocText (void) |
| Destructor. More... | |
| SerChSize | row (void) const noexcept |
| Get current row. More... | |
| SerChSize | column (void) const noexcept |
| Get current column. More... | |
| SerChLocText * | clone (void) const |
| Clone the location. More... | |
| void | reset (void) noexcept override |
| Reset the location to the beginning. More... | |
| void | inc (char c) override |
| Increment the location after reading/writing char C. More... | |
| void | inc (const char *t, SerChSize n) override |
| Increment the location after reading/writing a block T of N chars. More... | |
| void | dec (char c) override |
| Decrement the location after un-reading/un-writing char C. More... | |
| void | dec (const char *t, SerChSize n) override |
| Decrement the location after un-reading/un-writing a block T of N chars. More... | |
| bool | operator== (const SerChLocText &o) |
| bool | operator!= (const SerChLocText &o) |
| bool | operator== (const SerChLoc &o) const override |
| Equality. More... | |
| bool | operator!= (const SerChLoc &o) const override |
| Unequality. More... | |
| std::string | to_string (bool compact=false) const noexcept override |
| Convert the location to a string. More... | |
| virtual Clonable * | emptyClone (void) const |
| Derived classes can override this to provide a clone that is "empty". More... | |
Getters | |
| SerChSize | linear (void) const noexcept |
| Get the current location. More... | |
|
inherited |
|
inlinenoexcept |
|
inline |
|
inline |
|
inlinevirtual |
|
inline |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinevirtual |
Clone the location.
Reimplemented from elementa::base::SerChLoc.
|
overridevirtualnoexcept |
Reset the location to the beginning.
Reimplemented from elementa::base::SerChLoc.
|
overridevirtual |
Increment the location after reading/writing char C.
Virtual for derived classes to enrich this behavior.
Reimplemented from elementa::base::SerChLoc.
|
overridevirtual |
Increment the location after reading/writing a block T of N chars.
Virtual for derived classes to enrich this behavior.
Reimplemented from elementa::base::SerChLoc.
|
overridevirtual |
Decrement the location after un-reading/un-writing char C.
Throw if that decrement is not possible according to the current location value.
Reimplemented from elementa::base::SerChLoc.
|
overridevirtual |
Decrement the location after un-reading/un-writing a block T of N chars.
Throw if that decrement is not possible according to the current location value.
Reimplemented from elementa::base::SerChLoc.
|
inline |
|
inline |
|
inlineoverridevirtual |
|
inlineoverridevirtual |
|
overridevirtualnoexcept |
Convert the location to a string.
If COMPACT == TRUE, return an equal or shorter string.
Reimplemented from elementa::base::SerChLoc.
|
inlinenoexceptinherited |
|
inlinevirtualinherited |
Derived classes can override this to provide a clone that is "empty".
"Emptiness" here means that the clone is not actually a clone of the derived object, but a new object of the same class of the derived object, without no content (i.e., right after creation).
Reimplemented in elementa::adts::graphs::SparseGraph< Vertex, Edge >.
Definition at line 93 of file clonable.h.
References ELE_CODE_UNIMPLEMENTED.
| using elementa::base::SerChSize = typedef std::streamsize |
#include <elementa/base/serial_channels/basics.h>
Type of the size of any channel.
| using elementa::base::SerChDatum = typedef std::streambuf::int_type |
#include <elementa/base/serial_channels/basics.h>
Type that can hold either a char or eof.
| using elementa::base::SerChCharTraits = typedef std::char_traits<char> |
#include <elementa/base/serial_channels/basics.h>
To have access to the methods of char_traits corresponding to these channs.
For instance: to_char_type, to_int_type to convert to/from char and SerChDatum.
| using elementa::base::RootSerCh = typedef std::ios |
#include <elementa/base/serial_channels/basics.h>
Class that is at the root of any serial channel in Elementa.
This class is a base of any serial channel, but it does not provide any input/output methods, only the ones related to error management, thus it should not be used, in general, as a polymorphic representation of a serial channel.
| using elementa::base::OutSerCh = typedef std::ostream |
#include <elementa/base/serial_channels/basics.h>
"Base class" that represents any output serial channel in Elementa.
The use of this enables polymorphic use of both Elementa serial channels and STL channels (within the Elementa minimized functionality) indistinctly.
The functionality of any OutSerCh must be the following, stolen from STL:
\code OutSerCh & put(char c); // declared non-virtual in ostream // Write character c into the stream. // Errors: // eofbit must be set if the channel is exhausted after this put. // failbit must be set if, at calling, the channel has eofbit or badbit, or // in other circumstances depending on the channel (e.g., when a file // channel cannot open the file in the case of STL fstreams). // badbit must be set if writing the char fails for any reason. \endcode \code OutSerCh & write(const char* s, SerChSize n); // non-virtual in ostream // Inserts the first n characters of the array pointed by s into the stream. // Errors: // eofbit must be set if the channel is exhausted after this write. // failbit must be set if, at calling, the channel has eofbit or badbit, or // in other circumstances depending on the channel (e.g., when a file // channel cannot open the file in the case of STL fstreams). // badbit must be set if writing any of the chars fails for any reason. \endcode \code OutSerCh & flush(void); // declared non-virtual in ostream // If the channel has an internal buffer, this must write all of it to the // associated device; otherwise it must do nothing. // Errors: // failbit must be set if, at calling, the channel has eofbit or badbit. // badbit must be set if the synchronization operation failed. \endcode
| using elementa::base::InSerCh = typedef std::istream |
#include <elementa/base/serial_channels/basics.h>
"Base class" that represents any input serial channel in Elementa.
The use of this enables polymorphic use of both Elementa serial channels and STL channels (within the Elementa minimized functionality) indistinctly.
Its functionality must be the following, stolen from STL:
\code SerChDatum get(void); // non-virtually declared in istream // Get a single character and return either it or kSerChEOF if the last // char was already consumed previously. If a previous kSerChEOF was // returned, further kSerChEOF are returned indefinitely but the fail flag // will be set in addition to the eof flag in the channel. SerChDatum peek(void); // non-virtually declared in istream // Get a single character and return either it or kSerChEOF if the last // char was already consumed previously. The difference with get() is that // peek() does not consume the char itself (if any). If a previous kSerChEOF // was returned, further kSerChEOF are returned indefinitely but the fail // flag will be set in addition to the eof flag in the channel. InSerCh & get(char & c); // non-virtually declared in istream // Get a single character and store it into C, if available; if the channel // has no more chars, set both eof and fail and does not update C. // Errors in these methods: // eofbit is set AFTER a GET or a PEEK are done on an already exhausted ch. // failbit is set if the channel has eofbit or badbit already, or // in other circumstances depending on the channel (e.g., when a file // channel cannot open the file in the case of STL fstreams). // badbit is set if reading the char fails for other reasons. \endcode \code InSerCh & read(char* s, SerChSize n); // non-virtually declared in istream // Get up to N characters, storing them into S. Same behaviour as get(char&) \endcode \code SerChSize gcount(void) const; // non-virtually declared in istream // Return the number of chars actually read in the last reading operation. // No error is produced. Only the last operation is taken into account. \endcode \code InSerCh & putback(char c); // non-virtually declared in istream // Tries to put back character C in the stream in order to be the next one // to be read (not needed to be the same previously read). // NOTE: putback() is only intended to put back one char and never beyond // the beginning of the channel (if any); other uses might be ok or fail, // depending on the channel. // Errors: // eofbit is cleared after this call. // failbit is set if, at calling, the channel has eofbit or badbit, or // in other circumstances depending on the channel (e.g., when a file // channel cannot open the file in the case of STL fstreams). // badbit is set if the putback did not work. \endcode \code InSerCh & unget(void); // non-virtually declared in istream // The same as putback() but with using the last character that was got. \code int sync(void); // non-virtually declared in istream // If the channel has an internal buffer, this syncs the buffer with the // device, which, for example, can consists in clearing all unread content // of the buffer and discarding it (as it happens in std::cin.sync()). // Return 0 if success (or if nothing has to be done) and -1 if error. // Errors: // failbit is set if, at calling, the channel has eofbit or badbit. // badbit is set if the synchronization operation failed. \endcode
| using elementa::base::InOutSerCh = typedef std::iostream |
#include <elementa/base/serial_channels/basics.h>
"Base class" that represents any input + output serial channel in Elementa.
The use of this enables polymorphic use of both Elementa serial channels and STL channels (within the Elementa minimized functionality) indistinctly. Its functionality must be the merging of InSerCh and OutSerCh.
| void elementa::base::serch_isgood | ( | RootSerCh & | serchconst, |
| const std::string & | place = "", |
||
| const RTTextWithEnum::Combination & | flags = {RTTextWith::kAll_} |
||
| ) |
#include <elementa/base/serial_channels/basics.h>
Throw an exception if the channel is not good; do nothing otherwise.
Throws a std::runtime_error.
Referenced by elementa::adts::graphs::Szer_GraphCompactText< Vertex, Edge >::ser(), elementa::adts::Szer_TreeText< Vertex, Edge >::ser(), elementa::base::Szer_Char::ser(), and elementa::base::Szer_NatBin< NatType >::ser().
| bool elementa::base::serch_iseofbutok | ( | RootSerCh & | serchconst, |
| const std::string & | place = "", |
||
| const RTTextWithEnum::Combination & | flags = {RTTextWith::kAll_} |
||
| ) |
#include <elementa/base/serial_channels/basics.h>
Return TRUE if the channel is eof() (maybe bad/fail); throw if !eof nor good.
Do nothing otherwise and return FALSE (the channel is good)
| bool elementa::base::serch_isexhausted | ( | InSerCh & | serch, |
| const std::string & | place = "", |
||
| const RTTextWithEnum::Combination & | flags = {RTTextWith::kAll_} |
||
| ) |
#include <elementa/base/serial_channels/basics.h>
Return TRUE if it is eof or exhausted; then throw if the channel is bad/fail.
Otherwise do nothing and return FALSE. A channel is exhausted if is eof or after peeking the next char the eof flag is set.
Referenced by elementa::base::Szer_Char::deser(), and elementa::base::Szer_NatBin< NatType >::deser().
|
noexcept |
#include <elementa/base/serial_channels/basics.h>
Converts an io state into a string.
Since std::ios_base::iostate is usually an integral type, to avoid an implicit conversion to integer -and thus a call to a different to_string()- we have renamed this function.
Referenced by elementa::base::serch_filtered_pbackfail(), elementa::base::serch_filtered_uflow(), elementa::base::serch_filtered_underflow(), elementa::base::serch_st_to_string(), elementa::base::serch_transfer(), elementa::base::serch_transfer< SerChI_Memory, SerChIO_Memory >(), and elementa::base::serch_transfer< SerChIO_Memory, SerChIO_Memory >().
|
inlinenoexcept |
#include <elementa/base/serial_channels/basics.h>
Converts the state of a serial channel into a string.
Definition at line 515 of file basics.h.
References elementa::base::serch_st_to_string().
| SerChSize elementa::base::serch_transfer | ( | SCOrg & | chin, |
| SCDest & | chout, | ||
| SerChSize | count = 0 |
||
| ) |
#include <elementa/base/serial_channels/basics.h>
Write COUNT items read from channel CHIN into channel CHOUT.
If COUNT is 0 read until CHIN or CHOUT are in error or exhausted (do not throw if any error). Return the number of bytes transferred.
Return the actual number of items transferred (less than COUNT if any channel gets exhausted or, in general, not good).
Definition at line 678 of file basics.h.
References ELE_CODE_TRACE_OFF, ELE_CODE_UNTRACE, elementa::base::serch_st_to_string(), and elementa::base::to_number().
Referenced by elementa::base::serch_transfer().
| SerChSize elementa::base::serch_transfer | ( | SCOrg && | chin, |
| SCDest && | chout, | ||
| SerChSize | count = 1 |
||
| ) |
#include <elementa/base/serial_channels/basics.h>
Version of serch_transfer for using rvalues (but without moving then).
No moves are involved; this is just for enabling calling the function with rvalues, and it just redirect the call to the appropriate version.
Definition at line 738 of file basics.h.
References ELE_CODE_TRACE_OFF, and elementa::base::serch_transfer().
|
constexpr |
#include <elementa/base/serial_channels/basics.h>
Const that holds the eof value.
Definition at line 189 of file basics.h.
Referenced by elementa::base::serch_filtered_overflow(), elementa::base::serch_filtered_pbackfail(), elementa::base::serch_filtered_uflow(), and elementa::base::serch_filtered_underflow().