Changeset 925 for code/branches/core2/src/util/Convert.h
- Timestamp:
- Mar 26, 2008, 1:36:35 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core2/src/util/Convert.h
r871 r925 41 41 #include "MultiTypeMath.h" 42 42 43 44 43 // DEFAULT CLASS 45 44 template <typename FromType, typename ToType> … … 151 150 bool operator()(ToType* output, const MultiTypePrimitive& input) const 152 151 { 153 if (input.getType() == MT_int) 152 if (input.getType() == MT_void) 153 return ConvertValue(output, input.getVoid()); 154 else if (input.getType() == MT_int) 154 155 return ConvertValue(output, input.getInt()); 155 156 else if (input.getType() == MT_uint) … … 185 186 bool operator()(std::string* output, const MultiTypePrimitive& input) const 186 187 { 187 if (input.getType() == MT_int) 188 if (input.getType() == MT_void) 189 return ConvertValue(output, input.getVoid()); 190 else if (input.getType() == MT_int) 188 191 return ConvertValue(output, input.getInt()); 189 192 else if (input.getType() == MT_uint) … … 225 228 else if (input.getType() == MT_string) 226 229 return ConvertValue(output, input.getString()); 230 else if (input.getType() == MT_xmlelement) 231 return ConvertValue(output, input.getXMLElement()); 227 232 else 228 233 return ConvertValue(output, (MultiTypePrimitive)input); … … 239 244 else if (input.getType() == MT_string) 240 245 return ConvertValue(output, input.getString()); 246 else if (input.getType() == MT_xmlelement) 247 return ConvertValue(output, input.getXMLElement()); 241 248 else 242 249 return ConvertValue(output, (MultiTypePrimitive)input); … … 534 541 }; 535 542 543 544 //////////////// 545 // XMLElement // 546 //////////////// 547 548 // orxonox::Element to std::string 549 template <> 550 class Converter<orxonox::Element, std::string> 551 { 552 public: 553 bool operator()(std::string* output, const orxonox::Element& input) const 554 { 555 std::ostringstream ostream; 556 if (ostream << input) 557 { 558 (*output) = ostream.str(); 559 return true; 560 } 561 562 return false; 563 } 564 }; 565 566 // std::string to orxonox::Element 567 template <> 568 class Converter<std::string, orxonox::Element> 569 { 570 public: 571 bool operator()(orxonox::Element* output, const std::string& input) const 572 { 573 std::istringstream istream(input); 574 if (istream >> (*output)) 575 return true; 576 577 return false; 578 } 579 }; 580 581 536 582 #endif /* _Convert_H__ */
Note: See TracChangeset
for help on using the changeset viewer.