Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/util/executor/executor_substring.cc @ 10710

Last change on this file since 10710 was 9869, checked in by bensch, 18 years ago

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File size: 6.3 KB
Line 
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
16#include "executor_substring.h"
17#include "helper_functions.h"
18
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 */
25template<> bool fromString<bool>(const std::string& input, bool defaultValue) { return isBool(input, defaultValue); };
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 */
32template<> int fromString<int>(const std::string& input, int defaultValue) { return isInt(input, defaultValue); };
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 */
39template<> unsigned int fromString<unsigned int>(const std::string& input, unsigned int defaultValue) { return isInt(input, defaultValue); };
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 */
46template<> float fromString<float>(const std::string& input, float defaultValue) { return isFloat(input, defaultValue); };
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 */
53template<> char fromString<char>(const std::string& input, char defaultValue) { return isInt(input, defaultValue); };
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 */
60template<> const std::string& fromString<const std::string&>(const std::string& input, const std::string& defaultValue) { return (input.size() > 0) ? input : defaultValue; };
61
62
63/**
64 * @brief converts to any type from a MultiType
65 * @param multi the MultiType to convert.
66 * @returns the converted Value.
67 */
68template<> bool fromMulti<bool>(const MultiType& multi) { return multi.getBool(); };
69/**
70 * @brief converts to any type from a MultiType
71 * @param multi the MultiType to convert.
72 * @returns the converted Value.
73 */
74template<> int fromMulti<int>(const MultiType& multi) { return multi.getInt(); }
75/**
76 * @brief converts to any type from a MultiType
77 * @param multi the MultiType to convert.
78 * @returns the converted Value.
79 */
80template<> unsigned int fromMulti<unsigned int>(const MultiType& multi) { return multi.getInt(); };
81/**
82 * @brief converts to any type from a MultiType
83 * @param multi the MultiType to convert.
84 * @returns the converted Value.
85 */
86template<> float fromMulti<float>(const MultiType& multi) { return multi.getFloat(); };
87/**
88 * @brief converts to any type from a MultiType
89 * @param multi the MultiType to convert.
90 * @returns the converted Value.
91 */
92template<> char fromMulti<char>(const MultiType& multi) { return multi.getChar(); };
93/**
94 * @brief converts to any type from a MultiType
95 * @param multi the MultiType to convert.
96 * @returns the converted Value.
97 */
98template<> const std::string& fromMulti<const std::string&>(const MultiType& multi) { return multi.getConstString(); };
99
100
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 */
107template<> bool getDefault<bool>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getBool(); };
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 */
114template<> int getDefault<int>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getInt(); };
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 */
121template<> unsigned int getDefault<unsigned int>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getInt(); };
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 */
128template<> float getDefault<float>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getFloat(); };
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 */
135template<> char getDefault<char>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getChar(); };
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 */
142template<> const std::string& getDefault<const std::string&>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getStoredString(); };
Note: See TracBrowser for help on using the repository browser.