Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Value: String to int - problem or feature?
Re: Value: String to int - problem or feature? [message #36394 is a reply to message #36391] Wed, 23 May 2012 20:42 Go to previous messageGo to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi Steffen,

Value is not meant meant for converting types. It is just container that can store various types. In most cases, you always get out the same type you put in. If there implicit conversion is possible, it will be done the same way as you can do e.g. <double> = <int>, but for incompatible types such as int and String, error occurs.

What you need to do is to call StrInt in between:
Value v = "122";
int i = StrInt(v);
If you are not sure what is in your Value variable, you can test it before the conversion using Is<>() method, e.g:
Value v = "122";
if (v.Is<int>()) { ... }
else if (v.Is<String>()) { ... };
Also, as a special case, you can convert any type of Value into String using v.ToString().

Did that answered your question?

Best regards,
Honza
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Out of memory panic
Next Topic: Serialize of derived classes
Goto Forum:
  


Current Time: Sat Sep 21 03:25:41 CEST 2024

Total time taken to generate the page: 0.03560 seconds