Changeset 8801 for code/branches/output/src/libraries/util
- Timestamp:
- Jul 30, 2011, 9:31:05 PM (13 years ago)
- Location:
- code/branches/output/src/libraries/util
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/output/src/libraries/util/StringUtils.cc
r8232 r8801 79 79 for (; pos2 > 0 && (str[pos2] == ' ' || str[pos2] == '\t' || str[pos2] == '\n'); pos2--); 80 80 return str.substr(pos1, pos2 - pos1 + 1); 81 } 82 83 /// Splits a given string by a delimiter and stores it in an output vector 84 void vectorize(const std::string& str, char delimiter, std::vector<std::string>* output) 85 { 86 for (size_t start = 0, end = 0; end != std::string::npos; start = end + 1) 87 { 88 end = str.find_first_of(delimiter, start); 89 output->push_back(str.substr(start, end - start)); 90 } 81 91 } 82 92 … … 517 527 return matrix[(rows-1)*cols + cols-1]; 518 528 } 519 529 520 530 /** 521 531 @brief -
code/branches/output/src/libraries/util/StringUtils.h
r8232 r8801 43 43 #include "UtilPrereqs.h" 44 44 #include <string> 45 #include <vector> 45 46 46 47 namespace orxonox … … 54 55 55 56 _UtilExport std::string removeTrailingWhitespaces(const std::string& str); 57 58 _UtilExport void vectorize(const std::string& str, char delimiter, std::vector<std::string>* output); 56 59 57 60 _UtilExport size_t getNextQuote(const std::string& str, size_t start); … … 88 91 89 92 _UtilExport unsigned int getLevenshteinDistance(const std::string& str1, const std::string& str2); 90 93 91 94 _UtilExport std::string getTimestamp(void); 92 95 } -
code/branches/output/src/libraries/util/output/OutputManager.cc
r8799 r8801 32 32 #include "ConsoleWriter.h" 33 33 #include "LogWriter.h" 34 #include "util/StringUtils.h" 34 35 35 36 namespace orxonox … … 65 66 { 66 67 std::vector<std::string> lines; 67 for (size_t start = 0, end = 0; end != std::string::npos; start = end + 1) 68 { 69 end = message.find_first_of('\n', start); 70 lines.push_back(message.substr(start, end)); 71 } 68 vectorize(message, '\n', &lines); 72 69 73 70 for (size_t i = 0; i < this->listeners_.size(); ++i)
Note: See TracChangeset
for help on using the changeset viewer.