Framework update.

This commit is contained in:
stephb9959
2022-05-31 23:26:05 -07:00
parent 5c44134f9d
commit cafc243e55

View File

@@ -5,6 +5,7 @@
#pragma once #pragma once
#include <string> #include <string>
#include <cstring>
#include "Poco/String.h" #include "Poco/String.h"
#if defined(__GNUC__) #if defined(__GNUC__)
@@ -428,6 +429,7 @@ namespace OpenWifi::uCentralProtocol {
static const char *RADIUSACCT = "acct"; static const char *RADIUSACCT = "acct";
static const char *RADIUSAUTH = "auth"; static const char *RADIUSAUTH = "auth";
static const char *RADIUSDST = "dst"; static const char *RADIUSDST = "dst";
static const char *IES = "ies";
} }
namespace OpenWifi::uCentralProtocol::Events { namespace OpenWifi::uCentralProtocol::Events {
@@ -458,7 +460,7 @@ namespace OpenWifi::uCentralProtocol::Events {
}; };
inline static EVENT_MSG EventFromString(const std::string & Method) { inline static EVENT_MSG EventFromString(const std::string & Method) {
static std::vector<std::pair<const char *,EVENT_MSG>> Values{ static std::vector<std::pair<const char *,EVENT_MSG>> EventValues{
{ CFGPENDING , ET_CFGPENDING }, { CFGPENDING , ET_CFGPENDING },
{ CONNECT, ET_CONNECT }, { CONNECT, ET_CONNECT },
{ CRASHLOG, ET_CRASHLOG }, { CRASHLOG, ET_CRASHLOG },
@@ -471,11 +473,12 @@ namespace OpenWifi::uCentralProtocol::Events {
{ TELEMETRY, ET_TELEMETRY } { TELEMETRY, ET_TELEMETRY }
}; };
std::string L = Poco::toLower(Method); const auto l_method = Poco::toLower(Method);
auto hint = std::find_if(cbegin(Values),cend(Values),[&](const std::pair<const char *,EVENT_MSG> &v) ->bool { return strcmp(v.first,L.c_str())==0; }); for(const auto &[event_name,event_type]:EventValues) {
if(hint == cend(Values)) if(std::strcmp(event_name,Method.c_str())==0)
return ET_UNKNOWN; return event_type;
return hint->second; }
return ET_UNKNOWN;
}; };
} }