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::allocatorType::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::allocatorType::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::allocatorType::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::allocatorType::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_baseType::value_type layout */ \
Type::value_type value; \
/* ensure that the debugger sees this template instance */ \
static void get() { \
multi_index_helper