Browse Source

update

master
zhaohe 2 years ago
parent
commit
99f14adcb3
  1. 5
      core/basic/enum_converter.hpp

5
core/basic/enum_converter.hpp

@ -16,6 +16,8 @@
#include <typeinfo> #include <typeinfo>
#include <vector> #include <vector>
#include "iflytopcpp/core/spdlogfactory/logger.hpp"
namespace iflytop { namespace iflytop {
namespace core { namespace core {
using namespace std; using namespace std;
@ -34,13 +36,14 @@ class EnumConverter {
if (it != _str2e.end()) { if (it != _str2e.end()) {
return it->second; return it->second;
} }
return "unkown";
return fmt::format("unkown({})", (int)e);
}; };
T str2e(string s) { T str2e(string s) {
auto it = _e2str.find(s); auto it = _e2str.find(s);
if (it != _e2str.end()) { if (it != _e2str.end()) {
return it->second; return it->second;
} }
throw std::invalid_argument(fmt::format("EnumConverter unkown convert ({})", s));
return (T)-1; return (T)-1;
}; };
}; };

Loading…
Cancel
Save