I'm seeking of an API that can be used to dump most data structures,is there one in c/c++?
boost has a serialisation library you can explicitly use to make your data structures dumpable.
If you want it to happen more automatically, your options are bleak. A C++ program can inspect its own debug symbols, or compile up some extra code - perhaps auto-generated with reference to GCC-XML output, or using a tool like OpenC++ to auto-generate some meta-data.
I'm seeking of an API that can be used to dump most data structures,is there one in c/c++?
Short answer: No, there is not.
Longer answer: C++ doesn't have reflection. That is, there is no way to analyze unknown data structures at runtime. You will have to have to write dump routines yourself for any data structure you want to dump, building on what's available for its data members.
However, note that C++ has a whole lot of tools to make that easier. For example, given a simple generic dump()
template:
template< typename T >
inline void dump(std::ostream& os, const T& obj) {os << obj;}
the elements of any sequence can be dumped using this simple function:
template< typename OutIt >
void dump(std::ostream& os, OutIt begin, OutIt end)
{
if(begin != end)
os << *begin++;
while(begin != end) {
os << ", ";
dump(*begin++);
}
}