• Advertisement
Sign in to follow this  

Keeping track of templated classes

This topic is 3315 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there a way to keep a list of templated classes? I'm attempting to write my own configuration file system. I'll be parsing configuration files for keywords such as "int" "float" etc. So when I'm parsing a file I want to be able to create a templated variable class "Variable<int>" and "Variable<float>". This isn't hard, but how can I keep a list of all of these when I cannot use a templated class as a list type?

Share this post


Link to post
Share on other sites
Advertisement
I think the trick is that Variable<T> inherits from non-templated VariableBase.

Share this post


Link to post
Share on other sites
Ah, of course. Thanks. I resorted to just parsing floats because I can't think of any way to create user-defined types with a script. I can't imagine including every file in my game that has a type definition in it and hard coding a string to match every single user type.

Share this post


Link to post
Share on other sites
Quote:
Original post by M4573R
I resorted to just parsing floats

Beware, most integer values cannot be represented by floats. Have you tried parsing the integer 123456789 as a float for example? ;)

Share this post


Link to post
Share on other sites
Hm, I guess I could just parse everything as strings and let the end user be responsible for converting it to the right type.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement