SpECTRE Documentation Coverage Report
Current view: top level - Utilities - MakeString.hpp Hit Total Coverage
Commit: 817e13c5144619b701c7cd870655d8dbf94ab8ce Lines: 1 12 8.3 %
Date: 2024-07-19 22:17:05
Legend: Lines: hit not hit

          Line data    Source code
       1           0 : // Distributed under the MIT License.
       2             : // See LICENSE.txt for details.
       3             : 
       4             : #pragma once
       5             : 
       6             : #include <ostream>
       7             : #include <sstream>
       8             : #include <string>
       9             : 
      10             : #include "Utilities/StlStreamDeclarations.hpp"
      11             : 
      12             : /*!
      13             :  * \ingroup UtilitiesGroup
      14             :  * \brief Make a string by streaming into object.
      15             :  *
      16             :  * \snippet Test_MakeString.cpp make_string
      17             :  */
      18           1 : class MakeString {
      19             :  public:
      20           0 :   MakeString() = default;
      21           0 :   MakeString(const MakeString&) = delete;
      22           0 :   MakeString& operator=(const MakeString&) = delete;
      23           0 :   MakeString(MakeString&&) = default;
      24           0 :   MakeString& operator=(MakeString&&) = delete;
      25           0 :   ~MakeString() = default;
      26             : 
      27             :   // NOLINTNEXTLINE(google-explicit-constructor)
      28             :   operator std::string() const { return stream_.str(); }
      29             : 
      30             :   template <class T>
      31           0 :   friend MakeString operator<<(MakeString&& ms, const T& t) {
      32             :     // clang-tidy: can get unintentional pointer casts
      33             :     ms.stream_ << t;  // NOLINT
      34             :     return std::move(ms);
      35             :   }
      36             : 
      37             :   template <class T>
      38           0 :   friend MakeString& operator<<(MakeString& ms, const T& t) {
      39             :     // clang-tidy: can get unintentional pointer casts
      40             :     ms.stream_ << t;  // NOLINT
      41             :     return ms;
      42             :   }
      43             : 
      44             :  private:
      45           0 :   std::stringstream stream_{};
      46             : };
      47             : 
      48           0 : inline std::ostream& operator<<(std::ostream& os, const MakeString& t) {
      49             :   return os << std::string{t};
      50             : }

Generated by: LCOV version 1.14