[info] type_name = "std::vector" stub_template_params = [1] header = "vector" # Old: ctype = "SEQ_TYPE" typeName = "std::vector<" ns = ["namespace std"] numTemplateParams = 1 allocatorIndex = 1 [codegen] decl = """ template void getSizeType(const %1% &container, size_t& returnArg); """ func = """ template void getSizeType(const %1% &container, size_t& returnArg) { SAVE_SIZE(sizeof(%1%)); SAVE_DATA((uintptr_t)&container); SAVE_DATA((uintptr_t)container.capacity()); SAVE_DATA((uintptr_t)container.size()); SAVE_SIZE((container.capacity() - container.size()) * sizeof(T)); // The double ampersand is needed otherwise this loop doesn't work with vector for (auto&& it: container) { getSizeType(it, returnArg); } } """ handler = """ template struct TypeHandler> { using type = types::st::Pair< DB, types::st::VarInt, types::st::Pair< DB, types::st::VarInt, types::st::List::type>>>; static types::st::Unit getSizeType( const %1% & container, typename TypeHandler>::type returnArg) { auto tail = returnArg.write((uintptr_t)&container) .write(container.capacity()) .write(container.size()); // The double ampersand is needed otherwise this loop doesn't work with // vector for (auto&& it : container) { tail = tail.delegate([&it](auto ret) { return OIInternal::getSizeType(it, ret); }); } return tail.finish(); } }; """ traversal_func = """ auto tail = returnArg.write((uintptr_t)&container) .write(container.capacity()) .write(container.size()); // The double ampersand is needed otherwise this loop doesn't work with // vector for (auto&& it : container) { tail = tail.delegate([&it](auto ret) { return OIInternal::getSizeType(it, ret); }); } return tail.finish(); """ [[codegen.processor]] type = "types::st::VarInt" func = """ el.pointer = std::get(d.val).value; """ [[codegen.processor]] type = "types::st::VarInt" func = """ el.container_stats.emplace(result::Element::ContainerStats{ .capacity = std::get(d.val).value }); """ [[codegen.processor]] type = "types::st::List::type>" func = """ static constexpr auto childField = make_field("[]"); auto list = std::get(d.val); el.container_stats->length = list.length; el.exclusive_size += (el.container_stats->capacity - el.container_stats->length) * sizeof(T0); for (size_t i = 0; i < list.length; i++) stack_ins(childField); """