Connecting Tech Pros Worldwide Help | Site Map

Constructing a Class Given a String

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 22nd, 2005, 11:24 AM
Todd Bandrowsky
Guest
 
Posts: n/a
Default Constructing a Class Given a String

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!

  #2  
Old July 22nd, 2005, 11:24 AM
Victor Bazarov
Guest
 
Posts: n/a
Default 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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.