Constructing a Class Given a String

Discussion in 'C++' started by Todd Bandrowsky, May 21, 2004.

  1. 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!
     
    Todd Bandrowsky, May 21, 2004
    #1
    1. Advertising

  2. Todd Bandrowsky wrote:
    > 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
     
    Victor Bazarov, May 21, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lord0
    Replies:
    1
    Views:
    599
    Thomas Weidenfeller
    Apr 19, 2006
  2. chiara
    Replies:
    6
    Views:
    501
    Barry Schwarz
    Oct 6, 2005
  3. 2Barter.net
    Replies:
    0
    Views:
    396
    2Barter.net
    Dec 13, 2006
  4. Santosh
    Replies:
    2
    Views:
    2,892
    Santosh
    Jan 16, 2009
  5. Xah Lee
    Replies:
    0
    Views:
    130
    Xah Lee
    Jan 8, 2014
Loading...

Share This Page