Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » DUMP for Maps [FEATURE REQUEST]
DUMP for Maps [FEATURE REQUEST] [message #27231] Tue, 06 July 2010 15:49 Go to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

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 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
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
Re: DUMP for Maps [FEATURE REQUEST] [message #27856 is a reply to message #27233] Fri, 06 August 2010 20:28 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
why not have a
String ToString() const;

function for them as well? making possible
LOG(containerInstance) ;

this kind of idea i posted into 'code style', really liked it in C# beeing able to inspect no matter which class instance in debugger..

[Updated on: Fri, 06 August 2010 20:45]

Report message to a moderator

Re: DUMP for Maps [FEATURE REQUEST] [message #27996 is a reply to message #27856] Fri, 13 August 2010 09:30 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
kohait00 wrote on Fri, 06 August 2010 14:28

why not have a
String ToString() const;

function for them as well? making possible
LOG(containerInstance) ;

this kind of idea i posted into 'code style', really liked it in C# beeing able to inspect no matter which class instance in debugger..


Well, I have a little problem with creating a single String here, as the result can get pretty big. Perhaps it is non-issue, but...
Re: DUMP for Maps [FEATURE REQUEST] [message #27999 is a reply to message #27996] Fri, 13 August 2010 09:38 Go to previous message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
for those classes predestinated to produce large Strings, one could limit output to say 1000 chars or so..inside the ToString()..

i found this thing to be quite usefull when debugging over LOG
Previous Topic: Trim instead of TrimBoth
Next Topic: NEW: Tree<T> container
Goto Forum:
  


Current Time: Sun Apr 28 13:14:01 CEST 2024

Total time taken to generate the page: 0.03186 seconds