void MsgLogger::log(std::string const & msg) { boost::lock_guard<boost::mutex> guard(m_data_lock); std::string::size_type first_eol = msg.find('\n'); // log end of first and last message strings if (first_eol != std::string::npos && first_eol != msg.length() - 1) m_data.push_back(last_substr(msg, first_eol)); m_data.push_back(last_substr(msg, msg.length())); }
inline std::vector<std::string> split(const std::string& str, const std::string& sep) { std::vector<std::string> substr; substr.push_back(str); std::string last_substr(str); if (sep.empty()) { return substr; } do { auto split = split_first(last_substr, sep); substr[substr.size()-1] = split.first; substr.push_back(split.second); last_substr = substr[substr.size()-1]; } while(!last_substr.empty()); substr.pop_back(); return substr; }