mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 13:26:10 +01:00
Use std::string instead of StringRef as argument to the makeStream
This is done because `makeStream` was the only place using `StringRef::c_str()`, which is an error-prone and unsafe API that I want to remove.
This commit is contained in:
parent
2c269eb633
commit
e50e10ef8f
@ -74,7 +74,7 @@ namespace Detail {
|
||||
class FileStream : public IStream {
|
||||
mutable std::ofstream m_ofs;
|
||||
public:
|
||||
FileStream( StringRef filename ) {
|
||||
FileStream( std::string const& filename ) {
|
||||
m_ofs.open( filename.c_str() );
|
||||
CATCH_ENFORCE( !m_ofs.fail(), "Unable to open file: '" << filename << "'" );
|
||||
}
|
||||
@ -121,7 +121,7 @@ namespace Detail {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
auto makeStream( StringRef const &filename ) -> IStream const* {
|
||||
auto makeStream( std::string const& filename ) -> IStream const* {
|
||||
if( filename.empty() )
|
||||
return new Detail::CoutStream();
|
||||
else if( filename[0] == '%' ) {
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <iosfwd>
|
||||
#include <cstddef>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
@ -20,14 +21,12 @@ namespace Catch {
|
||||
std::ostream& cerr();
|
||||
std::ostream& clog();
|
||||
|
||||
class StringRef;
|
||||
|
||||
struct IStream {
|
||||
virtual ~IStream();
|
||||
virtual std::ostream& stream() const = 0;
|
||||
};
|
||||
|
||||
auto makeStream( StringRef const &filename ) -> IStream const*;
|
||||
auto makeStream( std::string const& filename ) -> IStream const*;
|
||||
|
||||
class ReusableStringStream : Detail::NonCopyable {
|
||||
std::size_t m_index;
|
||||
|
Loading…
Reference in New Issue
Block a user