diff options
| author | Chris Thrasher | 2025-09-21 18:05:21 -0600 |
|---|---|---|
| committer | Chris Thrasher | 2025-09-22 11:50:44 -0600 |
| commit | 8efee9b7632e6dd014b5b041ee326eef7d0b09e6 (patch) | |
| tree | fbc1657a5d7d414fbe93a412990bcf5cfb2df438 /src/catch2/internal/catch_jsonwriter.cpp | |
| parent | a5735af2f7d956600250541d289c552ace7e87ae (diff) | |
| download | catch3-devel-c++17.tar.gz | |
Use std::string_viewdevel-c++17
Diffstat (limited to 'src/catch2/internal/catch_jsonwriter.cpp')
| -rw-r--r-- | src/catch2/internal/catch_jsonwriter.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/catch2/internal/catch_jsonwriter.cpp b/src/catch2/internal/catch_jsonwriter.cpp index 6915c9c3..b4a749f8 100644 --- a/src/catch2/internal/catch_jsonwriter.cpp +++ b/src/catch2/internal/catch_jsonwriter.cpp @@ -17,21 +17,21 @@ namespace Catch { c == '\n' || c == '\r' || c == '\t'; } - static Catch::StringRef makeEscapeStringRef( char c ) { + static std::string_view makeEscapeStringRef( char c ) { if ( c == '"' ) { - return "\\\""_sr; + return "\\\""; } else if ( c == '\\' ) { - return "\\\\"_sr; + return "\\\\"; } else if ( c == '\b' ) { - return "\\b"_sr; + return "\\b"; } else if ( c == '\f' ) { - return "\\f"_sr; + return "\\f"; } else if ( c == '\n' ) { - return "\\n"_sr; + return "\\n"; } else if ( c == '\r' ) { - return "\\r"_sr; + return "\\r"; } else if ( c == '\t' ) { - return "\\t"_sr; + return "\\t"; } Catch::Detail::Unreachable(); } @@ -75,7 +75,7 @@ namespace Catch { m_os << '}'; } - JsonValueWriter JsonObjectWriter::write( StringRef key ) { + JsonValueWriter JsonObjectWriter::write( std::string_view key ) { JsonUtils::appendCommaNewline( m_os, m_should_comma, m_indent_level + 1 ); @@ -136,15 +136,15 @@ namespace Catch { return JsonArrayWriter{ m_os, m_indent_level }; } - void JsonValueWriter::write( Catch::StringRef value ) && { + void JsonValueWriter::write( std::string_view value ) && { writeImpl( value, true ); } void JsonValueWriter::write( bool value ) && { - writeImpl( value ? "true"_sr : "false"_sr, false ); + writeImpl( value ? "true" : "false", false ); } - void JsonValueWriter::writeImpl( Catch::StringRef value, bool quote ) { + void JsonValueWriter::writeImpl( std::string_view value, bool quote ) { if ( quote ) { m_os << '"'; } size_t current_start = 0; for ( size_t i = 0; i < value.size(); ++i ) { |