[core] Make enum ↔ string conversion more generic-friendly

Rewrite enum.hpp in such a way that parseConstant can be defined generically for all enumerated types.

While there, properly validated enumerated property values.
This commit is contained in:
John Firebaugh
2016-06-10 21:17:23 -07:00
parent 36bef21575
commit 282e626ac1
15 changed files with 194 additions and 258 deletions

View File

@@ -18,6 +18,7 @@
#include <mbgl/util/token.hpp>
#include <mbgl/util/string.hpp>
#include <mbgl/util/tile_cover.hpp>
#include <mbgl/util/enum.hpp>
#include <mbgl/tile/raster_tile.hpp>
#include <mbgl/tile/geojson_tile.hpp>
@@ -197,8 +198,7 @@ std::unique_ptr<Tile> Source::createTile(const OverscaledTileID& overscaledTileI
} else if (type == SourceType::GeoJSON) {
return std::make_unique<GeoJSONTile>(overscaledTileID, id, parameters, geojsonvt.get());
} else {
Log::Warning(Event::Style, "Source type '%s' is not implemented",
SourceTypeClass(type).c_str());
Log::Warning(Event::Style, "Source type '%s' is not implemented", Enum<SourceType>::toString(type));
return nullptr;
}
}