SNode.C
Loading...
Searching...
No Matches
core::socket::State Class Reference

#include <State.h>

Collaboration diagram for core::socket::State:

Public Member Functions

 State (const int &state, const std::string &file, const int &line)
 
 State (const int &state, const std::string &file, const int &line, int errnum, const std::string &errstr)
 
 operator int () const
 
bool operator== (const int &state) const
 
Stateoperator= (int state)
 
Stateoperator|= (int state)
 
Stateoperator&= (int state)
 
Stateoperator^= (int state)
 
State operator| (int state)
 
State operator& (int state)
 
State operator^ (int state)
 
std::string what () const
 
std::string where () const
 

Static Public Attributes

static constexpr int OK = 0
 
static constexpr int DISABLED = 1
 
static constexpr int ERROR = 2
 
static constexpr int FATAL = 3
 
static constexpr int NO_RETRY = 4
 

Private Attributes

int state
 
std::string file
 
int line = 0
 
int errnum
 
std::string errstr
 

Detailed Description

Definition at line 53 of file State.h.

Constructor & Destructor Documentation

◆ State() [1/2]

core::socket::State::State ( const int &  state,
const std::string &  file,
const int &  line 
)

Definition at line 54 of file State.cpp.

55 : state(state)
56 , file(file)
57 , line(line)
58 , errnum(errno)
59 , errstr(errnum != 0 ? std::strerror(errnum) : "") {
60 }
std::string errstr
Definition State.h:95
std::string file
Definition State.h:91

References errnum, errstr, file, line, and state.

◆ State() [2/2]

core::socket::State::State ( const int &  state,
const std::string &  file,
const int &  line,
int  errnum,
const std::string &  errstr 
)

Definition at line 62 of file State.cpp.

63 : state(state)
64 , file(file)
65 , line(line)
66 , errnum(errnum)
67 , errstr(errnum != 0 ? errstr : "") {
68 }

References errnum, errstr, file, line, and state.

Referenced by operator&(), operator^(), and operator|().

Here is the caller graph for this function:

Member Function Documentation

◆ operator int()

core::socket::State::operator int ( ) const

Definition at line 70 of file State.cpp.

70 {
71 return state;
72 }

References state.

◆ operator&()

State core::socket::State::operator& ( int  state)

Definition at line 106 of file State.cpp.

106 {
107 return State(this->state & state, this->file, this->line, this->errnum, this->errstr);
108 }
State(const int &state, const std::string &file, const int &line)
Definition State.cpp:54

References errnum, errstr, file, line, State(), and state.

Referenced by core::socket::stream::SocketClient< SocketConnectorT, SocketContextFactoryT, Args >::realConnect(), and core::socket::stream::SocketServer< SocketAcceptorT, SocketContextFactoryT, Args >::realListen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator&=()

State & core::socket::State::operator&= ( int  state)

Definition at line 90 of file State.cpp.

90 {
91 this->state &= state;
92
93 return *this;
94 }

References state.

Referenced by core::socket::stream::SocketClient< SocketConnectorT, SocketContextFactoryT, Args >::realConnect(), and core::socket::stream::SocketServer< SocketAcceptorT, SocketContextFactoryT, Args >::realListen().

Here is the caller graph for this function:

◆ operator=()

State & core::socket::State::operator= ( int  state)

Definition at line 78 of file State.cpp.

78 {
79 this->state = state;
80
81 return *this;
82 }

References state.

◆ operator==()

bool core::socket::State::operator== ( const int &  state) const

Definition at line 74 of file State.cpp.

74 {
75 return this->state == state;
76 }

References state.

Referenced by core::socket::stream::SocketClient< SocketConnectorT, SocketContextFactoryT, Args >::realConnect(), and core::socket::stream::SocketServer< SocketAcceptorT, SocketContextFactoryT, Args >::realListen().

Here is the caller graph for this function:

◆ operator^()

State core::socket::State::operator^ ( int  state)

Definition at line 110 of file State.cpp.

110 {
111 return State(this->state ^ state, this->file, this->line, this->errnum, this->errstr);
112 }

References errnum, errstr, file, line, State(), and state.

Here is the call graph for this function:

◆ operator^=()

State & core::socket::State::operator^= ( int  state)

Definition at line 96 of file State.cpp.

96 {
97 this->state ^= state;
98
99 return *this;
100 }

References state.

◆ operator|()

State core::socket::State::operator| ( int  state)

Definition at line 102 of file State.cpp.

102 {
103 return State(this->state | state, this->file, this->line, this->errnum, this->errstr);
104 }

References errnum, errstr, file, line, State(), and state.

Referenced by core::socket::stream::SocketConnector< PhysicalSocketClientT, ConfigT, SocketConnectionT >::connectEvent(), core::socket::stream::SocketAcceptor< PhysicalSocketServerT, ConfigT, SocketConnectionT >::init(), and core::socket::stream::SocketConnector< PhysicalSocketClientT, ConfigT, SocketConnectionT >::init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator|=()

State & core::socket::State::operator|= ( int  state)

Definition at line 84 of file State.cpp.

84 {
85 this->state |= state;
86
87 return *this;
88 }

References state.

◆ what()

std::string core::socket::State::what ( ) const

Definition at line 114 of file State.cpp.

114 {
115 std::string stateString;
116
117 switch (state & ~NO_RETRY) {
118 case OK:
119 stateString = "OK";
120 break;
121 case DISABLED:
122 stateString = "DISABLED";
123 break;
124 case ERROR:
125 [[fallthrough]];
126 case FATAL:
127 stateString = errstr;
128 break;
129 }
130
131 return stateString.append(" [").append(std::to_string(errnum)).append("]");
132 }
static constexpr int DISABLED
Definition State.h:56
static constexpr int ERROR
Definition State.h:57
static constexpr int FATAL
Definition State.h:58
static constexpr int OK
Definition State.h:55
static constexpr int NO_RETRY
Definition State.h:59

References DISABLED, errnum, ERROR, errstr, FATAL, NO_RETRY, OK, and state.

Referenced by tls::getClient(), legacy::getLegacyClient(), and main().

Here is the caller graph for this function:

◆ where()

std::string core::socket::State::where ( ) const

Definition at line 134 of file State.cpp.

134 {
135 return file + "(" + std::to_string(line) + ")";
136 }

References file, and line.

Member Data Documentation

◆ DISABLED

◆ errnum

int core::socket::State::errnum
private

Definition at line 94 of file State.h.

Referenced by operator&(), operator^(), operator|(), State(), State(), and what().

◆ ERROR

◆ errstr

std::string core::socket::State::errstr
private

Definition at line 95 of file State.h.

Referenced by operator&(), operator^(), operator|(), State(), State(), and what().

◆ FATAL

◆ file

std::string core::socket::State::file
private

Definition at line 91 of file State.h.

Referenced by operator&(), operator^(), operator|(), State(), State(), and where().

◆ line

int core::socket::State::line = 0
private

Definition at line 92 of file State.h.

Referenced by operator&(), operator^(), operator|(), State(), State(), and where().

◆ NO_RETRY

◆ OK

◆ state

int core::socket::State::state
private

The documentation for this class was generated from the following files: