@@ -308,6 +308,17 @@ public:
|
|||||||
delete it->second;
|
delete it->second;
|
||||||
m_pairs.erase(it);
|
m_pairs.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Checks whether a handle exists inside.
|
||||||
|
*
|
||||||
|
* @param id Identifier of the handle.
|
||||||
|
* @return true if the handle exists insdie of this container.
|
||||||
|
*/
|
||||||
|
template <typename IdFwd>
|
||||||
|
constexpr bool contains(IdFwd&& id) const {
|
||||||
|
return m_pairs.find(std::forward<IdFwd>(id)) != m_pairs.end();
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
std::unordered_map<id_type, pair_type*> m_pairs;
|
std::unordered_map<id_type, pair_type*> m_pairs;
|
||||||
};
|
};
|
||||||
@@ -395,6 +406,14 @@ public:
|
|||||||
delete m_pairs[id];
|
delete m_pairs[id];
|
||||||
m_pairs[id] = nullptr;
|
m_pairs[id] = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Checks whether a handle exists inside.
|
||||||
|
*
|
||||||
|
* @param id Identifier of the handle.
|
||||||
|
* @return true if the handle exists insdie of this container.
|
||||||
|
*/
|
||||||
|
constexpr bool contains(id_type id) const { return id < m_pairs.size() && m_pairs[id] != nullptr; }
|
||||||
public:
|
public:
|
||||||
auto begin() { return m_pairs.begin(); }
|
auto begin() { return m_pairs.begin(); }
|
||||||
auto begin() const { return m_pairs.begin(); }
|
auto begin() const { return m_pairs.begin(); }
|
||||||
|
|||||||
@@ -12,8 +12,14 @@ std::ostream& mod::serialize(std::ostream& os) const {
|
|||||||
detail::serialize(os, std::uint32_t(0)); // version
|
detail::serialize(os, std::uint32_t(0)); // version
|
||||||
|
|
||||||
detail::serialize(os, function_id(m_functionMap.size()));
|
detail::serialize(os, function_id(m_functionMap.size()));
|
||||||
for (auto* pair : m_functions) {
|
for (function_id id = 0; id < m_functions.cend() - m_functions.cbegin(); ++id) {
|
||||||
function_h func = { pair };
|
if (!m_functions.contains(id)) {
|
||||||
|
detail::serialize(os, "");
|
||||||
|
detail::serialize(os, std::uint8_t(0xFF)); // null function
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
function_h func = m_functions.at(id);
|
||||||
bool isPublic = m_publicFunctions.find(func->name()) != m_publicFunctions.end();
|
bool isPublic = m_publicFunctions.find(func->name()) != m_publicFunctions.end();
|
||||||
detail::serialize(os, isPublic ? func->name() : ""); // private functions have empty names
|
detail::serialize(os, isPublic ? func->name() : ""); // private functions have empty names
|
||||||
detail::serialize(os, std::uint8_t(func->type()));
|
detail::serialize(os, std::uint8_t(func->type()));
|
||||||
|
|||||||
Reference in New Issue
Block a user