Changeset 1020 for code/branches/core2/src/util
- Timestamp:
- Apr 10, 2008, 4:39:06 PM (17 years ago)
- Location:
- code/branches/core2/src/util
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core2/src/util/MultiTypeMath.cc
r1003 r1020 169 169 ConvertValue(&output, this->vector3_); 170 170 else if (this->type_ == MT_colourvalue) 171 { std::cout << "3_1\n"; 172 ConvertValue(&output, this->colourvalue_);} 171 ConvertValue(&output, this->colourvalue_); 173 172 else if (this->type_ == MT_quaternion) 174 173 ConvertValue(&output, this->quaternion_); … … 190 189 return ConvertValue(&this->vector3_, value, orxonox::Vector3(0, 0, 0)); 191 190 else if (this->type_ == MT_colourvalue) 192 { std::cout << "4_1\n"; 193 return ConvertValue(&this->colourvalue_, value, orxonox::ColourValue(0, 0, 0, 0)); } 191 return ConvertValue(&this->colourvalue_, value, orxonox::ColourValue(0, 0, 0, 0)); 194 192 else if (this->type_ == MT_quaternion) 195 193 return ConvertValue(&this->quaternion_, value, orxonox::Quaternion(1, 0, 0, 0)); -
code/branches/core2/src/util/String.cc
r1006 r1020 62 62 std::string removeTrailingWhitespaces(const std::string& str) 63 63 { 64 unsigned int pos1 = 0; 65 unsigned int pos2 = str.size() - 1; 66 for (; pos1 < str.size() && (str[pos1] == ' ' || str[pos1] == '\t' || str[pos1] == '\n'); pos1++); 67 for (; pos2 >= 0 && (str[pos2] == ' ' || str[pos2] == '\t' || str[pos2] == '\n'); pos2--); 68 return str.substr(pos1, pos2 - pos1 + 1); 69 } 70 71 /** 72 @brief Returns the position of the next quote in the string, starting with start. 73 @param str The string 74 @param start The startposition 75 @return The position of the next quote (std::string::npos if there is no next quote) 76 */ 77 unsigned int getNextQuote(const std::string& str, unsigned int start) 78 { 79 unsigned int quote = start - 1; 80 81 while ((quote = str.find('\"', quote + 1)) != std::string::npos) 82 { 83 unsigned int backslash = quote; 84 unsigned int numbackslashes = 0; 85 for (; backslash > 0; backslash--, numbackslashes++) 86 if (str[backslash - 1] != '\\') 87 break; 88 89 if (numbackslashes % 2 == 0) 90 break; 91 } 92 93 return quote; 64 94 } 65 95 … … 71 101 bool hasStringBetweenQuotes(const std::string& str) 72 102 { 103 unsigned int pos1 = getNextQuote(str, 0); 104 unsigned int pos2 = getNextQuote(str, pos1 + 1); 105 return (pos1 != std::string::npos && pos2 != std::string::npos && pos2 > pos1 + 1); 73 106 } 74 107 … … 80 113 std::string getStringBetweenQuotes(const std::string& str) 81 114 { 115 unsigned int pos1 = getNextQuote(str, 0); 116 unsigned int pos2 = getNextQuote(str, pos1 + 1); 117 if (pos1 != std::string::npos && pos2 != std::string::npos) 118 return str.substr(pos1, pos2 - pos1 + 1); 119 else 120 return ""; 82 121 } 83 122 -
code/branches/core2/src/util/String.h
r1006 r1020 38 38 39 39 _UtilExport std::string removeTrailingWhitespaces(const std::string& str); 40 41 _UtilExport unsigned int getNextQuote(const std::string& str, unsigned int start); 40 42 41 43 _UtilExport bool hasStringBetweenQuotes(const std::string& str);
Note: See TracChangeset
for help on using the changeset viewer.