Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 26, 2008, 1:36:35 AM (16 years ago)
Author:
landauf
Message:
  • the MultiTypes can now handle pointers and xml-elements
  • added a const keyword in the ticpp.h file (TinyXML++)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core2/src/util/Convert.h

    r871 r925  
    4141#include "MultiTypeMath.h"
    4242
    43 
    4443// DEFAULT CLASS
    4544template <typename FromType, typename ToType>
     
    151150    bool operator()(ToType* output, const MultiTypePrimitive& input) const
    152151    {
    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)
    154155        return ConvertValue(output, input.getInt());
    155156      else if (input.getType() == MT_uint)
     
    185186    bool operator()(std::string* output, const MultiTypePrimitive& input) const
    186187    {
    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)
    188191        return ConvertValue(output, input.getInt());
    189192      else if (input.getType() == MT_uint)
     
    225228      else if (input.getType() == MT_string)
    226229        return ConvertValue(output, input.getString());
     230      else if (input.getType() == MT_xmlelement)
     231        return ConvertValue(output, input.getXMLElement());
    227232      else
    228233        return ConvertValue(output, (MultiTypePrimitive)input);
     
    239244      else if (input.getType() == MT_string)
    240245        return ConvertValue(output, input.getString());
     246      else if (input.getType() == MT_xmlelement)
     247        return ConvertValue(output, input.getXMLElement());
    241248      else
    242249        return ConvertValue(output, (MultiTypePrimitive)input);
     
    534541};
    535542
     543
     544////////////////
     545// XMLElement //
     546////////////////
     547
     548// orxonox::Element to std::string
     549template <>
     550class 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
     567template <>
     568class 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
    536582#endif /* _Convert_H__ */
Note: See TracChangeset for help on using the changeset viewer.