Changeset 6394 for code/branches/presentation2/src/libraries/util
- Timestamp:
- Dec 22, 2009, 2:07:44 PM (15 years ago)
- Location:
- code/branches/presentation2/src/libraries/util
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2/src/libraries/util/Clipboard.cc
r5958 r6394 78 78 { 79 79 COUT(1) << "Error: Unable to copy the following text to the clipboard:" << std::endl; 80 COUT(1) << " \"" << text << "\""<< std::endl;80 COUT(1) << " \"" << text << '"' << std::endl; 81 81 } 82 82 return false; … … 96 96 if (hData == NULL) 97 97 return ""; 98 std::string output = static_cast<char*>(GlobalLock(hData));98 std::string output(static_cast<char*>(GlobalLock(hData))); 99 99 GlobalUnlock(hData); 100 100 CloseClipboard(); … … 119 119 namespace orxonox 120 120 { 121 static std::string clipboard = ""; //!< Keeps the text of our internal clipboard121 static std::string clipboard; //!< Keeps the text of our internal clipboard 122 122 123 123 /** -
code/branches/presentation2/src/libraries/util/Convert.h
r5738 r6394 43 43 44 44 #include "Debug.h" 45 #include "StringUtils.h"46 45 #include "TemplateUtils.h" 47 46 … … 336 335 FORCEINLINE static bool convert(std::string* output, const char input) 337 336 { 338 *output = std::string(1, input);337 *output = input; 339 338 return true; 340 339 } … … 345 344 FORCEINLINE static bool convert(std::string* output, const unsigned char input) 346 345 { 347 *output = std::string(1, input);346 *output = input; 348 347 return true; 349 348 } … … 352 351 struct ConverterExplicit<std::string, char> 353 352 { 354 FORCEINLINE static bool convert(char* output, const std::string input)355 { 356 if ( input != "")353 FORCEINLINE static bool convert(char* output, const std::string& input) 354 { 355 if (!input.empty()) 357 356 *output = input[0]; 358 357 else … … 364 363 struct ConverterExplicit<std::string, unsigned char> 365 364 { 366 FORCEINLINE static bool convert(unsigned char* output, const std::string input)367 { 368 if ( input != "")365 FORCEINLINE static bool convert(unsigned char* output, const std::string& input) 366 { 367 if (!input.empty()) 369 368 *output = input[0]; 370 369 else … … 389 388 }; 390 389 390 // Declarations to avoid StringUtils.h include 391 _UtilExport std::string removeTrailingWhitespaces(const std::string& str); 392 _UtilExport std::string getLowercase(const std::string& str); 393 391 394 // std::string to bool 392 395 template <> … … 395 398 static bool convert(bool* output, const std::string& input) 396 399 { 397 std::stringstripped = getLowercase(removeTrailingWhitespaces(input));400 const std::string& stripped = getLowercase(removeTrailingWhitespaces(input)); 398 401 if (stripped == "true" || stripped == "on" || stripped == "yes") 399 402 { 400 *output = true;401 return true;403 *output = true; 404 return true; 402 405 } 403 406 else if (stripped == "false" || stripped == "off" || stripped == "no") 404 407 { 405 *output = false;406 return true;408 *output = false; 409 return true; 407 410 } 408 411 -
code/branches/presentation2/src/libraries/util/Exception.cc
r5781 r6394 49 49 : description_(description) 50 50 , lineNumber_(0) 51 , functionName_("")52 , filename_("")53 51 { } 54 52 … … 61 59 const std::string& Exception::getFullDescription() const 62 60 { 63 if (fullDescription_ == "")61 if (fullDescription_.empty()) 64 62 { 65 63 std::ostringstream fullDesc; … … 67 65 fullDesc << this->getTypeName() << "Exception"; 68 66 69 if ( this->filename_ != "")67 if (!this->filename_.empty()) 70 68 { 71 69 fullDesc << " in " << this->filename_; 72 70 if (this->lineNumber_) 73 fullDesc << "(" << this->lineNumber_ << ")";71 fullDesc << '(' << this->lineNumber_ << ')'; 74 72 } 75 73 76 if ( this->functionName_ != "")77 fullDesc << " in function '" << this->functionName_ << "'";74 if (!this->functionName_.empty()) 75 fullDesc << " in function '" << this->functionName_ << '\''; 78 76 79 77 fullDesc << ": "; 80 if ( this->description_ != "")78 if (!this->description_.empty()) 81 79 fullDesc << this->description_; 82 80 else 83 81 fullDesc << "No description available."; 84 82 85 this->fullDescription_ = std::string(fullDesc.str());83 this->fullDescription_ = fullDesc.str(); 86 84 } 87 85 -
code/branches/presentation2/src/libraries/util/Math.h
r6137 r6394 165 165 template <> inline bool zeroise<bool>() { return 0; } 166 166 template <> inline void* zeroise<void*>() { return 0; } 167 template <> inline std::string zeroise<std::string>() { return ""; }167 template <> inline std::string zeroise<std::string>() { return std::string(); } 168 168 template <> inline orxonox::Radian zeroise<orxonox::Radian>() { return orxonox::Radian(0.0f); } 169 169 template <> inline orxonox::Degree zeroise<orxonox::Degree>() { return orxonox::Degree(0.0f); } -
code/branches/presentation2/src/libraries/util/MathConvert.h
r5738 r6394 53 53 { 54 54 std::ostringstream ostream; 55 if (ostream << input.x << ","<< input.y)55 if (ostream << input.x << ',' << input.y) 56 56 { 57 57 (*output) = ostream.str(); … … 69 69 { 70 70 std::ostringstream ostream; 71 if (ostream << input.x << "," << input.y << ","<< input.z)71 if (ostream << input.x << ',' << input.y << ',' << input.z) 72 72 { 73 73 (*output) = ostream.str(); … … 85 85 { 86 86 std::ostringstream ostream; 87 if (ostream << input.x << "," << input.y << "," << input.z << ","<< input.w)87 if (ostream << input.x << ',' << input.y << ',' << input.z << ',' << input.w) 88 88 { 89 89 (*output) = ostream.str(); … … 101 101 { 102 102 std::ostringstream ostream; 103 if (ostream << input.w << "," << input.x << "," << input.y << ","<< input.z)103 if (ostream << input.w << ',' << input.x << ',' << input.y << ',' << input.z) 104 104 { 105 105 (*output) = ostream.str(); … … 117 117 { 118 118 std::ostringstream ostream; 119 if (ostream << input.r << "," << input.g << "," << input.b << ","<< input.a)119 if (ostream << input.r << ',' << input.g << ',' << input.b << ',' << input.a) 120 120 { 121 121 (*output) = ostream.str(); -
code/branches/presentation2/src/libraries/util/OutputHandler.cc
r6277 r6394 77 77 #ifdef ORXONOX_PLATFORM_WINDOWS 78 78 char* pTempDir = getenv("TEMP"); 79 this->logFilename_ = std::string(pTempDir) + "/"+ logFileBaseName_g;79 this->logFilename_ = std::string(pTempDir) + '/' + logFileBaseName_g; 80 80 #else 81 81 this->logFilename_ = std::string("/tmp/") + logFileBaseName_g; -
code/branches/presentation2/src/libraries/util/StringUtils.cc
r5738 r6394 40 40 namespace orxonox 41 41 { 42 std::string BLANKSTRING ("");42 std::string BLANKSTRING; 43 43 44 44 std::string getUniqueNumberString() … … 54 54 { 55 55 size_t pos; 56 while ((pos = (*str).find( " ")) < (*str).length())56 while ((pos = (*str).find(' ')) < (*str).length()) 57 57 (*str).erase(pos, 1); 58 while ((pos = (*str).find( "\t")) < (*str).length())58 while ((pos = (*str).find('\t')) < (*str).length()) 59 59 (*str).erase(pos, 1); 60 while ((pos = (*str).find( "\n")) < (*str).length())60 while ((pos = (*str).find('\n')) < (*str).length()) 61 61 (*str).erase(pos, 1); 62 62 } … … 69 69 std::string getStripped(const std::string& str) 70 70 { 71 std::string output = std::string(str);71 std::string output(str); 72 72 strip(&output); 73 73 return output; … … 98 98 size_t quote = start - 1; 99 99 100 while ((quote = str.find(' \"', quote + 1)) != std::string::npos)100 while ((quote = str.find('"', quote + 1)) != std::string::npos) 101 101 { 102 102 size_t backslash = quote; … … 231 231 { 232 232 // Strip the line, whitespaces are disturbing 233 std::stringteststring = getStripped(str);233 const std::string& teststring = getStripped(str); 234 234 235 235 // There are four possible comment-symbols: … … 259 259 bool isEmpty(const std::string& str) 260 260 { 261 std::string temp = getStripped(str); 262 return ((temp == "") || (temp.size() == 0)); 261 return getStripped(str).empty(); 263 262 } 264 263 … … 303 302 for (size_t pos = 0; (pos = output.find('\f', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\f"); } 304 303 for (size_t pos = 0; (pos = output.find('\a', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\a"); } 305 for (size_t pos = 0; (pos = output.find('"' , pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\\""); }304 for (size_t pos = 0; (pos = output.find('"' , pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\\""); } 306 305 for (size_t pos = 0; (pos = output.find('\0', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\0"); } 307 306 … … 319 318 return str; 320 319 321 std::string output = "";320 std::string output; 322 321 for (size_t pos = 0; pos < str.size() - 1; ) 323 322 { … … 363 362 std::string getLowercase(const std::string& str) 364 363 { 365 std::string output = std::string(str);364 std::string output(str); 366 365 lowercase(&output); 367 366 return output; … … 387 386 std::string getUppercase(const std::string& str) 388 387 { 389 std::string output = std::string(str);388 std::string output(str); 390 389 uppercase(&output); 391 390 return output; -
code/branches/presentation2/src/libraries/util/SubString.cc
r6061 r6394 270 270 } 271 271 else 272 { 273 static std::string empty; 274 return empty; 275 } 272 return ""; 276 273 } 277 274 -
code/branches/presentation2/src/libraries/util/UtilPrereqs.h
r6105 r6394 131 131 } 132 132 133 // Just so you don't have to include StringUtils.h everywhere just for this 134 namespace orxonox 135 { 136 extern _UtilExport std::string BLANKSTRING; 137 } 138 139 133 140 #endif /* _UtilPrereqs_H__ */
Note: See TracChangeset
for help on using the changeset viewer.