diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-04-26 16:39:56 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-06-02 14:51:39 -0700 |
commit | c902f9098b331302aaa1baac77d1575db624a132 (patch) | |
tree | 211901cd04454aedbac40c469198438e46d7038c /src/mbgl/style/parser.hpp | |
parent | 18149cbcc27a926f280b08d8d0e09104b2147688 (diff) | |
download | qtlocation-mapboxgl-c902f9098b331302aaa1baac77d1575db624a132.tar.gz |
[core] Rationalize naming for style-related code
Diffstat (limited to 'src/mbgl/style/parser.hpp')
-rw-r--r-- | src/mbgl/style/parser.hpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/mbgl/style/parser.hpp b/src/mbgl/style/parser.hpp new file mode 100644 index 0000000000..ea821fabde --- /dev/null +++ b/src/mbgl/style/parser.hpp @@ -0,0 +1,55 @@ +#pragma once + +#include <mbgl/style/layer.hpp> +#include <mbgl/style/source.hpp> +#include <mbgl/style/filter.hpp> + +#include <mbgl/util/rapidjson.hpp> +#include <mbgl/util/font_stack.hpp> + +#include <vector> +#include <memory> +#include <string> +#include <unordered_map> +#include <forward_list> + +namespace mbgl { +namespace style { + +std::unique_ptr<Tileset> parseTileJSON(const std::string& json, const std::string& sourceURL, SourceType, uint16_t tileSize); +std::unique_ptr<Tileset> parseTileJSON(const JSValue&); + +std::unique_ptr<mapbox::geojsonvt::GeoJSONVT> parseGeoJSON(const JSValue&); + +Filter parseFilter(const JSValue&); + +class Parser { +public: + ~Parser(); + + void parse(const std::string&); + + std::string spriteURL; + std::string glyphURL; + + std::vector<std::unique_ptr<Source>> sources; + std::vector<std::unique_ptr<Layer>> layers; + + // Statically evaluate layer properties to determine what font stacks are used. + std::vector<FontStack> fontStacks() const; + +private: + void parseSources(const JSValue&); + void parseLayers(const JSValue&); + void parseLayer(const std::string& id, const JSValue&, std::unique_ptr<Layer>&); + void parseVisibility(Layer&, const JSValue& value); + + std::unordered_map<std::string, const Source*> sourcesMap; + std::unordered_map<std::string, std::pair<const JSValue&, std::unique_ptr<Layer>>> layersMap; + + // Store a stack of layer IDs we're parsing right now. This is to prevent reference cycles. + std::forward_list<std::string> stack; +}; + +} // namespace style +} // namespace mbgl |