mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-05 17:44:52 +01:00
Don't throw an exception when a compound field is not found
This commit is contained in:
parent
8403a4e71c
commit
d922636311
1 changed files with 7 additions and 5 deletions
|
@ -54,13 +54,15 @@ public:
|
||||||
return Type::Compound;
|
return Type::Compound;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T> std::shared_ptr<const T> get(const std::string &key) const {
|
||||||
std::shared_ptr<const T> get(const std::string &key) const {
|
auto it = find(key);
|
||||||
return std::dynamic_pointer_cast<const T>(at(key));
|
if (it == end())
|
||||||
|
return std::shared_ptr<const T>();
|
||||||
|
|
||||||
|
return std::dynamic_pointer_cast<const T>(it->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename... Args>
|
template<typename T, typename... Args> std::shared_ptr<const T> get(const std::string &key, const Args &...args) const {
|
||||||
std::shared_ptr<const T> get(const std::string &key, const Args &...args) const {
|
|
||||||
std::shared_ptr<const CompoundTag> tag = get<CompoundTag>(key);
|
std::shared_ptr<const CompoundTag> tag = get<CompoundTag>(key);
|
||||||
if (!tag)
|
if (!tag)
|
||||||
return std::shared_ptr<const T>();
|
return std::shared_ptr<const T>();
|
||||||
|
|
Loading…
Add table
Reference in a new issue