Home » U++ Library support » U++ Core » DUMP for Maps [FEATURE REQUEST]
DUMP for Maps [FEATURE REQUEST] [message #27231] |
Tue, 06 July 2010 15:49 |
|
Hi Mirek,
Could you please add a macro that would dump ArrayMap/VectorMap including the keys? I really miss it when debugging some of my programs. If I am not mistaken, the closest thing we have now is "DUMPC(map.GetKeys());DUMPC(map);", which is far from easy to use.
Something like this in Core/diag.h would be totally sufficient:#define DUMPM(c) UPP::LockLog(), UPP::DumpMap(VppLog() << #c << ':' << UPP::EOL, (c)), UPP::UnlockLog()
template <class T>
void DumpMap(Stream& s, const T& t) {
s << LOG_BEGIN;
for(int i = 0; i < t.GetCount(); i++)
s << '[' << i << "] = ("<< t.GetKey(i) << ") " << t[i] << EOL;
s << LOG_END;
}
Best regards,
Honza
|
|
|
Re: DUMP for Maps [FEATURE REQUEST] [message #27233 is a reply to message #27231] |
Tue, 06 July 2010 21:07 |
|
mirek
Messages: 14039 Registered: November 2005
|
Ultimate Member |
|
|
dolik.rce wrote on Tue, 06 July 2010 09:49 | Hi Mirek,
Could you please add a macro that would dump ArrayMap/VectorMap including the keys? I really miss it when debugging some of my programs. If I am not mistaken, the closest thing we have now is "DUMPC(map.GetKeys());DUMPC(map);", which is far from easy to use.
Something like this in Core/diag.h would be totally sufficient:#define DUMPM(c) UPP::LockLog(), UPP::DumpMap(VppLog() << #c << ':' << UPP::EOL, (c)), UPP::UnlockLog()
template <class T>
void DumpMap(Stream& s, const T& t) {
s << LOG_BEGIN;
for(int i = 0; i < t.GetCount(); i++)
s << '[' << i << "] = ("<< t.GetKey(i) << ") " << t[i] << EOL;
s << LOG_END;
}
Best regards,
Honza
|
Good idea. It is there...
Mirek
|
|
|
|
|
|
Goto Forum:
Current Time: Sat Sep 21 02:59:30 CEST 2024
Total time taken to generate the page: 0.02401 seconds
|