[7728] | 1 | /* |
---|
| 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | ### File Specific: |
---|
| 12 | main-programmer: Benjamin Grauer |
---|
| 13 | co-programmer: ... |
---|
| 14 | */ |
---|
| 15 | |
---|
[9742] | 16 | #include "executor_substring.h" |
---|
[9734] | 17 | #include "helper_functions.h" |
---|
[7728] | 18 | |
---|
| 19 | template<> bool fromString<bool>(const std::string& input, bool defaultValue) { return isBool(input, defaultValue); }; |
---|
| 20 | template<> int fromString<int>(const std::string& input, int defaultValue) { return isInt(input, defaultValue); }; |
---|
| 21 | template<> unsigned int fromString<unsigned int>(const std::string& input, unsigned int defaultValue) { return isInt(input, defaultValue); }; |
---|
| 22 | template<> float fromString<float>(const std::string& input, float defaultValue) { return isFloat(input, defaultValue); }; |
---|
| 23 | template<> char fromString<char>(const std::string& input, char defaultValue) { return isInt(input, defaultValue); }; |
---|
[8408] | 24 | template<> const std::string& fromString<const std::string&>(const std::string& input, const std::string& defaultValue) { return (input.size() > 0) ? input : defaultValue; }; |
---|
[7728] | 25 | |
---|
[8035] | 26 | |
---|
| 27 | template<> bool fromMulti<bool>(const MultiType& multi) { return multi.getBool(); }; |
---|
| 28 | template<> int fromMulti<int>(const MultiType& multi) { return multi.getInt(); } |
---|
| 29 | template<> unsigned int fromMulti<unsigned int>(const MultiType& multi) { return multi.getInt(); }; |
---|
| 30 | template<> float fromMulti<float>(const MultiType& multi) { return multi.getFloat(); }; |
---|
| 31 | template<> char fromMulti<char>(const MultiType& multi) { return multi.getChar(); }; |
---|
| 32 | template<> const std::string& fromMulti<const std::string&>(const MultiType& multi) { return multi.getConstString(); }; |
---|
| 33 | |
---|
| 34 | |
---|
[7728] | 35 | template<> bool getDefault<bool>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getBool(); }; |
---|
| 36 | template<> int getDefault<int>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getInt(); }; |
---|
| 37 | template<> unsigned int getDefault<unsigned int>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getInt(); }; |
---|
| 38 | template<> float getDefault<float>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getFloat(); }; |
---|
| 39 | template<> char getDefault<char>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getChar(); }; |
---|
[9730] | 40 | template<> const std::string& getDefault<const std::string&>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getStoredString(); }; |
---|
[7728] | 41 | |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | |
---|
| 45 | |
---|
[8035] | 46 | |
---|
| 47 | |
---|
[7728] | 48 | /** |
---|
| 49 | * A LITTLE TESTING SUITE FOR THE EXECUTOR. |
---|
| 50 | * |
---|
| 51 | #include "executor/executor_functional.h" |
---|
| 52 | |
---|
| 53 | #define EXECUTOR_FUNCTIONAL_USE_STATIC |
---|
| 54 | #include "executor/executor_functional.h" |
---|
| 55 | |
---|
| 56 | class TestClass : public BaseObject |
---|
| 57 | { |
---|
| 58 | public: |
---|
| 59 | TestClass() {}; |
---|
| 60 | |
---|
| 61 | void printTest() { printf ("TEST\n"); }; |
---|
| 62 | void printTestInt(int i) { printf ("%d\n", i); }; |
---|
| 63 | void printTestBool(bool b) { printf("%d\n", (int)b); }; |
---|
| 64 | void printTwoVals(int b, int i) { printf ("%d %d\n", b, i); }; |
---|
| 65 | void printStrings(const std::string& name) { printf("String:: '%s'\n", name.c_str()); }; |
---|
| 66 | static void printStatic() { printf("STATIC\n");}; |
---|
| 67 | }; |
---|
| 68 | |
---|
| 69 | void TEST() |
---|
| 70 | { |
---|
| 71 | TestClass test; |
---|
| 72 | SubString testStrings("1 SCHEISSE, 2, 3", ",", SubString::WhiteSpaces, false); |
---|
| 73 | (*createExecutor<TestClass>(&TestClass::printTest))(&test, testStrings); |
---|
| 74 | (*createExecutor<TestClass>(&TestClass::printTestInt))(&test, testStrings); |
---|
| 75 | (*createExecutor<TestClass>(&TestClass::printTestBool))(&test, testStrings); |
---|
| 76 | (*createExecutor<TestClass>(&TestClass::printTwoVals))(&test, testStrings); |
---|
| 77 | (*createExecutor<TestClass>(&TestClass::printStatic))(&test, testStrings); |
---|
| 78 | (*createExecutor<TestClass>(&TestClass::printStrings))(&test, testStrings); |
---|
| 79 | |
---|
| 80 | } |
---|
| 81 | */ |
---|