Porytiles
Loading...
Searching...
No Matches
enum_map_provider.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <functional>
5#include <map>
6#include <memory>
7#include <string>
8
10
11namespace porytiles {
12
26 public:
27 virtual ~EnumMapProvider() = default;
28
33 [[nodiscard]] virtual ChainableResult<std::uint32_t> lookup(const std::string &name) const = 0;
34
39 [[nodiscard]] virtual ChainableResult<std::string> lookup(std::uint32_t value) const = 0;
40};
41
50using ProviderMap = std::map<std::string, std::unique_ptr<EnumMapProvider>, std::less<>>;
51
52} // namespace porytiles
A result type that maintains a chainable sequence of errors for debugging and error reporting.
Abstract interface for providing two-way name/value mappings for an enumerated attribute field.
virtual ChainableResult< std::string > lookup(std::uint32_t value) const =0
Looks up the constant name for a numeric value.
virtual ~EnumMapProvider()=default
virtual ChainableResult< std::uint32_t > lookup(const std::string &name) const =0
Looks up the numeric value for a constant name.
std::string name
std::map< std::string, std::unique_ptr< EnumMapProvider >, std::less<> > ProviderMap
Maps schema field names to the provider that names that field's values.