diff --git a/components/core/src/clp_s/TimestampPattern.cpp b/components/core/src/clp_s/TimestampPattern.cpp index 0bfa5cf0f..11fab3480 100644 --- a/components/core/src/clp_s/TimestampPattern.cpp +++ b/components/core/src/clp_s/TimestampPattern.cpp @@ -14,6 +14,7 @@ using clp::string_utils::convert_string_to_int; using std::string; +using std::string_view; using std::to_string; using std::vector; @@ -73,7 +74,7 @@ append_padded_value_notz(int value, char padding_character, size_t max_length, s * @return true if conversion succeeds, false otherwise */ static bool convert_string_to_number( - std::string_view str, + string_view str, size_t begin_ix, size_t end_ix, char padding_character, @@ -91,7 +92,7 @@ static bool convert_string_to_number( * @return true if conversion succeeds, false otherwise */ static bool convert_string_to_number_notz( - std::string_view str, + string_view str, size_t max_digits, size_t begin_ix, size_t& end_ix, @@ -127,7 +128,7 @@ append_padded_value_notz(int value, char padding_character, size_t max_length, s } static bool convert_string_to_number( - std::string_view str, + string_view str, size_t begin_ix, size_t end_ix, char padding_character, @@ -156,7 +157,7 @@ static bool convert_string_to_number( } static bool convert_string_to_number_notz( - std::string_view str, + string_view str, size_t max_digits, size_t begin_ix, size_t& end_ix, @@ -308,7 +309,7 @@ void TimestampPattern::init() { } TimestampPattern const* TimestampPattern::search_known_ts_patterns( - std::string_view line, + string_view line, epochtime_t& timestamp, size_t& timestamp_begin_pos, size_t& timestamp_end_pos @@ -344,7 +345,7 @@ void TimestampPattern::clear() { } bool TimestampPattern::parse_timestamp( - std::string_view line, + string_view line, epochtime_t& timestamp, size_t& timestamp_begin_pos, size_t& timestamp_end_pos @@ -829,23 +830,20 @@ bool TimestampPattern::parse_timestamp( } auto dot_position = line.find('.'); auto nanosecond_start = dot_position + 1; - if (std::string::npos == dot_position || 0 == dot_position + if (string::npos == dot_position || 0 == dot_position || cNanosecondDigits != (line.length() - nanosecond_start)) { return false; } - auto timestamp_view = std::string_view(line); - if (false - == convert_string_to_int(timestamp_view.substr(0, dot_position), timestamp)) - { + if (false == convert_string_to_int(line.substr(0, dot_position), timestamp)) { return false; } epochtime_t timestamp_nanoseconds; if (false == convert_string_to_int( - timestamp_view.substr(nanosecond_start, cNanosecondDigits), + line.substr(nanosecond_start, cNanosecondDigits), timestamp_nanoseconds )) { @@ -1072,14 +1070,14 @@ void TimestampPattern::insert_formatted_timestamp(epochtime_t timestamp, string& case 'E': // UNIX epoch milliseconds // Note: this timestamp format is required to make up the entire timestamp, so // this is safe - new_msg = std::to_string(timestamp); + new_msg = to_string(timestamp); break; case 'F': { // Nanosecond precision floating point UNIX epoch timestamp constexpr auto cNanosecondDigits = 9; // Note: this timestamp format is required to make up the entire timestamp, so // this is safe - new_msg = std::to_string(timestamp); + new_msg = to_string(timestamp); new_msg.insert(new_msg.end() - cNanosecondDigits, '.'); break; }