1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
enum keyword_t { LOCAL_TIME, WEATHER, TEMP_STRING, HUMIDITY, WIND, PRESSURE, PRESSURE_TREND, HEAT_INDEX, NOWCAST, UNKNOWN };
keyword_t keyword ;
bool getNowCast = true ;
void noteKeyword( const std::string& token )
{
static const std::unordered_map< std::string, keyword_t > lookup = // #include <unordered_map>
{
{ "local_time_rfc822", LOCAL_TIME },
{ "weather", WEATHER },
{ "temperature_string", TEMP_STRING },
{ "relative_humidity", HUMIDITY },
{ "wind_string", WIND },
{ "pressure_in", PRESSURE },
{ "pressure_trend", PRESSURE_TREND },
{ "heat_index_string", HEAT_INDEX },
{ "nowcast", NOWCAST },
};
const auto iter = lookup.find(token) ;
if( iter != lookup.end() ) keyword = iter->second ;
else keyword = UNKNOWN ;
if( keyword == NOWCAST && !getNowCast ) keyword = UNKNOWN ;
}
|