Elementa v8.0.0
Minimalistic library for any C++ application (C++11 and up)
Loading...
Searching...
No Matches
basics.h File Reference
#include "elementa/license.inc"
#include "elementa/checks.inc"
#include <iostream>
#include <string>
#include "elementa/base/exceptions.h"
#include "elementa/base/debugging.h"
#include "elementa/base/strings.h"
#include "elementa/patterns/clonable.h"
Include dependency graph for basics.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

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...