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 31 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 32 of file State.cpp.

33 : state(state)
34 , file(file)
35 , line(line)
36 , errnum(errno)
37 , errstr(errnum != 0 ? std::strerror(errnum) : "") {
38 }
std::string errstr
Definition State.h:73
std::string file
Definition State.h:69

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

Referenced by State().

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

◆ 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 40 of file State.cpp.

41 : state(state)
42 , file(file)
43 , line(line)
44 , errnum(errnum)
45 , errstr(errnum != 0 ? errstr : "") {
46 }

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

Referenced by State().

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

Member Function Documentation

◆ operator int()

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

Definition at line 48 of file State.cpp.

48 {
49 return state;
50 }

References state.

◆ operator&()

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

Definition at line 84 of file State.cpp.

84 {
85 return State(this->state & state, this->file, this->line, this->errnum, this->errstr);
86 }
State
Definition State.h:29

References errnum, line, and state.

◆ operator&=()

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

Definition at line 68 of file State.cpp.

68 {
69 this->state &= state;
70
71 return *this;
72 }

References state.

◆ operator=()

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

Definition at line 56 of file State.cpp.

56 {
57 this->state = state;
58
59 return *this;
60 }

References state.

◆ operator==()

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

Definition at line 52 of file State.cpp.

52 {
53 return this->state == state;
54 }

References state.

◆ operator^()

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

Definition at line 88 of file State.cpp.

88 {
89 return State(this->state ^ state, this->file, this->line, this->errnum, this->errstr);
90 }

References errnum, line, and state.

◆ operator^=()

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

Definition at line 74 of file State.cpp.

74 {
75 this->state ^= state;
76
77 return *this;
78 }

References state.

◆ operator|()

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

Definition at line 80 of file State.cpp.

80 {
81 return State(this->state | state, this->file, this->line, this->errnum, this->errstr);
82 }

References errnum, line, and state.

◆ operator|=()

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

Definition at line 62 of file State.cpp.

62 {
63 this->state |= state;
64
65 return *this;
66 }

References state.

◆ what()

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

Definition at line 92 of file State.cpp.

92 {
93 std::string stateString;
94
95 switch (state & ~NO_RETRY) {
96 case OK:
97 stateString = "OK";
98 break;
99 case DISABLED:
100 stateString = "DISABLED";
101 break;
102 case ERROR:
103 [[fallthrough]];
104 case FATAL:
105 stateString = errstr;
106 break;
107 }
108
109 return stateString.append(" [").append(std::to_string(errnum)).append("]");
110 }
static constexpr int DISABLED
Definition State.h:34
static constexpr int ERROR
Definition State.h:35
static constexpr int FATAL
Definition State.h:36
static constexpr int OK
Definition State.h:33
static constexpr int NO_RETRY
Definition State.h:37

References ERROR, NO_RETRY, and state.

◆ where()

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

Definition at line 112 of file State.cpp.

112 {
113 return file + "(" + std::to_string(line) + ")";
114 }

Member Data Documentation

◆ DISABLED

int core::socket::State::DISABLED = 1
staticconstexpr

Definition at line 34 of file State.h.

◆ errnum

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

Definition at line 72 of file State.h.

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

◆ ERROR

int core::socket::State::ERROR = 2
staticconstexpr

Definition at line 35 of file State.h.

Referenced by what().

◆ errstr

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

Definition at line 73 of file State.h.

◆ FATAL

int core::socket::State::FATAL = 3
staticconstexpr

Definition at line 36 of file State.h.

◆ file

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

Definition at line 69 of file State.h.

◆ line

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

Definition at line 70 of file State.h.

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

◆ NO_RETRY

int core::socket::State::NO_RETRY = 4
staticconstexpr

Definition at line 37 of file State.h.

Referenced by what().

◆ OK

int core::socket::State::OK = 0
staticconstexpr

Definition at line 33 of file State.h.

◆ state

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

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