# TypeResolver.hpp
This File On Github
Ask A Question
API: latest
module: oatpp
#include "oatpp/core/data/mapping/TypeResolver.hpp"
# TypeResolver
Helper class to work with oatpp types.
namespace oatpp { namespace data { namespace mapping {
class TypeResolver {}
}}}
# Methods
Return Type | Name | Summary |
---|---|---|
[none] | TypeResolver | Default constructor. |
[none] | ~TypeResolver | Virtual destructor. |
void | setKnownClass | Set if the type class is considered known/unknown |
void | addKnownClasses | Set all mentioned type classes as known. |
bool | isKnownClass | Check if type class is known. |
bool | isKnownType | Check if type is known. |
void | setEnabledInterpretations | Set enabled type interpretations. |
const std::vector<std::string>& | getEnabledInterpretations | Get enabled type interpretations. |
const type::Type* | resolveType | Resolve unknown type according to enabled interpretations. |
type::Void | resolveValue | Resolve unknown value according to enabled interpretations. |
const type::Type* | resolveObjectPropertyType | Traverse object property tree resolving unknown types according to enabled interpretations. |
type::Void | resolveObjectPropertyValue | Traverse object property tree resolving unknown value types according to enabled interpretations. |
# TypeResolver::TypeResolver
Default constructor.
TypeResolver()
# TypeResolver::~TypeResolver
Virtual destructor.
virtual ~TypeResolver() = default
# TypeResolver::setKnownClass
Set if the type class is considered known/unknown
- @param classId
- @param isKnown
void setKnownClass(const type::ClassId& classId, bool isKnown)
# TypeResolver::addKnownClasses
Set all mentioned type classes as known.
- @param knownClasses
void addKnownClasses(const std::vector<type::ClassId>& knownClasses)
# TypeResolver::isKnownClass
Check if type class is known.
- @param classId
- @return
bool isKnownClass(const type::ClassId& classId) const
# TypeResolver::isKnownType
Check if type is known.
- @param type
- @return
bool isKnownType(const type::Type* type) const
# TypeResolver::setEnabledInterpretations
Set enabled type interpretations.
- @param interpretations
void setEnabledInterpretations(const std::vector<std::string>& interpretations)
# TypeResolver::getEnabledInterpretations
Get enabled type interpretations.
- @return
const std::vector<std::string>& getEnabledInterpretations() const
# TypeResolver::resolveType
Resolve unknown type according to enabled interpretations.
- @param type - type to resolve.
- @param cache - local cache.
- @return
const type::Type* resolveType(const type::Type* type, Cache& cache) const
# TypeResolver::resolveValue
Resolve unknown value according to enabled interpretations.
- @param value - value to resolve.
- @param cache - local cache.
- @return
type::Void resolveValue(const type::Void& value, Cache& cache) const
# TypeResolver::resolveObjectPropertyType
Traverse object property tree resolving unknown types according to enabled interpretations.
- @param objectType - base object type.
- @param path - vector of property names.
- @param cache - local cache.
- @return - oatpp::Type.
nullptr
- if couldn't resolve.
const type::Type* resolveObjectPropertyType(const type::Type* objectType,
const std::vector<std::string>& path,
Cache& cache) const
# TypeResolver::resolveObjectPropertyValue
Traverse object property tree resolving unknown value types according to enabled interpretations.
- @param object - base object.
- @param path - vector of property names.
- @param cache - local cache.
- @return - value as oatpp::Void. The
valueType
will be set to resolved type or tooatpp::Void::Class::getType()
if couldn't resolve.
type::Void resolveObjectPropertyValue(const type::Void& object,
const std::vector<std::string>& path,
Cache& cache) const
# TypeResolver::Cache
Local resolution cache used to reduce number of type interpretation iterations.
namespace oatpp { namespace data { namespace mapping {
class TypeResolver {
struct Cache {}
};
}}}
# Fields
Type | Name | Summary |
---|---|---|
std::unordered_map<const type::Type*, const type::Type*> | types | types map. |
std::unordered_map<const type::Type*, std::unordered_map<type::Void, type::Void>> | values | values by type map. |
# TypeResolver::Cache::types
types map.
std::unordered_map<const type::Type*, const type::Type*> types
# TypeResolver::Cache::values
values by type map.
std::unordered_map<const type::Type*, std::unordered_map<type::Void, type::Void>> values