Re: Custom Data Formatter for C++ Template Classes
Re: Custom Data Formatter for C++ Template Classes
- Subject: Re: Custom Data Formatter for C++ Template Classes
- From: Michael Rice <email@hidden>
- Date: Tue, 19 Jul 2005 22:09:23 -0500
Dave -
Your message gave me some more ideas about this and, after a bit of
experimenting, I did achieve [very] limited success. For specific
sets of template parameters, I am able to display summary information
about them. I had to do a little trickery to get the .plist to work,
but it does. This is far from optimal, since I will have to update my
plug-in each time I need a new template, but it might just get me by
for now.
I defined specialized template functions for formatting the data. For
example, in my .cpp file I defined a specialized version for an 'int'
template instantiation:
template <class Type>
char* MyTemplateToCString(MyTemplate<Type>* var, int ID);
template <>
char* MyTemplateToCString<int>(MyTemplate<int>* var, int ID);
I wasn't able to get the .plist to understand a template for the
function specification, so I used the C++ mangled name for the
function name, which I got using 'otool -t -V' on my bundle binary.
For the <key> in my .plist I used:
MyTemplate<int>
I tried std::vector, but there are some issues with how to specify
the allocator template parameter.
Michael
On Jul 19, 2005, at 9:00 PM, David Leimbach wrote:
I think the problem is that a template class isn't a class at all.
It's a "meta" class. You are effectively telling the compiler how
you'd like a certain pattern of code to be generated. All template
programming is a form of metaprogramming.
Take that plus the fact that you are possibly dealing with classes
that are explicitly instantiated differently for different types
and you've got a real problem to track.
Take std::vector<bool> for example. It's actually not a vector of
"bools" but a bitvector.
How do you want to represent the size? The implemenation of
std::vector<bool> is not the same as std::vector<int>.
I'd love to know if you have success with this but it's clearly
harder to do than with a real living type. Template classes are
rules about how to create more types with similar functionality.
Dave
On Jul 19, 2005, at 6:50 PM, Michael Rice wrote:
Thanks to Jim and Chris, I have been able to develop an Xcode
plugin for displaying summary info for my data types in the
debugger. My next challenge is to do the same for a C++ template
class. It surprises me that Xcode can't display any summary info
for the Standard C++ collections, such as std::vector. I know it
would be difficult/impossible to display a snapshot of the data.
However, in the std::vector case, I would like to see the size of
the collection.
I tried adding a data formatter like:
template <class Type>
char* MyTemplateToCString(const MyTemplate<Type>* objPtr, int ID);
using various format specs in the .plist, but none were
successful. It looks like the problem may be in how to specify the
data formatter function in the .plist file.
So, is there any way to display summary info for a template class?
Maybe just for specific sets of template parameters (e.g.,
std::vector<int>)?
Thanks.
Michael
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40gmail.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden