You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
1.2 KiB

5 years ago
  1. #ifndef __BETACORE_COMMON_HPP__
  2. #define __BETACORE_COMMON_HPP__
  3. #define BUFFER_LENGTH 1024
  4. #include <string>
  5. namespace betacore
  6. {
  7. enum SHAPE
  8. {
  9. NONE,
  10. TRIANGLE,
  11. CIRCLE,
  12. SQUARE,
  13. PENTAGON,
  14. UNKOWN
  15. };
  16. enum MODE
  17. {
  18. ALICE,
  19. BOB,
  20. EVE,
  21. END
  22. };
  23. class Parser
  24. {
  25. public:
  26. static std::string mode(MODE &mode)
  27. {
  28. switch (mode)
  29. {
  30. case ALICE:
  31. return "ALICE";
  32. case BOB:
  33. return "BOB";
  34. case EVE:
  35. return "EVE";
  36. default:
  37. return "END";
  38. }
  39. }
  40. static MODE mode(const std::string &mode)
  41. {
  42. if (mode == "ALICE")
  43. return ALICE;
  44. if (mode == "BOB")
  45. return BOB;
  46. return END;
  47. }
  48. static SHAPE shape(const std::string &shape)
  49. {
  50. if (shape == "TRIANGLE")
  51. return TRIANGLE;
  52. if (shape == "CIRCLE")
  53. return CIRCLE;
  54. if (shape == "SQUARE")
  55. return SQUARE;
  56. if (shape == "PENTAGON")
  57. return PENTAGON;
  58. return UNKOWN;
  59. }
  60. static std::string shape(const SHAPE &shape)
  61. {
  62. std::string message;
  63. switch (shape)
  64. {
  65. case TRIANGLE:
  66. message = "TRIANGLE";
  67. break;
  68. case CIRCLE:
  69. message = "CIRCLE";
  70. break;
  71. case SQUARE:
  72. message = "SQUARE";
  73. break;
  74. case PENTAGON:
  75. message = "PENTAGON";
  76. break;
  77. default:
  78. message = "UNKOWN";
  79. break;
  80. }
  81. return message;
  82. }
  83. };
  84. } // namespace betacore
  85. #endif