Re: How to convert a string to an object reference?



Hello Lew,
I solved the problem with a HashMap.

Thank You
Alois
"Lew" <lew@xxxxxxxxxxxxxxxxxxxx> schrieb im Newsbeitrag
news:tsKdnS1Lr-wsoq7bnZ2dnUVZ_oLinZ2d@xxxxxxxxxxxxxx
Alois Haslinger wrote:
is there an easy way to convert a string to an object reference of
a well-known class?

Lew wrote:
Unless the "well-known" class has a "valueOf( String )" method or
equivalent, you will have to parse the string and convert by your own
code.

Is the "well-known" class part of the standard API or a custom class?

Or you could use a Map< String, WellKnown >.

--
Lew


.



Relevant Pages

  • Re: Help With PyParsing of output from win32pdhutil.ShowAllProcesses()
    ... None to a string). ... Still have an urge to parse with pyparsing? ... pyparsing Dict class. ... keys from the parsed data, so it looks like you are already thinking ...
    (comp.lang.python)
  • Re: Hash or Tree
    ... I doubt TreeMap is faster than HashMap. ... to compare to each string key on the path. ... time in a HashSet (given properly distributed hash codes and table ... The advantage of TreeSet over HashSet is not in speed, ...
    (comp.lang.java.programmer)
  • Re: Partial Search
    ... >Client Code needs to search based on some string that cd be anywhere ... A Hashmap needs an exact key. ... You look at each string and compare ... You break your object keys into "syllables" or potential syllables, ...
    (comp.lang.java.programmer)
  • Re: Pyparsing help
    ... our grammar isn't parsing the METAL2 entry at all. ... input string". ... successful parse, then restored half of the entries I removed, until I ... Layer PRBOUNDARY ...
    (comp.lang.python)
  • Re: Nasty code...but please critique it anyway :-)
    ... You only need <string>, move all the other #includes to the C++ files. ... compilation times. ... You may want to use a std::stringstream to parse the integer, ... You may want to flush the output stream after printing menutext, ...
    (alt.comp.lang.learn.c-cpp)