Constructing a Class Given a String

T

Todd Bandrowsky

I was just about to make the proclamation that the standard C++'s rtti
can't quite do all the stuff that .NET reflection can do, but I
thought I would check. Perhaps my C++ knowledge is not quite up to
date!

Does the latest go around of C++ envision richer run time type
information similar to that offered by Delphi or .NET?

I know that rtti lets me get a typeinfo with the string name of the
class in it, but I can't see a way to get a class given a string name?
Am I still stuck in switch land and factory patterns for this?

Similarly, I would like to go back and forth between enumerations and
strings.

Also, does anyone know if GNU offers "language extensions" to do this
exact thing?

Thanks!
 
V

Victor Bazarov

Todd said:
I was just about to make the proclamation that the standard C++'s rtti
can't quite do all the stuff that .NET reflection can do, but I
thought I would check. Perhaps my C++ knowledge is not quite up to
date!

I can say the same about my knowledge of .NET reflection.
Does the latest go around of C++ envision richer run time type
information similar to that offered by Delphi or .NET?

I've not heard of anythink like that, besides, I've not seen the need.
I know that rtti lets me get a typeinfo with the string name of the
class in it, but I can't see a way to get a class given a string name?

RTTI-returned string is (a) implementation-specific and (b) not guaranteed
to have any meaningful content. And, no, there is no mechanism in the
language to identify types by name during run-time. Generally, one can
say that there are no types during run-time.
Am I still stuck in switch land and factory patterns for this?

Yes, you probably are. If you really need that thing, that is.
Similarly, I would like to go back and forth between enumerations and
strings.

Similarly, there is no language mechanism to do that. You need to provide
one if you need it.
Also, does anyone know if GNU offers "language extensions" to do this
exact thing?

Ask in a GNU newsgroup.

Victor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top