24 lines
584 B
C++
24 lines
584 B
C++
#ifndef DBC_TEXT_UTILS_H
|
|
#define DBC_TEXT_UTILS_H
|
|
|
|
#include <cctype>
|
|
#include <string>
|
|
|
|
namespace dbc_detail {
|
|
inline std::string TrimText(const std::string &text) {
|
|
std::string::size_type begin = 0U;
|
|
while ((begin < text.size()) &&
|
|
std::isspace(static_cast<unsigned char>(text[begin])))
|
|
++begin;
|
|
|
|
std::string::size_type end = text.size();
|
|
while ((end > begin) &&
|
|
std::isspace(static_cast<unsigned char>(text[end - 1U])))
|
|
--end;
|
|
|
|
return text.substr(begin, end - begin);
|
|
}
|
|
}
|
|
|
|
#endif
|