[xsde-users] Re: Determine whether an object model supports polymorphism

Thomas Frenzel (TomSun) tftomsun at streamteam.de
Fri Oct 23 09:01:22 EDT 2009


Hello Boris,

Quote 1:
Do you need this functionality (i.e., conversion from a string   
representation to enum other than during XML parsing) right now in  
your application? Or is it something that might be useful in the   
future?  

I don't need this feature at the moment. So, for me its not necessary to implement it now. Its like you said, i just thought its maybe a nice to have feature. If i really need it one day, then i can write you an email again.

Quote 2:
What if I have two enums that have the same value bit at different  
"positions" ;-)?  

Hm, i don't know if i understand the problem. The Parse method would take the string (char*) that has been passed to the Color constructor and the static array of the Color names. So you just need a loop and compare the input name with all the names from the static array. Dependend on constructor you call, you will always pass a different char* array. So even if you define two names twice in two different enumerations, you would still get the right index for each of them.

  _____  

From: Boris Kolpackov [mailto:boris at codesynthesis.com]
To: Thomas Frenzel (TomSun) [mailto:tftomsun at streamteam.de]
Cc: xsde-users at codesynthesis.com
Sent: Thu, 22 Oct 2009 14:52:48 +0200
Subject: Re: Determine whether an object model supports polymorphism

Hi Thomas,
  
  Thomas Frenzel (TomSun) <tftomsun at streamteam.de> writes:
  
  >   Maybe you could reduce the effort in the generated code if you 
  >   provide in your lib a static method... something like
  
  It is not really the effort to generate the code that is the issue.
  It is the interface (no clean way to report errors when exceptions
  are disabled) as well as the generated code size concern. So I am
  trying to keep things as minimal as possible.
  
  Do you need this functionality (i.e., conversion from a string 
  representation to enum other than during XML parsing) right now in
  your application? Or is it something that might be useful in the 
  future?
  
  
  >   
  >   static int ParseEnum(char* value, const char*[] enumNames)
  >   {
  >   // TODO do the error handling and getting the integer representation 
  >      of the enum value here.
  >   }
  
  What if I have two enums that have the same value bit at different
  "positions" ;-)?
  
  
  >   and you could just generated the constructor like this
  >   inline color:
  >   color (char* enumName)
  >     v_ ((value)::ParseEnum(enumName,color_str_))
  >   {
  >   }
  
  No, I don't like this. It should be either implemented properly or
  not implemented at all. Having a half-done solution is very costly
  to support.
  
  Boris
    


More information about the xsde-users mailing list