|
Boost Users : |
From: Filip KonviÄka (filip.konvicka_at_[hidden])
Date: 2007-05-31 04:22:14
Hello all,
for those interested, here is an alpha version of a MSVC-8.0 visualizer
for multi_index_containers whose first index is sequenced<>. To try it
out, insert autoexp.dat.txt contents into your
Microsoft Visual Studio 8\Common7\Packages\Debugger\autoexp.dat
For your container to be visualized, you need to call the
VISUALIZE_MULTI_INDEX_CONTAINER macro at the global namespace level (see
the attached example, test2.cpp, and the screenshot of a test2.cpp
debugging session, sample.png).
Comments / suggestions are welcome!
Things that need attention:
- of course, containers whose first index is not sequenced<>
- maybe there is a better way of enforcing template instantiation...?
- possible name conflict issues, you guys probably know better than I do :-)
Cheers,
Filip
P.S.: My colleague says that this is black magic, so beware :-)
#include "common.hpp"
int wmain() {
cont test_cont;
test_cont.push_back(test(L"aaa"));
test_cont.push_back(test(L"bbb"));
test_cont.push_back(test(L"bbbx"));
test_cont.push_back(test(L"bbbss"));
test_cont.push_back(test(L"ccc", L"ddd"));
return 0; // see screenshot
}
#ifndef MIC_VISUALIZER_HPP
#define MIC_VISUALIZER_HPP
template<typename T>
struct multi_index_helper {
};
template<typename T>
struct multi_index_helper_2 {
};
template<typename T>
struct multi_index_helper_3 {
};
#define __VISUALIZE_MIC_INDEX_DEF(Type) \
boost::multi_index::detail::multi_index_node_type< \
Type::value_type, \
Type::index_specifier_type_list, \
std::allocator<Type::value_type> >::type
/// Enables MSVC visualizers for multi_index_container Type
#define VISUALIZE_MULTI_INDEX_CONTAINER(Type) \
template<> \
struct multi_index_helper_2<Type> { \
typedef __VISUALIZE_MIC_INDEX_DEF(Type) index_node_type; \
typedef \
boost::base_from_member< \
boost::detail::allocator::rebind_to< \
std::allocator<Type::value_type>, \
index_node_type \
>::type> \
base_type; \
typedef \
boost::multi_index::detail::header_holder< \
index_node_type, Type> \
header_holder_type; \
typedef \
boost::multi_index::detail::multi_index_base_type< \
Type::value_type, \
Type::index_specifier_type_list, \
std::allocator<Type::value_type> >::type \
index_type; \
/* mimic multi_index_container layout */ \
base_type base; \
header_holder_type header; \
index_type index; \
unsigned int node_count; \
/* ensure that the debugger sees this template instance */ \
static void get() { \
multi_index_helper_2<Type> *ensure_inst=0; \
} \
}; \
template<> \
struct multi_index_helper_3<Type> { \
typedef __VISUALIZE_MIC_INDEX_DEF(Type) index_node_type; \
typedef \
boost::multi_index::detail::header_holder< \
index_node_type, Type> \
header_holder_type; \
typedef \
boost::multi_index::detail::multi_index_base_type< \
Type::value_type, \
Type::index_specifier_type_list, \
std::allocator<Type::value_type> >::type \
index_type; \
/* mimic multi_index_container layout from header field */ \
header_holder_type header; \
index_type index; \
unsigned int node_count; \
/* ensure that the debugger sees this template instance */ \
static void get() { \
multi_index_helper_3<Type> *ensure_inst=0; \
} \
}; \
template<> \
struct multi_index_helper<__VISUALIZE_MIC_INDEX_DEF(Type)> { \
typedef __VISUALIZE_MIC_INDEX_DEF(Type) index_node_type; \
/* mimic index_node_base<Type::value_type> layout */ \
Type::value_type value; \
/* ensure that the debugger sees this template instance */ \
static void get() { \
multi_index_helper<index_node_type> *ensure_inst=0; \
} \
};
#endif
;-------------------------------
; boost::multi_index_container
;
boost::multi_index::detail::header_holder<boost::multi_index::detail::sequenced_index_node<*>,*>{
preview(#("multi_index_container data"))
children(
#(
#list(
head : *(((boost::multi_index::detail::sequenced_index_node_impl*)(boost::multi_index::detail::sequenced_index_node_trampoline<$T1>*)($c.member))->next_),
size : ((multi_index_helper_3<$T2>*)&$c)->node_count,
next : next_
) : *(multi_index_helper<boost::multi_index::detail::sequenced_index_node<$T1> >*)(boost::multi_index::detail::sequenced_index_node<$T1>*)(boost::multi_index::detail::sequenced_index_node_trampoline<$T1>*)(&$e)
)
)
}
multi_index_helper<*> {
preview(#($c.value))
children(#(value:$c.value))
}
boost::multi_index::multi_index_container<*,*,*>{
preview(#($c.node_count, " nodes"))
children(
#(
data:((multi_index_helper_2<boost::multi_index::multi_index_container<$T1,$T2,$T3> >*)&$c)->header,
original members: [$c,!]
)
)
}
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net