| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*************************************** | ||
| 2 | Auteur : Pierre Aubert | ||
| 3 | Mail : pierre.aubert@lapp.in2p3.fr | ||
| 4 | Licence : CeCILL-C | ||
| 5 | ****************************************/ | ||
| 6 | |||
| 7 | #include "PSocketFlag.h" | ||
| 8 | #include <stdexcept> | ||
| 9 | |||
| 10 | ///Convert a PSendFlag into a std::string | ||
| 11 | /** @param flag : PSendFlag to be converted | ||
| 12 | * @return corresponding string | ||
| 13 | */ | ||
| 14 | 2 | std::string toString(PSendFlag::PSendFlag flag){ | |
| 15 |
2/3✓ Branch 0 (2→3) taken 1 times.
✓ Branch 1 (2→8) taken 1 times.
✗ Branch 2 (2→13) not taken.
|
2 | switch(flag){ |
| 16 |
1/1✓ Branch 0 (5→6) taken 1 times.
|
3 | case PSendFlag::BLOCK: return "BLOCK"; break; |
| 17 |
1/1✓ Branch 0 (10→11) taken 1 times.
|
3 | case PSendFlag::NON_BLOCK: return "NON_BLOCK"; break; |
| 18 | } | ||
| 19 | ✗ | throw std::invalid_argument("Invalid PSendFlag flag"); | |
| 20 | } | ||
| 21 | |||
| 22 | ///Convert a PSendStatus into a std::string | ||
| 23 | /** @param status : PSendStatus to be converted | ||
| 24 | * @return corresponding string | ||
| 25 | */ | ||
| 26 | 7 | std::string toString(PSendStatus::PSendStatus status){ | |
| 27 |
7/8✓ Branch 0 (2→3) taken 1 times.
✓ Branch 1 (2→8) taken 1 times.
✓ Branch 2 (2→13) taken 1 times.
✓ Branch 3 (2→18) taken 1 times.
✓ Branch 4 (2→23) taken 1 times.
✓ Branch 5 (2→28) taken 1 times.
✓ Branch 6 (2→33) taken 1 times.
✗ Branch 7 (2→38) not taken.
|
7 | switch(status){ |
| 28 |
1/1✓ Branch 0 (5→6) taken 1 times.
|
3 | case PSendStatus::OK: return "OK"; break; |
| 29 |
1/1✓ Branch 0 (10→11) taken 1 times.
|
3 | case PSendStatus::SOCKET_NOT_AVAILABLE: return "SOCKET_NOT_AVAILABLE"; break; |
| 30 |
1/1✓ Branch 0 (15→16) taken 1 times.
|
3 | case PSendStatus::NO_ROUTE_TO_RECEIVER: return "NO_ROUTE_TO_RECEIVER"; break; |
| 31 |
1/1✓ Branch 0 (20→21) taken 1 times.
|
3 | case PSendStatus::SIGNAL_INTERRUPTION: return "SIGNAL_INTERRUPTION"; break; |
| 32 |
1/1✓ Branch 0 (25→26) taken 1 times.
|
3 | case PSendStatus::BROKEN_BACKEND: return "BROKEN_BACKEND"; break; |
| 33 |
1/1✓ Branch 0 (30→31) taken 1 times.
|
3 | case PSendStatus::BROKEN_SOCKET: return "BROKEN_SOCKET"; break; |
| 34 |
1/1✓ Branch 0 (35→36) taken 1 times.
|
3 | case PSendStatus::CANNOT_SERIALIZE_DATA: return "CANNOT_SERIALIZE_DATA"; break; |
| 35 | } | ||
| 36 | ✗ | throw std::invalid_argument("Invalid PSendStatus flag"); | |
| 37 | } | ||
| 38 | |||
| 39 | |||
| 40 | ///Convert a PRecvFlag into a std::string | ||
| 41 | /** @param flag : PRecvFlag to be converted | ||
| 42 | * @return corresponding string | ||
| 43 | */ | ||
| 44 | 2 | std::string toString(PRecvFlag::PRecvFlag flag){ | |
| 45 |
2/3✓ Branch 0 (2→3) taken 1 times.
✓ Branch 1 (2→8) taken 1 times.
✗ Branch 2 (2→13) not taken.
|
2 | switch(flag){ |
| 46 |
1/1✓ Branch 0 (5→6) taken 1 times.
|
3 | case PRecvFlag::BLOCK: return "BLOCK"; break; |
| 47 |
1/1✓ Branch 0 (10→11) taken 1 times.
|
3 | case PRecvFlag::NON_BLOCK: return "NON_BLOCK"; break; |
| 48 | } | ||
| 49 | ✗ | throw std::invalid_argument("Invalid PRecvFlag flag"); | |
| 50 | } | ||
| 51 | |||
| 52 | ///Convert a PRecvStatus into a std::string | ||
| 53 | /** @param status : PRecvStatus to be converted | ||
| 54 | * @return corresponding string | ||
| 55 | */ | ||
| 56 | 8 | std::string toString(PRecvStatus::PRecvStatus status){ | |
| 57 |
8/9✓ Branch 0 (2→3) taken 1 times.
✓ Branch 1 (2→8) taken 1 times.
✓ Branch 2 (2→13) taken 1 times.
✓ Branch 3 (2→18) taken 1 times.
✓ Branch 4 (2→23) taken 1 times.
✓ Branch 5 (2→28) taken 1 times.
✓ Branch 6 (2→33) taken 1 times.
✓ Branch 7 (2→38) taken 1 times.
✗ Branch 8 (2→43) not taken.
|
8 | switch(status){ |
| 58 |
1/1✓ Branch 0 (5→6) taken 1 times.
|
3 | case PRecvStatus::OK: return "OK"; break; |
| 59 |
1/1✓ Branch 0 (10→11) taken 1 times.
|
3 | case PRecvStatus::NO_MESSAGE_RECEIVED: return "NO_MESSAGE_RECEIVED"; break; |
| 60 |
1/1✓ Branch 0 (15→16) taken 1 times.
|
3 | case PRecvStatus::INVALID_MESSAGE: return "INVALID_MESSAGE"; break; |
| 61 |
1/1✓ Branch 0 (20→21) taken 1 times.
|
3 | case PRecvStatus::SOCKET_NOT_AVAILABLE: return "SOCKET_NOT_AVAILABLE"; break; |
| 62 |
1/1✓ Branch 0 (25→26) taken 1 times.
|
3 | case PRecvStatus::SIGNAL_INTERRUPTION: return "SIGNAL_INTERRUPTION"; break; |
| 63 |
1/1✓ Branch 0 (30→31) taken 1 times.
|
3 | case PRecvStatus::BROKEN_BACKEND: return "BROKEN_BACKEND"; break; |
| 64 |
1/1✓ Branch 0 (35→36) taken 1 times.
|
3 | case PRecvStatus::BROKEN_SOCKET: return "BROKEN_SOCKET"; break; |
| 65 |
1/1✓ Branch 0 (40→41) taken 1 times.
|
3 | case PRecvStatus::CANNOT_DESERIALIZE_DATA: return "CANNOT_DESERIALIZE_DATA"; break; |
| 66 | } | ||
| 67 | ✗ | throw std::invalid_argument("Invalid PRecvStatus flag"); | |
| 68 | } | ||
| 69 | |||
| 70 | ///Convert a std::string into a PSendFlag | ||
| 71 | /** @param str : std::string to be converted | ||
| 72 | * @return corresponding PSendFlag | ||
| 73 | */ | ||
| 74 | template<> | ||
| 75 | 2 | PSendFlag::PSendFlag fromString<PSendFlag::PSendFlag>(const std::string& str){ | |
| 76 |
2/2✓ Branch 0 (3→4) taken 1 times.
✓ Branch 1 (3→5) taken 1 times.
|
2 | if(str == "BLOCK"){return PSendFlag::BLOCK;} |
| 77 |
1/2✓ Branch 0 (6→7) taken 1 times.
✗ Branch 1 (6→8) not taken.
|
1 | else if(str == "NON_BLOCK"){return PSendFlag::NON_BLOCK;} |
| 78 | ✗ | throw std::invalid_argument("Invalid PSendFlag string: " + str); | |
| 79 | } | ||
| 80 | |||
| 81 | ///Convert a std::string into a PSendStatus | ||
| 82 | /** @param str : std::string to be converted | ||
| 83 | * @return corresponding PSendStatus | ||
| 84 | */ | ||
| 85 | template<> | ||
| 86 | 7 | PSendStatus::PSendStatus fromString<PSendStatus::PSendStatus>(const std::string& str){ | |
| 87 |
2/2✓ Branch 0 (3→4) taken 1 times.
✓ Branch 1 (3→5) taken 6 times.
|
7 | if(str == "OK"){return PSendStatus::OK;} |
| 88 |
2/2✓ Branch 0 (6→7) taken 1 times.
✓ Branch 1 (6→8) taken 5 times.
|
6 | else if(str == "SOCKET_NOT_AVAILABLE"){return PSendStatus::SOCKET_NOT_AVAILABLE;} |
| 89 |
2/2✓ Branch 0 (9→10) taken 1 times.
✓ Branch 1 (9→11) taken 4 times.
|
5 | else if(str == "NO_ROUTE_TO_RECEIVER"){return PSendStatus::NO_ROUTE_TO_RECEIVER;} |
| 90 |
2/2✓ Branch 0 (12→13) taken 1 times.
✓ Branch 1 (12→14) taken 3 times.
|
4 | else if(str == "SIGNAL_INTERRUPTION"){return PSendStatus::SIGNAL_INTERRUPTION;} |
| 91 |
2/2✓ Branch 0 (15→16) taken 1 times.
✓ Branch 1 (15→17) taken 2 times.
|
3 | else if(str == "BROKEN_BACKEND"){return PSendStatus::BROKEN_BACKEND;} |
| 92 |
2/2✓ Branch 0 (18→19) taken 1 times.
✓ Branch 1 (18→20) taken 1 times.
|
2 | else if(str == "BROKEN_SOCKET"){return PSendStatus::BROKEN_SOCKET;} |
| 93 |
1/2✓ Branch 0 (21→22) taken 1 times.
✗ Branch 1 (21→23) not taken.
|
1 | else if(str == "CANNOT_SERIALIZE_DATA"){return PSendStatus::CANNOT_SERIALIZE_DATA;} |
| 94 | ✗ | throw std::invalid_argument("Invalid PSendStatus string: " + str); | |
| 95 | } | ||
| 96 | |||
| 97 | ///Convert a std::string into a PRecvFlag | ||
| 98 | /** @param str : std::string to be converted | ||
| 99 | * @return corresponding PRecvFlag | ||
| 100 | */ | ||
| 101 | template<> | ||
| 102 | 2 | PRecvFlag::PRecvFlag fromString<PRecvFlag::PRecvFlag>(const std::string& str){ | |
| 103 |
2/2✓ Branch 0 (3→4) taken 1 times.
✓ Branch 1 (3→5) taken 1 times.
|
2 | if(str == "BLOCK"){return PRecvFlag::BLOCK;} |
| 104 |
1/2✓ Branch 0 (6→7) taken 1 times.
✗ Branch 1 (6→8) not taken.
|
1 | else if(str == "NON_BLOCK"){return PRecvFlag::NON_BLOCK;} |
| 105 | ✗ | throw std::invalid_argument("Invalid PRecvFlag string: " + str); | |
| 106 | } | ||
| 107 | |||
| 108 | ///Convert a std::string into a PRecvStatus | ||
| 109 | /** @param str : std::string to be converted | ||
| 110 | * @return corresponding PRecvStatus | ||
| 111 | */ | ||
| 112 | template<> | ||
| 113 | 8 | PRecvStatus::PRecvStatus fromString<PRecvStatus::PRecvStatus>(const std::string& str){ | |
| 114 |
2/2✓ Branch 0 (3→4) taken 1 times.
✓ Branch 1 (3→5) taken 7 times.
|
8 | if(str == "OK"){return PRecvStatus::OK;} |
| 115 |
2/2✓ Branch 0 (6→7) taken 1 times.
✓ Branch 1 (6→8) taken 6 times.
|
7 | else if(str == "NO_MESSAGE_RECEIVED"){return PRecvStatus::NO_MESSAGE_RECEIVED;} |
| 116 |
2/2✓ Branch 0 (9→10) taken 1 times.
✓ Branch 1 (9→11) taken 5 times.
|
6 | else if(str == "INVALID_MESSAGE"){return PRecvStatus::INVALID_MESSAGE;} |
| 117 |
2/2✓ Branch 0 (12→13) taken 1 times.
✓ Branch 1 (12→14) taken 4 times.
|
5 | else if(str == "SOCKET_NOT_AVAILABLE"){return PRecvStatus::SOCKET_NOT_AVAILABLE;} |
| 118 |
2/2✓ Branch 0 (15→16) taken 1 times.
✓ Branch 1 (15→17) taken 3 times.
|
4 | else if(str == "SIGNAL_INTERRUPTION"){return PRecvStatus::SIGNAL_INTERRUPTION;} |
| 119 |
2/2✓ Branch 0 (18→19) taken 1 times.
✓ Branch 1 (18→20) taken 2 times.
|
3 | else if(str == "BROKEN_BACKEND"){return PRecvStatus::BROKEN_BACKEND;} |
| 120 |
2/2✓ Branch 0 (21→22) taken 1 times.
✓ Branch 1 (21→23) taken 1 times.
|
2 | else if(str == "BROKEN_SOCKET"){return PRecvStatus::BROKEN_SOCKET;} |
| 121 |
1/2✓ Branch 0 (24→25) taken 1 times.
✗ Branch 1 (24→26) not taken.
|
1 | else if(str == "CANNOT_DESERIALIZE_DATA"){return PRecvStatus::CANNOT_DESERIALIZE_DATA;} |
| 122 | ✗ | throw std::invalid_argument("Invalid PRecvStatus string: " + str); | |
| 123 | } | ||
| 124 |