Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMartin Hořeňovský2025-10-16 20:37:05 +0200
committerMartin Hořeňovský2025-10-16 20:37:05 +0200
commit3b853aa9fbe16569a30b176e1a76fa4d72c63551 (patch)
tree238089fe176a22932917d4f2e1c5593e7d6538b2
parent49d79e9e9c40e644304945dd5a8e4e78d0c61d10 (diff)
downloadcatch3-3b853aa9fbe16569a30b176e1a76fa4d72c63551.tar.gz
Add lifetime attributes to JSON/XML writers
-rw-r--r--src/catch2/internal/catch_jsonwriter.hpp13
-rw-r--r--src/catch2/internal/catch_xmlwriter.hpp7
2 files changed, 11 insertions, 9 deletions
diff --git a/src/catch2/internal/catch_jsonwriter.hpp b/src/catch2/internal/catch_jsonwriter.hpp
index 23b56d13..8b3d2bc1 100644
--- a/src/catch2/internal/catch_jsonwriter.hpp
+++ b/src/catch2/internal/catch_jsonwriter.hpp
@@ -8,6 +8,7 @@
#ifndef CATCH_JSONWRITER_HPP_INCLUDED
#define CATCH_JSONWRITER_HPP_INCLUDED
+#include <catch2/internal/catch_lifetimebound.hpp>
#include <catch2/internal/catch_reusable_string_stream.hpp>
#include <catch2/internal/catch_stringref.hpp>
@@ -27,8 +28,8 @@ namespace Catch {
class JsonValueWriter {
public:
- JsonValueWriter( std::ostream& os );
- JsonValueWriter( std::ostream& os, std::uint64_t indent_level );
+ JsonValueWriter( std::ostream& os CATCH_ATTR_LIFETIMEBOUND );
+ JsonValueWriter( std::ostream& os CATCH_ATTR_LIFETIMEBOUND, std::uint64_t indent_level );
JsonObjectWriter writeObject() &&;
JsonArrayWriter writeArray() &&;
@@ -62,8 +63,8 @@ namespace Catch {
class JsonObjectWriter {
public:
- JsonObjectWriter( std::ostream& os );
- JsonObjectWriter( std::ostream& os, std::uint64_t indent_level );
+ JsonObjectWriter( std::ostream& os CATCH_ATTR_LIFETIMEBOUND );
+ JsonObjectWriter( std::ostream& os CATCH_ATTR_LIFETIMEBOUND, std::uint64_t indent_level );
JsonObjectWriter( JsonObjectWriter&& source ) noexcept;
JsonObjectWriter& operator=( JsonObjectWriter&& source ) = delete;
@@ -81,8 +82,8 @@ namespace Catch {
class JsonArrayWriter {
public:
- JsonArrayWriter( std::ostream& os );
- JsonArrayWriter( std::ostream& os, std::uint64_t indent_level );
+ JsonArrayWriter( std::ostream& os CATCH_ATTR_LIFETIMEBOUND );
+ JsonArrayWriter( std::ostream& os CATCH_ATTR_LIFETIMEBOUND, std::uint64_t indent_level );
JsonArrayWriter( JsonArrayWriter&& source ) noexcept;
JsonArrayWriter& operator=( JsonArrayWriter&& source ) = delete;
diff --git a/src/catch2/internal/catch_xmlwriter.hpp b/src/catch2/internal/catch_xmlwriter.hpp
index 22b42c5c..0b549cd7 100644
--- a/src/catch2/internal/catch_xmlwriter.hpp
+++ b/src/catch2/internal/catch_xmlwriter.hpp
@@ -8,6 +8,7 @@
#ifndef CATCH_XMLWRITER_HPP_INCLUDED
#define CATCH_XMLWRITER_HPP_INCLUDED
+#include <catch2/internal/catch_lifetimebound.hpp>
#include <catch2/internal/catch_reusable_string_stream.hpp>
#include <catch2/internal/catch_stringref.hpp>
@@ -43,7 +44,7 @@ namespace Catch {
public:
enum ForWhat { ForTextNodes, ForAttributes };
- constexpr XmlEncode( StringRef str, ForWhat forWhat = ForTextNodes ):
+ constexpr XmlEncode( StringRef str CATCH_ATTR_LIFETIMEBOUND, ForWhat forWhat = ForTextNodes ):
m_str( str ), m_forWhat( forWhat ) {}
@@ -61,7 +62,7 @@ namespace Catch {
class ScopedElement {
public:
- ScopedElement( XmlWriter* writer, XmlFormatting fmt );
+ ScopedElement( XmlWriter* writer CATCH_ATTR_LIFETIMEBOUND, XmlFormatting fmt );
ScopedElement( ScopedElement&& other ) noexcept;
ScopedElement& operator=( ScopedElement&& other ) noexcept;
@@ -93,7 +94,7 @@ namespace Catch {
XmlFormatting m_fmt;
};
- XmlWriter( std::ostream& os );
+ XmlWriter( std::ostream& os CATCH_ATTR_LIFETIMEBOUND );
~XmlWriter();
XmlWriter( XmlWriter const& ) = delete;