Connecting Tech Pros Worldwide Forums | Help | Site Map

Constructing a Class Given a String

Todd Bandrowsky
Guest
 
Posts: n/a
#1: Jul 22 '05
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!

Victor Bazarov
Guest
 
Posts: n/a
#2: Jul 22 '05

re: Constructing a Class Given a String


Todd Bandrowsky wrote:[color=blue]
> 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![/color]

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

I've not heard of anythink like that, besides, I've not seen the need.
[color=blue]
> 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?[/color]

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.
[color=blue]
> Am I still stuck in switch land and factory patterns for this?[/color]

Yes, you probably are. If you really need that thing, that is.
[color=blue]
> Similarly, I would like to go back and forth between enumerations and
> strings.[/color]

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

Ask in a GNU newsgroup.

Victor
Closed Thread