Advertisement
den4ik2003

Untitled

Apr 27th, 2024
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. #include <string>
  2. #include <vector>
  3. #include <unordered_map>
  4.  
  5. #include <main/enums.hpp>
  6. #include <strategy/enums.hpp>
  7. #include <parsing/enums.hpp>
  8.  
  9. namespace mira {
  10.  
  11. struct input_parameter_wrapper { // проблема, что нет взаимоисключения, что если PLAIN_PARAMETER, то обязательно ТОЛЬКО parameter должен быть
  12. struct market_parameter {
  13. mira::parsing::e_market market;
  14. mira::e_strategy strategy;
  15. std::string symbol_str;
  16. };
  17.  
  18. e_input_parameter_type type;
  19. union { // м.б. вместо union использовать std::variant?
  20. std::string parameter;
  21. std::vector<market_parameter> market_parameters;
  22. };
  23.  
  24. static std::unordered_map<std::string, std::string> convert_market_input_to_plain(const std::unordered_map<std::string, input_parameter_wrapper>&);
  25.  
  26. e_input_parameter_type& operator=(input_parameter_wrapper& other) {
  27. type = other.type;
  28. if (type == e_input_parameter_type::PLAIN_PARAMETER) {
  29. parameter = other.parameter;
  30. } else if (type == e_input_parameter_type::MARKET_PARAMETER) {
  31. market_parameters = other.market_parameters;
  32. }
  33. }
  34.  
  35. ~input_parameter_wrapper() { // is it necessary to do?
  36. if (type == e_input_parameter_type::MARKET_PARAMETER) {
  37. market_parameters.~vector();
  38. } else if (type == e_input_parameter_type::PLAIN_PARAMETER) {
  39. parameter.~basic_string();
  40. }
  41. }
  42. };
  43.  
  44. } // namespace mira
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement