PhoenixSocket  5.0.0
Library which integrates socket use in Phoenix
Loading...
Searching...
No Matches
PSocketFlag.h File Reference
#include <string>
+ Include dependency graph for PSocketFlag.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  PSocketParam
 Parameters to create a socket. More...
 

Namespaces

namespace  PRecvFlag
 
namespace  PRecvStatus
 
namespace  PSendFlag
 
namespace  PSendStatus
 

Macros

#define PHOENIX_ASSERT_EXCEPTION(X)
 Assert especially designed to catch exception and abort if no exception is raised.
 

Enumerations

enum  PRecvFlag::PRecvFlag { PRecvFlag::BLOCK , PRecvFlag::NON_BLOCK }
 describe the receiving flag of the Socket More...
 
enum  PRecvStatus::PRecvStatus {
  PRecvStatus::OK , PRecvStatus::NO_MESSAGE_RECEIVED , PRecvStatus::INVALID_MESSAGE , PRecvStatus::SOCKET_NOT_AVAILABLE ,
  PRecvStatus::SIGNAL_INTERRUPTION , PRecvStatus::BROKEN_BACKEND , PRecvStatus::BROKEN_SOCKET , PRecvStatus::CANNOT_DESERIALIZE_DATA
}
 describe the result of the recv More...
 
enum  PSendFlag::PSendFlag { PSendFlag::BLOCK , PSendFlag::NON_BLOCK }
 describe the sending flag of the Socket More...
 
enum  PSendStatus::PSendStatus {
  PSendStatus::OK , PSendStatus::SOCKET_NOT_AVAILABLE , PSendStatus::NO_ROUTE_TO_RECEIVER , PSendStatus::SIGNAL_INTERRUPTION ,
  PSendStatus::BROKEN_BACKEND , PSendStatus::BROKEN_SOCKET , PSendStatus::CANNOT_SERIALIZE_DATA
}
 describe the result of the send More...
 

Functions

template<typename T>
fromString (const std::string &str)
 
template<>
PRecvFlag::PRecvFlag fromString< PRecvFlag::PRecvFlag > (const std::string &str)
 Convert a std::string into a PRecvFlag.
 
template<>
PRecvStatus::PRecvStatus fromString< PRecvStatus::PRecvStatus > (const std::string &str)
 Convert a std::string into a PRecvStatus.
 
template<>
PSendFlag::PSendFlag fromString< PSendFlag::PSendFlag > (const std::string &str)
 Convert a std::string into a PSendFlag.
 
template<>
PSendStatus::PSendStatus fromString< PSendStatus::PSendStatus > (const std::string &str)
 Convert a std::string into a PSendStatus.
 
std::string toString (PRecvFlag::PRecvFlag flag)
 Convert a PRecvFlag into a std::string.
 
std::string toString (PRecvStatus::PRecvStatus status)
 Convert a PRecvStatus into a std::string.
 
std::string toString (PSendFlag::PSendFlag flag)
 Convert a PSendFlag into a std::string.
 
std::string toString (PSendStatus::PSendStatus status)
 Convert a PSendStatus into a std::string.
 

Macro Definition Documentation

◆ PHOENIX_ASSERT_EXCEPTION

#define PHOENIX_ASSERT_EXCEPTION ( X)
Value:
{\
bool isWrongSend = false;\
try{\
X;\
}catch(...){\
isWrongSend = true;\
}\
data_stream_assert(isWrongSend);\
}

Assert especially designed to catch exception and abort if no exception is raised.

Definition at line 91 of file PSocketFlag.h.

91#define PHOENIX_ASSERT_EXCEPTION(X) {\
92 bool isWrongSend = false;\
93 try{\
94 X;\
95 }catch(...){\
96 isWrongSend = true;\
97 }\
98 data_stream_assert(isWrongSend);\
99}

Function Documentation

◆ fromString()

template<typename T>
T fromString ( const std::string & str)

◆ fromString< PRecvFlag::PRecvFlag >()

template<>
PRecvFlag::PRecvFlag fromString< PRecvFlag::PRecvFlag > ( const std::string & str)

Convert a std::string into a PRecvFlag.

Parameters
str: std::string to be converted
Returns
corresponding PRecvFlag

Definition at line 102 of file PSocketFlag.cpp.

102 {
103 if(str == "BLOCK"){return PRecvFlag::BLOCK;}
104 else if(str == "NON_BLOCK"){return PRecvFlag::NON_BLOCK;}
105 throw std::invalid_argument("Invalid PRecvFlag string: " + str);
106}

References PRecvFlag::BLOCK, and PRecvFlag::NON_BLOCK.

◆ fromString< PRecvStatus::PRecvStatus >()

template<>
PRecvStatus::PRecvStatus fromString< PRecvStatus::PRecvStatus > ( const std::string & str)

Convert a std::string into a PRecvStatus.

Parameters
str: std::string to be converted
Returns
corresponding PRecvStatus

Definition at line 113 of file PSocketFlag.cpp.

113 {
114 if(str == "OK"){return PRecvStatus::OK;}
115 else if(str == "NO_MESSAGE_RECEIVED"){return PRecvStatus::NO_MESSAGE_RECEIVED;}
116 else if(str == "INVALID_MESSAGE"){return PRecvStatus::INVALID_MESSAGE;}
117 else if(str == "SOCKET_NOT_AVAILABLE"){return PRecvStatus::SOCKET_NOT_AVAILABLE;}
118 else if(str == "SIGNAL_INTERRUPTION"){return PRecvStatus::SIGNAL_INTERRUPTION;}
119 else if(str == "BROKEN_BACKEND"){return PRecvStatus::BROKEN_BACKEND;}
120 else if(str == "BROKEN_SOCKET"){return PRecvStatus::BROKEN_SOCKET;}
121 else if(str == "CANNOT_DESERIALIZE_DATA"){return PRecvStatus::CANNOT_DESERIALIZE_DATA;}
122 throw std::invalid_argument("Invalid PRecvStatus string: " + str);
123}
@ SIGNAL_INTERRUPTION
Definition PSocketFlag.h:48
@ CANNOT_DESERIALIZE_DATA
Definition PSocketFlag.h:51
@ NO_MESSAGE_RECEIVED
Definition PSocketFlag.h:45
@ SOCKET_NOT_AVAILABLE
Definition PSocketFlag.h:47

References PRecvStatus::BROKEN_BACKEND, PRecvStatus::BROKEN_SOCKET, PRecvStatus::CANNOT_DESERIALIZE_DATA, PRecvStatus::INVALID_MESSAGE, PRecvStatus::NO_MESSAGE_RECEIVED, PRecvStatus::OK, PRecvStatus::SIGNAL_INTERRUPTION, and PRecvStatus::SOCKET_NOT_AVAILABLE.

◆ fromString< PSendFlag::PSendFlag >()

template<>
PSendFlag::PSendFlag fromString< PSendFlag::PSendFlag > ( const std::string & str)

Convert a std::string into a PSendFlag.

Parameters
str: std::string to be converted
Returns
corresponding PSendFlag

Definition at line 75 of file PSocketFlag.cpp.

75 {
76 if(str == "BLOCK"){return PSendFlag::BLOCK;}
77 else if(str == "NON_BLOCK"){return PSendFlag::NON_BLOCK;}
78 throw std::invalid_argument("Invalid PSendFlag string: " + str);
79}

References PSendFlag::BLOCK, and PSendFlag::NON_BLOCK.

◆ fromString< PSendStatus::PSendStatus >()

template<>
PSendStatus::PSendStatus fromString< PSendStatus::PSendStatus > ( const std::string & str)

Convert a std::string into a PSendStatus.

Parameters
str: std::string to be converted
Returns
corresponding PSendStatus

Definition at line 86 of file PSocketFlag.cpp.

86 {
87 if(str == "OK"){return PSendStatus::OK;}
88 else if(str == "SOCKET_NOT_AVAILABLE"){return PSendStatus::SOCKET_NOT_AVAILABLE;}
89 else if(str == "NO_ROUTE_TO_RECEIVER"){return PSendStatus::NO_ROUTE_TO_RECEIVER;}
90 else if(str == "SIGNAL_INTERRUPTION"){return PSendStatus::SIGNAL_INTERRUPTION;}
91 else if(str == "BROKEN_BACKEND"){return PSendStatus::BROKEN_BACKEND;}
92 else if(str == "BROKEN_SOCKET"){return PSendStatus::BROKEN_SOCKET;}
93 else if(str == "CANNOT_SERIALIZE_DATA"){return PSendStatus::CANNOT_SERIALIZE_DATA;}
94 throw std::invalid_argument("Invalid PSendStatus string: " + str);
95}
@ SOCKET_NOT_AVAILABLE
Definition PSocketFlag.h:24
@ NO_ROUTE_TO_RECEIVER
Definition PSocketFlag.h:25
@ CANNOT_SERIALIZE_DATA
Definition PSocketFlag.h:29
@ SIGNAL_INTERRUPTION
Definition PSocketFlag.h:26

References PSendStatus::BROKEN_BACKEND, PSendStatus::BROKEN_SOCKET, PSendStatus::CANNOT_SERIALIZE_DATA, PSendStatus::NO_ROUTE_TO_RECEIVER, PSendStatus::OK, PSendStatus::SIGNAL_INTERRUPTION, and PSendStatus::SOCKET_NOT_AVAILABLE.

◆ toString() [1/4]

std::string toString ( PRecvFlag::PRecvFlag flag)

Convert a PRecvFlag into a std::string.

Parameters
flag: PRecvFlag to be converted
Returns
corresponding string

Definition at line 44 of file PSocketFlag.cpp.

44 {
45 switch(flag){
46 case PRecvFlag::BLOCK: return "BLOCK"; break;
47 case PRecvFlag::NON_BLOCK: return "NON_BLOCK"; break;
48 }
49 throw std::invalid_argument("Invalid PRecvFlag flag");
50}

References PRecvFlag::BLOCK, and PRecvFlag::NON_BLOCK.

◆ toString() [2/4]

std::string toString ( PRecvStatus::PRecvStatus status)

Convert a PRecvStatus into a std::string.

Parameters
status: PRecvStatus to be converted
Returns
corresponding string

Definition at line 56 of file PSocketFlag.cpp.

56 {
57 switch(status){
58 case PRecvStatus::OK: return "OK"; break;
59 case PRecvStatus::NO_MESSAGE_RECEIVED: return "NO_MESSAGE_RECEIVED"; break;
60 case PRecvStatus::INVALID_MESSAGE: return "INVALID_MESSAGE"; break;
61 case PRecvStatus::SOCKET_NOT_AVAILABLE: return "SOCKET_NOT_AVAILABLE"; break;
62 case PRecvStatus::SIGNAL_INTERRUPTION: return "SIGNAL_INTERRUPTION"; break;
63 case PRecvStatus::BROKEN_BACKEND: return "BROKEN_BACKEND"; break;
64 case PRecvStatus::BROKEN_SOCKET: return "BROKEN_SOCKET"; break;
65 case PRecvStatus::CANNOT_DESERIALIZE_DATA: return "CANNOT_DESERIALIZE_DATA"; break;
66 }
67 throw std::invalid_argument("Invalid PRecvStatus flag");
68}

References PRecvStatus::BROKEN_BACKEND, PRecvStatus::BROKEN_SOCKET, PRecvStatus::CANNOT_DESERIALIZE_DATA, PRecvStatus::INVALID_MESSAGE, PRecvStatus::NO_MESSAGE_RECEIVED, PRecvStatus::OK, PRecvStatus::SIGNAL_INTERRUPTION, and PRecvStatus::SOCKET_NOT_AVAILABLE.

◆ toString() [3/4]

std::string toString ( PSendFlag::PSendFlag flag)

Convert a PSendFlag into a std::string.

Parameters
flag: PSendFlag to be converted
Returns
corresponding string

Definition at line 14 of file PSocketFlag.cpp.

14 {
15 switch(flag){
16 case PSendFlag::BLOCK: return "BLOCK"; break;
17 case PSendFlag::NON_BLOCK: return "NON_BLOCK"; break;
18 }
19 throw std::invalid_argument("Invalid PSendFlag flag");
20}

References PSendFlag::BLOCK, and PSendFlag::NON_BLOCK.

◆ toString() [4/4]

std::string toString ( PSendStatus::PSendStatus status)

Convert a PSendStatus into a std::string.

Parameters
status: PSendStatus to be converted
Returns
corresponding string

Definition at line 26 of file PSocketFlag.cpp.

26 {
27 switch(status){
28 case PSendStatus::OK: return "OK"; break;
29 case PSendStatus::SOCKET_NOT_AVAILABLE: return "SOCKET_NOT_AVAILABLE"; break;
30 case PSendStatus::NO_ROUTE_TO_RECEIVER: return "NO_ROUTE_TO_RECEIVER"; break;
31 case PSendStatus::SIGNAL_INTERRUPTION: return "SIGNAL_INTERRUPTION"; break;
32 case PSendStatus::BROKEN_BACKEND: return "BROKEN_BACKEND"; break;
33 case PSendStatus::BROKEN_SOCKET: return "BROKEN_SOCKET"; break;
34 case PSendStatus::CANNOT_SERIALIZE_DATA: return "CANNOT_SERIALIZE_DATA"; break;
35 }
36 throw std::invalid_argument("Invalid PSendStatus flag");
37}

References PSendStatus::BROKEN_BACKEND, PSendStatus::BROKEN_SOCKET, PSendStatus::CANNOT_SERIALIZE_DATA, PSendStatus::NO_ROUTE_TO_RECEIVER, PSendStatus::OK, PSendStatus::SIGNAL_INTERRUPTION, and PSendStatus::SOCKET_NOT_AVAILABLE.