Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7720 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
May 19, 2006, 3:29:21 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: strings work too now :)

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/util/executor/executor_functional.h

    r7719 r7720  
    3939template<> float fromString<float>(const std::string& input, float defaultValue) { return isFloat(input, defaultValue); };
    4040template<> char fromString<char>(const std::string& input, char defaultValue) { return isInt(input, defaultValue); };
    41 template<> const std::string& fromString<const std::string&>(const std::string& input, const std::string& defaultValue) { return isString(input, defaultValue); };
     41template<> const std::string& fromString<const std::string&>(const std::string& input, const std::string& defaultValue) { static std::string retVal = isString(input, defaultValue); return retVal; };
    4242
    4343template<typename type> type getDefault(const MultiType* const defaultValues, unsigned int i) { return (type)0; };
     
    4747template<> float getDefault<float>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getFloat(); };
    4848template<> char getDefault<char>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getChar(); };
    49 template<> std::string getDefault<std::string>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getString(); };
     49template<> const std::string& getDefault<const std::string&>(const MultiType* const defaultValues, unsigned int i) { static std::string retVal = defaultValues[i].getString(); return retVal; };
    5050
    5151#endif /* __EXECUTOR_FUNCTIONAL_H_ */
  • trunk/src/orxonox.cc

    r7718 r7720  
    431431  void printTestBool(bool b) { printf("%d\n", (int)b); };
    432432  void printTwoVals(int b, int i) { printf ("%d %d\n", b, i); };
    433 
     433  void printStrings(const std::string& name) { printf("String:: '%s'\n", name.c_str()); };
    434434  static void printStatic() { printf("STATIC\n");};
    435435};
     
    444444  (*createExecutor<TestClass>(&TestClass::printTwoVals))(&test, testStrings);
    445445  (*createExecutor<TestClass>(&TestClass::printStatic))(&test, testStrings);
     446  (*createExecutor<TestClass>(&TestClass::printStrings))(&test, testStrings);
    446447
    447448}
Note: See TracChangeset for help on using the changeset viewer.