| 46 | |
| 47 | template <typename F> |
| 48 | static void parse_errors(const std::string_view errors, F &&callback) |
| 49 | { |
| 50 | for (size_t offset = 0, next; offset != std::string_view::npos; offset = next) |
| 51 | { |
| 52 | const size_t pos_error = errors.find(": ", offset); |
| 53 | const size_t pos_error_line = errors.rfind('(', pos_error); // Paths can contain '(', but no ": ", so search backwards from the error location to find the line info |
| 54 | if (pos_error == std::string_view::npos || pos_error_line == std::string_view::npos || pos_error_line < offset) |
| 55 | break; |
| 56 | |
| 57 | const size_t pos_linefeed = errors.find('\n', pos_error); |
| 58 | |
| 59 | next = pos_linefeed != std::string_view::npos ? pos_linefeed + 1 : std::string_view::npos; |
| 60 | |
| 61 | const std::string_view error_file = errors.substr(offset, pos_error_line - offset); |
| 62 | int error_line = static_cast<int>(std::strtol(errors.data() + pos_error_line + 1, nullptr, 10)); |
| 63 | const std::string_view error_text = errors.substr(pos_error + 2 /* skip space */, pos_linefeed - pos_error - 2); |
| 64 | |
| 65 | callback(error_file, error_line, error_text); |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | template <typename T> |
| 70 | static std::string_view get_localized_annotation(T &object, const std::string_view ann_name, [[maybe_unused]] std::string language) |
no outgoing calls
no test coverage detected