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_xmlwriter.cpp | |
| parent | a5735af2f7d956600250541d289c552ace7e87ae (diff) | |
| download | catch3-devel-c++17.tar.gz | |
Use std::string_viewdevel-c++17
Diffstat (limited to 'src/catch2/internal/catch_xmlwriter.cpp')
| -rw-r--r-- | src/catch2/internal/catch_xmlwriter.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/catch2/internal/catch_xmlwriter.cpp b/src/catch2/internal/catch_xmlwriter.cpp index 67126be1..f5f00f75 100644 --- a/src/catch2/internal/catch_xmlwriter.cpp +++ b/src/catch2/internal/catch_xmlwriter.cpp @@ -47,7 +47,7 @@ namespace { void hexEscapeChar(std::ostream& os, unsigned char c) { std::ios_base::fmtflags f(os.flags()); - os << "\\x"_sr + os << "\\x" << std::uppercase << std::hex << std::setfill('0') << std::setw(2) << static_cast<int>(c); os.flags(f); @@ -79,25 +79,25 @@ namespace { switch ( c ) { case '<': write_to( idx ); - os << "<"_sr; + os << "<"; break; case '&': write_to( idx ); - os << "&"_sr; + os << "&"; break; case '>': // See: http://www.w3.org/TR/xml/#syntax if ( idx > 2 && m_str[idx - 1] == ']' && m_str[idx - 2] == ']' ) { write_to( idx ); - os << ">"_sr; + os << ">"; } break; case '\"': if ( m_forWhat == ForAttributes ) { write_to( idx ); - os << """_sr; + os << """; } break; @@ -209,14 +209,14 @@ namespace { } XmlWriter::ScopedElement& - XmlWriter::ScopedElement::writeText( StringRef text, XmlFormatting fmt ) { + XmlWriter::ScopedElement::writeText( std::string_view text, XmlFormatting fmt ) { m_writer->writeText( text, fmt ); return *this; } XmlWriter::ScopedElement& - XmlWriter::ScopedElement::writeAttribute( StringRef name, - StringRef attribute ) { + XmlWriter::ScopedElement::writeAttribute( std::string_view name, + std::string_view attribute ) { m_writer->writeAttribute( name, attribute ); return *this; } @@ -273,25 +273,25 @@ namespace { return *this; } - XmlWriter& XmlWriter::writeAttribute( StringRef name, - StringRef attribute ) { + XmlWriter& XmlWriter::writeAttribute( std::string_view name, + std::string_view attribute ) { if( !name.empty() && !attribute.empty() ) m_os << ' ' << name << "=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) << '"'; return *this; } - XmlWriter& XmlWriter::writeAttribute( StringRef name, bool attribute ) { - writeAttribute(name, (attribute ? "true"_sr : "false"_sr)); + XmlWriter& XmlWriter::writeAttribute( std::string_view name, bool attribute ) { + writeAttribute(name, (attribute ? "true" : "false")); return *this; } - XmlWriter& XmlWriter::writeAttribute( StringRef name, + XmlWriter& XmlWriter::writeAttribute( std::string_view name, char const* attribute ) { - writeAttribute( name, StringRef( attribute ) ); + writeAttribute( name, std::string_view( attribute ) ); return *this; } - XmlWriter& XmlWriter::writeText( StringRef text, XmlFormatting fmt ) { + XmlWriter& XmlWriter::writeText( std::string_view text, XmlFormatting fmt ) { CATCH_ENFORCE(!m_tags.empty(), "Cannot write text as top level element"); if( !text.empty() ){ bool tagWasOpen = m_tagIsOpen; @@ -305,7 +305,7 @@ namespace { return *this; } - XmlWriter& XmlWriter::writeComment( StringRef text, XmlFormatting fmt ) { + XmlWriter& XmlWriter::writeComment( std::string_view text, XmlFormatting fmt ) { ensureTagClosed(); if (shouldIndent(fmt)) { m_os << m_indent; @@ -315,7 +315,7 @@ namespace { return *this; } - void XmlWriter::writeStylesheetRef( StringRef url ) { + void XmlWriter::writeStylesheetRef( std::string_view url ) { m_os << R"(<?xml-stylesheet type="text/xsl" href=")" << url << R"("?>)" << '\n'; } |