Branch data Line data Source code
1 : : #ifndef DBC_TEXT_UTILS_H
2 : : #define DBC_TEXT_UTILS_H
3 : :
4 : : #include <cctype>
5 : : #include <string>
6 : :
7 : : namespace dbc_detail {
8 : 2913 : inline std::string TrimText(const std::string &text) {
9 : 2913 : std::string::size_type begin = 0U;
10 [ + + + + ]: 5727 : while ((begin < text.size()) &&
11 [ + + ]: 2692 : std::isspace(static_cast<unsigned char>(text[begin])))
12 : 122 : ++begin;
13 : :
14 : 2913 : std::string::size_type end = text.size();
15 [ + + + + ]: 5491 : while ((end > begin) &&
16 [ + + ]: 2574 : std::isspace(static_cast<unsigned char>(text[end - 1U])))
17 : 4 : --end;
18 : :
19 : 2913 : return text.substr(begin, end - begin);
20 : : }
21 : : }
22 : :
23 : : #endif
|