2022-12-19 14:37:51 +00:00
|
|
|
[info]
|
2023-05-23 22:26:38 +01:00
|
|
|
type_name = "std::map"
|
|
|
|
stub_template_params = [2,3]
|
2022-12-19 14:37:51 +00:00
|
|
|
ctype = "STD_MAP_TYPE"
|
|
|
|
header = "map"
|
2023-05-23 22:26:38 +01:00
|
|
|
|
|
|
|
# Old:
|
|
|
|
typeName = "std::map<"
|
2022-12-19 14:37:51 +00:00
|
|
|
ns = ["namespace std"]
|
2023-05-23 22:26:38 +01:00
|
|
|
numTemplateParams = 2
|
2022-12-19 14:37:51 +00:00
|
|
|
replaceTemplateParamIndex = [2]
|
|
|
|
allocatorIndex = 3
|
|
|
|
|
|
|
|
[codegen]
|
|
|
|
decl = """
|
|
|
|
template<class K, class T, class C, class A>
|
|
|
|
void getSizeType(const %1%<K, T, C, A> &container, size_t& returnArg);
|
|
|
|
"""
|
|
|
|
|
|
|
|
func = """
|
|
|
|
template<class K, class T, class C, class A>
|
|
|
|
void getSizeType(const %1%<K, T, C, A> &container, size_t& returnArg)
|
|
|
|
{
|
|
|
|
constexpr size_t nodeSize = sizeof(typename %1%<K, T, C, A>::node_type);
|
|
|
|
size_t numElems = container.size();
|
|
|
|
|
|
|
|
SAVE_SIZE(sizeof(%1%<K, T, C, A>) + (nodeSize * numElems));
|
|
|
|
|
|
|
|
SAVE_DATA((uintptr_t)nodeSize);
|
|
|
|
SAVE_DATA((uintptr_t)numElems);
|
|
|
|
|
|
|
|
for (auto const& it : container)
|
|
|
|
{
|
|
|
|
getSizeType(it.first, returnArg);
|
|
|
|
getSizeType(it.second, returnArg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
2023-04-20 17:52:58 +01:00
|
|
|
|
|
|
|
handler = """
|
|
|
|
template <typename DB, typename T0, typename T1, typename T2, typename T3>
|
|
|
|
struct TypeHandler<DB, %1%<T0, T1, T2, T3>> {
|
2023-06-29 13:07:46 +01:00
|
|
|
using type = types::st::Pair<DB,
|
|
|
|
types::st::VarInt<DB>,
|
|
|
|
types::st::List<DB, types::st::Pair<DB,
|
2023-04-20 17:52:58 +01:00
|
|
|
typename TypeHandler<DB, T0>::type,
|
|
|
|
typename TypeHandler<DB, T1>::type
|
|
|
|
>>>;
|
|
|
|
|
2023-06-29 13:07:46 +01:00
|
|
|
static types::st::Unit<DB> getSizeType(
|
2023-04-20 17:52:58 +01:00
|
|
|
const %1%<T0, T1, T2, T3>& container,
|
|
|
|
typename TypeHandler<DB, %1%<T0, T1, T2, T3>>::type returnArg) {
|
|
|
|
constexpr size_t nodeSize = sizeof(typename %1%<T0, T1, T2, T3>::node_type);
|
|
|
|
|
|
|
|
auto tail = returnArg.write(nodeSize).write(container.size());
|
|
|
|
|
|
|
|
// The double ampersand is needed otherwise this loop doesn't work with
|
|
|
|
// vector<bool>
|
|
|
|
for (const auto& it : container) {
|
|
|
|
tail = tail.delegate([&it](auto ret) {
|
|
|
|
return OIInternal::getSizeType<DB>(it.second, ret.delegate([&it](auto ret) {
|
|
|
|
return OIInternal::getSizeType<DB>(it.first, ret);
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return tail.finish();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
"""
|