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.

88 lines
1.2 KiB

  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. default:
  35. return "END";
  36. }
  37. }
  38. static MODE mode(const std::string &mode)
  39. {
  40. if (mode == "ALICE")
  41. return ALICE;
  42. if (mode == "BOB")
  43. return BOB;
  44. return END;
  45. }
  46. static SHAPE shape(const std::string &shape)
  47. {
  48. if (shape == "TRIANGLE")
  49. return TRIANGLE;
  50. if (shape == "CIRCLE")
  51. return CIRCLE;
  52. if (shape == "SQUARE")
  53. return SQUARE;
  54. if (shape == "PENTAGON")
  55. return PENTAGON;
  56. return UNKOWN;
  57. }
  58. static std::string shape(const SHAPE &shape)
  59. {
  60. std::string message;
  61. switch (shape)
  62. {
  63. case TRIANGLE:
  64. message = "TRIANGLE";
  65. break;
  66. case CIRCLE:
  67. message = "CIRCLE";
  68. break;
  69. case SQUARE:
  70. message = "SQUARE";
  71. break;
  72. case PENTAGON:
  73. message = "PENTAGON";
  74. break;
  75. default:
  76. message = "UNKOWN";
  77. break;
  78. }
  79. return message;
  80. }
  81. };
  82. } // namespace betacore
  83. #endif