indicates the object to be an STL container,
// and given the size of its value_type (retrieved via debug information),
// return number of elements and an iterator (any data it needs is stored in
// it_mem, which must hold DEBUG_STL_MAX_ITERATOR_SIZE bytes).
// returns 0 on success or an StlContainerError.
LibError debug_stl_get_container_info(const wchar_t* type_name, const u8* p, size_t size,
size_t el_size, size_t* el_count, DebugStlIterator* el_iterator, void* it_mem)
{
#if MSC_VERSION >= 1400
UNUSED2(type_name);
UNUSED2(p);
UNUSED2(size);
UNUSED2(el_size);
UNUSED2(el_count);
UNUSED2(el_iterator);
UNUSED2(it_mem);
return ERR::STL_CNT_UNKNOWN; // NOWARN
#else
bool handled = false, IsValid = false;
#define CONTAINER(name, type_name_pattern)\
else if(match_wildcard(type_name, type_name_pattern))\
{\
handled = true;\
IsValid = get_container_info(*(Any_##name*)p, size, el_size, *el_count, *el_iterator, it_mem);\
}
#define STD_CONTAINER(name) CONTAINER(name, L"std::" WIDEN(#name) L"<*>")
// workaround for preprocessor limitation: what we're trying to do is
// stringize the defined value of a macro. prepending and pasting L
// apparently isn't possible because macro args aren't expanded before
// being pasted; we therefore compare as chars[].
#define STRINGIZE2(id) # id
#define STRINGIZE(id) STRINGIZE2(id)
if(0) {} // kickoff
// standard containers
STD_CONTAINER(deque)
STD_CONTAINER(list)
STD_CONTAINER(vector)
#if STL_DINKUMWARE == 405
STD_CONTAINER(map)
STD_CONTAINER(multimap)
STD_CONTAINER(set)
STD_CONTAINER(multiset)
STD_CONTAINER(basic_string)
#endif
// standard container adapters
// (note: Any_queue etc. assumes the underlying container is a deque.
// we make sure of that here and otherwise refuse to display it, because
// doing so is lots of work for little gain.)
CONTAINER(queue, L"std::queue<*,std::deque<*> >")
CONTAINER(stack, L"std::stack<*,std::deque<*> >")
// nonstandard containers (will probably be part of C++0x)
#if HAVE_STL_HASH
CONTAINER(hash_map, WIDEN(STRINGIZE(STL_HASH_MAP)) L"<*>")
CONTAINER(hash_multimap, WIDEN(STRINGIZE(STL_HASH_MULTIMAP)) L"<*>")
CONTAINER(hash_set, WIDEN(STRINGIZE(STL_HASH_SET)) L"<*>")
CONTAINER(hash_multiset, WIDEN(STRINGIZE(STL_HASH_MULTISET)) L"<*>")
#endif
#if HAVE_STL_SLIST
CONTAINER(slist, WIDEN(STRINGIZE(STL_SLIST)) L"<*>")
#endif
// note: do not raise warnings - these can happen for new
// STL classes or if the debuggee's memory is corrupted.
if(!handled)
return ERR::STL_CNT_UNKNOWN; // NOWARN
if(!IsValid)
return ERR::STL_CNT_INVALID; // NOWARN
return INFO::OK;
#endif
}