This is the mail archive of the mailing list for the Archer project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: pretty-printing update

On Tuesday 30 September 2008 21:57:08 Tom Tromey wrote:
> I've been working on pretty printing for the past week; I thought I'd
> send a note about the current status.
>  [...]
> There are a couple problems right now.
> The biggest one is that the output is not always actually pretty.  It
> is an improvement, in that you can easily see the contents of
> containers and whatnot, but the formatting is odd.  Consider this
> example, where 'intmap' is a std::map<int, char*>:
> (gdb) p intmap
> $2 = number of elements = 2
> [5] = 0x804c057 "liver"
> [23] = 0x804c046 "maude"
> [...]
> If you've got any input on these, I'm all ears.

It depends a bit on who is going to read this output. The output
above is surely good enough for an interactive session, and in
that case the "$2" does not really hurt. 

For  a "machine" interface, something more structured (and more
robust to parse) would be needed anyway.

Solutions for that are not hard. As an example, a  std::list<std::string> 
with three elements "aaa", "b" and "2" could be "pretty printed" as:

  value="<3 items>",type="std::list<std::string>",

The values themselves are in this case base64 encoded to
make handling non-printable or otherwise special characters
simple. The format is standard MI, so whoever can parse MI
will be able to parse that. 

A GUI would display that as a tree similar to

[-] list  <3 items>  std::list<std::string>
 |-- [0]    aaa         std::string
 |-- [1]    b           std::string
 `-- [2]    2           std::string


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]