Changeset 1779 for code/branches/core3/src/util/Math.cc
- Timestamp:
- Sep 14, 2008, 11:31:28 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core3/src/util/Math.cc
r1778 r1779 130 130 131 131 // std::string to Vector2 132 bool fallbackConversion(orxonox::Vector2* output, const std::string& input) 133 { 134 unsigned int opening_parenthesis, closing_parenthesis = input.find(')'); 135 if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; } 136 137 SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0'); 132 bool ConverterFallback<orxonox::Vector2, std::string>::convert(orxonox::Vector2* output, const std::string& input) 133 { 134 unsigned int opening_parenthesis, closing_parenthesis = input.find(')'); 135 if ((opening_parenthesis = input.find('(')) == std::string::npos) 136 opening_parenthesis = 0; 137 else 138 opening_parenthesis++; 139 140 SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), 141 ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0'); 138 142 if (tokens.size() >= 2) 139 143 { … … 149 153 150 154 // std::string to Vector3 151 bool fallbackConversion(orxonox::Vector3* output, const std::string& input) 152 { 153 unsigned int opening_parenthesis, closing_parenthesis = input.find(')'); 154 if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; } 155 156 SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0'); 155 bool ConverterFallback<orxonox::Vector3, std::string>::convert(orxonox::Vector3* output, const std::string& input) 156 { 157 unsigned int opening_parenthesis, closing_parenthesis = input.find(')'); 158 if ((opening_parenthesis = input.find('(')) == std::string::npos) 159 opening_parenthesis = 0; 160 else 161 opening_parenthesis++; 162 163 SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), 164 ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0'); 157 165 if (tokens.size() >= 3) 158 166 { … … 170 178 171 179 // std::string to Vector4 172 bool fallbackConversion(orxonox::Vector4* output, const std::string& input) 180 bool ConverterFallback<orxonox::Vector4, std::string>::convert(orxonox::Vector4* output, const std::string& input) 181 { 182 unsigned int opening_parenthesis, closing_parenthesis = input.find(')'); 183 if ((opening_parenthesis = input.find('(')) == std::string::npos) 184 opening_parenthesis = 0; 185 else 186 opening_parenthesis++; 187 188 SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), 189 ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0'); 190 if (tokens.size() >= 4) 191 { 192 if (!ConvertValue(&(output->x), tokens[0])) 193 return false; 194 if (!ConvertValue(&(output->y), tokens[1])) 195 return false; 196 if (!ConvertValue(&(output->z), tokens[2])) 197 return false; 198 if (!ConvertValue(&(output->w), tokens[3])) 199 return false; 200 201 return true; 202 } 203 return false; 204 } 205 206 // std::string to Quaternion 207 bool ConverterFallback<orxonox::Quaternion, std::string>::convert(orxonox::Quaternion* output, const std::string& input) 173 208 { 174 209 unsigned int opening_parenthesis, closing_parenthesis = input.find(')'); … … 178 213 if (tokens.size() >= 4) 179 214 { 180 if (!ConvertValue(&(output-> x), tokens[0]))181 return false; 182 if (!ConvertValue(&(output-> y), tokens[1]))183 return false; 184 if (!ConvertValue(&(output-> z), tokens[2]))185 return false; 186 if (!ConvertValue(&(output-> w), tokens[3]))187 return false; 188 189 return true; 190 } 191 return false; 192 } 193 194 // std::string to Quaternion195 bool fallbackConversion(orxonox::Quaternion* output, const std::string& input)215 if (!ConvertValue(&(output->w), tokens[0])) 216 return false; 217 if (!ConvertValue(&(output->x), tokens[1])) 218 return false; 219 if (!ConvertValue(&(output->y), tokens[2])) 220 return false; 221 if (!ConvertValue(&(output->z), tokens[3])) 222 return false; 223 224 return true; 225 } 226 return false; 227 } 228 229 // std::string to ColourValue 230 bool ConverterFallback<orxonox::ColourValue, std::string>::convert(orxonox::ColourValue* output, const std::string& input) 196 231 { 197 232 unsigned int opening_parenthesis, closing_parenthesis = input.find(')'); … … 201 236 if (tokens.size() >= 4) 202 237 { 203 if (!ConvertValue(&(output->w), tokens[0]))204 return false;205 if (!ConvertValue(&(output->x), tokens[1]))206 return false;207 if (!ConvertValue(&(output->y), tokens[2]))208 return false;209 if (!ConvertValue(&(output->z), tokens[3]))210 return false;211 212 return true;213 }214 return false;215 }216 217 // std::string to ColourValue218 bool fallbackConversion(orxonox::ColourValue* output, const std::string& input)219 {220 unsigned int opening_parenthesis, closing_parenthesis = input.find(')');221 if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; }222 223 SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');224 if (tokens.size() >= 4)225 {226 238 if (!ConvertValue(&(output->r), tokens[0])) 227 239 return false;
Note: See TracChangeset
for help on using the changeset viewer.