[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 | |
---|
[9748] | 19 | /** |
---|
| 20 | * @brief converts an input string into a value, if no value was converted, uses defaultValue. |
---|
| 21 | * @param input the input as a String. |
---|
| 22 | * @param defaultValue the Default Value set, if the input could not be converted into type. |
---|
| 23 | * @returns either the converted value or defaultValue. |
---|
| 24 | */ |
---|
[7728] | 25 | template<> bool fromString<bool>(const std::string& input, bool defaultValue) { return isBool(input, defaultValue); }; |
---|
[9748] | 26 | /** |
---|
| 27 | * @brief converts an input string into a value, if no value was converted, uses defaultValue. |
---|
| 28 | * @param input the input as a String. |
---|
| 29 | * @param defaultValue the Default Value set, if the input could not be converted into type. |
---|
| 30 | * @returns either the converted value or defaultValue. |
---|
| 31 | */ |
---|
[7728] | 32 | template<> int fromString<int>(const std::string& input, int defaultValue) { return isInt(input, defaultValue); }; |
---|
[9748] | 33 | /** |
---|
| 34 | * @brief converts an input string into a value, if no value was converted, uses defaultValue. |
---|
| 35 | * @param input the input as a String. |
---|
| 36 | * @param defaultValue the Default Value set, if the input could not be converted into type. |
---|
| 37 | * @returns either the converted value or defaultValue. |
---|
| 38 | */ |
---|
[7728] | 39 | template<> unsigned int fromString<unsigned int>(const std::string& input, unsigned int defaultValue) { return isInt(input, defaultValue); }; |
---|
[9748] | 40 | /** |
---|
| 41 | * @brief converts an input string into a value, if no value was converted, uses defaultValue. |
---|
| 42 | * @param input the input as a String. |
---|
| 43 | * @param defaultValue the Default Value set, if the input could not be converted into type. |
---|
| 44 | * @returns either the converted value or defaultValue. |
---|
| 45 | */ |
---|
[7728] | 46 | template<> float fromString<float>(const std::string& input, float defaultValue) { return isFloat(input, defaultValue); }; |
---|
[9748] | 47 | /** |
---|
| 48 | * @brief converts an input string into a value, if no value was converted, uses defaultValue. |
---|
| 49 | * @param input the input as a String. |
---|
| 50 | * @param defaultValue the Default Value set, if the input could not be converted into type. |
---|
| 51 | * @returns either the converted value or defaultValue. |
---|
| 52 | */ |
---|
[7728] | 53 | template<> char fromString<char>(const std::string& input, char defaultValue) { return isInt(input, defaultValue); }; |
---|
[9748] | 54 | /** |
---|
| 55 | * @brief converts an input string into a value, if no value was converted, uses defaultValue. |
---|
| 56 | * @param input the input as a String. |
---|
| 57 | * @param defaultValue the Default Value set, if the input could not be converted into type. |
---|
| 58 | * @returns either the converted value or defaultValue. |
---|
| 59 | */ |
---|
[8408] | 60 | template<> const std::string& fromString<const std::string&>(const std::string& input, const std::string& defaultValue) { return (input.size() > 0) ? input : defaultValue; }; |
---|
[7728] | 61 | |
---|
[8035] | 62 | |
---|
[9748] | 63 | /** |
---|
| 64 | * @brief converts to any type from a MultiType |
---|
| 65 | * @param multi the MultiType to convert. |
---|
| 66 | * @returns the converted Value. |
---|
| 67 | */ |
---|
[8035] | 68 | template<> bool fromMulti<bool>(const MultiType& multi) { return multi.getBool(); }; |
---|
[9748] | 69 | /** |
---|
| 70 | * @brief converts to any type from a MultiType |
---|
| 71 | * @param multi the MultiType to convert. |
---|
| 72 | * @returns the converted Value. |
---|
| 73 | */ |
---|
[8035] | 74 | template<> int fromMulti<int>(const MultiType& multi) { return multi.getInt(); } |
---|
[9748] | 75 | /** |
---|
| 76 | * @brief converts to any type from a MultiType |
---|
| 77 | * @param multi the MultiType to convert. |
---|
| 78 | * @returns the converted Value. |
---|
| 79 | */ |
---|
[8035] | 80 | template<> unsigned int fromMulti<unsigned int>(const MultiType& multi) { return multi.getInt(); }; |
---|
[9748] | 81 | /** |
---|
| 82 | * @brief converts to any type from a MultiType |
---|
| 83 | * @param multi the MultiType to convert. |
---|
| 84 | * @returns the converted Value. |
---|
| 85 | */ |
---|
[8035] | 86 | template<> float fromMulti<float>(const MultiType& multi) { return multi.getFloat(); }; |
---|
[9748] | 87 | /** |
---|
| 88 | * @brief converts to any type from a MultiType |
---|
| 89 | * @param multi the MultiType to convert. |
---|
| 90 | * @returns the converted Value. |
---|
| 91 | */ |
---|
[8035] | 92 | template<> char fromMulti<char>(const MultiType& multi) { return multi.getChar(); }; |
---|
[9748] | 93 | /** |
---|
| 94 | * @brief converts to any type from a MultiType |
---|
| 95 | * @param multi the MultiType to convert. |
---|
| 96 | * @returns the converted Value. |
---|
| 97 | */ |
---|
[8035] | 98 | template<> const std::string& fromMulti<const std::string&>(const MultiType& multi) { return multi.getConstString(); }; |
---|
| 99 | |
---|
| 100 | |
---|
[9748] | 101 | /** |
---|
| 102 | * @brief retrieves a default value from an array of default values, at possition i. |
---|
| 103 | * @param defaultValues the Array of default values. |
---|
| 104 | * @param i the index. |
---|
| 105 | * @returns the Default Value at Position i |
---|
| 106 | */ |
---|
[7728] | 107 | template<> bool getDefault<bool>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getBool(); }; |
---|
[9748] | 108 | /** |
---|
| 109 | * @brief retrieves a default value from an array of default values, at possition i. |
---|
| 110 | * @param defaultValues the Array of default values. |
---|
| 111 | * @param i the index. |
---|
| 112 | * @returns the Default Value at Position i |
---|
| 113 | */ |
---|
[7728] | 114 | template<> int getDefault<int>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getInt(); }; |
---|
[9748] | 115 | /** |
---|
| 116 | * @brief retrieves a default value from an array of default values, at possition i. |
---|
| 117 | * @param defaultValues the Array of default values. |
---|
| 118 | * @param i the index. |
---|
| 119 | * @returns the Default Value at Position i |
---|
| 120 | */ |
---|
[7728] | 121 | template<> unsigned int getDefault<unsigned int>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getInt(); }; |
---|
[9748] | 122 | /** |
---|
| 123 | * @brief retrieves a default value from an array of default values, at possition i. |
---|
| 124 | * @param defaultValues the Array of default values. |
---|
| 125 | * @param i the index. |
---|
| 126 | * @returns the Default Value at Position i |
---|
| 127 | */ |
---|
[7728] | 128 | template<> float getDefault<float>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getFloat(); }; |
---|
[9748] | 129 | /** |
---|
| 130 | * @brief retrieves a default value from an array of default values, at possition i. |
---|
| 131 | * @param defaultValues the Array of default values. |
---|
| 132 | * @param i the index. |
---|
| 133 | * @returns the Default Value at Position i |
---|
| 134 | */ |
---|
[7728] | 135 | template<> char getDefault<char>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getChar(); }; |
---|
[9748] | 136 | /** |
---|
| 137 | * @brief retrieves a default value from an array of default values, at possition i. |
---|
| 138 | * @param defaultValues the Array of default values. |
---|
| 139 | * @param i the index. |
---|
| 140 | * @returns the Default Value at Position i |
---|
| 141 | */ |
---|
[9730] | 142 | template<> const std::string& getDefault<const std::string&>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getStoredString(); }; |
---|