Refactoring: Pass all the control over the variables to the Variables class

This commit is contained in:
Felipe Zimmerle
2015-10-28 20:51:54 -03:00
parent 6f617e6ca8
commit 787be98122
11 changed files with 316 additions and 251 deletions

View File

@@ -44,42 +44,42 @@ bool GeoLookup::evaluate(Assay *assay, const std::string &exp) {
}
if (ret && gir) {
if (gir->country_code) {
assay->store_variable("GEO:COUNTRY_CODE", gir->country_code);
assay->m_variables.store("GEO:COUNTRY_CODE", gir->country_code);
}
if (gir->country_code3) {
assay->store_variable("GEO:COUNTRY_CODE3", gir->country_code3);
assay->m_variables.store("GEO:COUNTRY_CODE3", gir->country_code3);
}
if (gir->country_name) {
assay->store_variable("GEO:COUNTRY_NAME", gir->country_name);
assay->m_variables.store("GEO:COUNTRY_NAME", gir->country_name);
}
if (gir->continent_code) {
assay->store_variable("GEO:COUNTRY_CONTINENT",
assay->m_variables.store("GEO:COUNTRY_CONTINENT",
gir->continent_code);
}
if (gir->country_code && gir->region) {
assay->store_variable("GEO:REGION",
assay->m_variables.store("GEO:REGION",
GeoIP_region_name_by_code(gir->country_code, gir->region));
}
if (gir->city) {
assay->store_variable("GEO:CITY", gir->city);
assay->m_variables.store("GEO:CITY", gir->city);
}
if (gir->postal_code) {
assay->store_variable("GEO:POSTAL_CODE", gir->postal_code);
assay->m_variables.store("GEO:POSTAL_CODE", gir->postal_code);
}
if (gir->latitude) {
assay->store_variable("GEO:LATITUDE",
assay->m_variables.store("GEO:LATITUDE",
std::to_string(gir->latitude));
}
if (gir->longitude) {
assay->store_variable("GEO:LONGITUDE",
assay->m_variables.store("GEO:LONGITUDE",
std::to_string(gir->longitude));
}
if (gir->metro_code) {
assay->store_variable("GEO:DMA_CODE",
assay->m_variables.store("GEO:DMA_CODE",
std::to_string(gir->metro_code));
}
if (gir->area_code) {
assay->store_variable("GEO:AREA_CODE",
assay->m_variables.store("GEO:AREA_CODE",
std::to_string(gir->area_code));
}