Report use string instead of string_view

Signed-off-by: James Cherry <cherry@parallaxsw.com>
This commit is contained in:
James Cherry 2026-03-18 13:01:05 -07:00
parent 90df0cfea5
commit 464bc3ae4f
5 changed files with 18 additions and 23 deletions

View File

@ -138,13 +138,13 @@ public:
} }
// Log output to filename until logEnd is called. // Log output to filename until logEnd is called.
virtual void logBegin(std::string_view filename); virtual void logBegin(std::string filename);
virtual void logEnd(); virtual void logEnd();
// Redirect output to filename until redirectFileEnd is called. // Redirect output to filename until redirectFileEnd is called.
virtual void redirectFileBegin(std::string_view filename); virtual void redirectFileBegin(std::string filename);
// Redirect append output to filename until redirectFileEnd is called. // Redirect append output to filename until redirectFileEnd is called.
virtual void redirectFileAppendBegin(std::string_view filename); virtual void redirectFileAppendBegin(std::string filename);
virtual void redirectFileEnd(); virtual void redirectFileEnd();
// Redirect output to a string until redirectStringEnd is called. // Redirect output to a string until redirectStringEnd is called.
virtual void redirectStringBegin(); virtual void redirectStringBegin();

View File

@ -44,10 +44,10 @@ class ReportTcl : public Report
public: public:
ReportTcl(); ReportTcl();
virtual ~ReportTcl(); virtual ~ReportTcl();
void logBegin(std::string_view filename) override; void logBegin(std::string filename) override;
void logEnd() override; void logEnd() override;
void redirectFileBegin(std::string_view filename) override; void redirectFileBegin(std::string filename) override;
void redirectFileAppendBegin(std::string_view filename) override; void redirectFileAppendBegin(std::string filename) override;
void redirectFileEnd() override; void redirectFileEnd() override;
void redirectStringBegin() override; void redirectStringBegin() override;
const char *redirectStringEnd() override; const char *redirectStringEnd() override;

View File

@ -27,8 +27,6 @@
#include <string> #include <string>
#include <istream> #include <istream>
#include "LibertyParser.hh"
#include "LibertyLocation.hh"
#include "LibertyParse.hh" #include "LibertyParse.hh"
#ifndef __FLEX_LEXER_H #ifndef __FLEX_LEXER_H

View File

@ -185,12 +185,11 @@ Report::isSuppressed(int id)
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
void void
Report::logBegin(std::string_view filename) Report::logBegin(std::string filename)
{ {
std::string filename_str(filename); log_stream_ = fopen(filename.c_str(), "w");
log_stream_ = fopen(filename_str.c_str(), "w");
if (log_stream_ == nullptr) if (log_stream_ == nullptr)
throw FileNotWritable(std::move(filename_str)); throw FileNotWritable(std::move(filename));
} }
void void
@ -202,21 +201,19 @@ Report::logEnd()
} }
void void
Report::redirectFileBegin(std::string_view filename) Report::redirectFileBegin(std::string filename)
{ {
std::string filename_str(filename); redirect_stream_ = fopen(filename.c_str(), "w");
redirect_stream_ = fopen(filename_str.c_str(), "w");
if (redirect_stream_ == nullptr) if (redirect_stream_ == nullptr)
throw FileNotWritable(std::move(filename_str)); throw FileNotWritable(std::move(filename));
} }
void void
Report::redirectFileAppendBegin(std::string_view filename) Report::redirectFileAppendBegin(std::string filename)
{ {
std::string filename_str(filename); redirect_stream_ = fopen(filename.c_str(), "a");
redirect_stream_ = fopen(filename_str.c_str(), "a");
if (redirect_stream_ == nullptr) if (redirect_stream_ == nullptr)
throw FileNotWritable(std::move(filename_str)); throw FileNotWritable(std::move(filename));
} }
void void

View File

@ -183,7 +183,7 @@ ReportTcl::flush()
// Tcl_Main can eval multiple commands before the flushing the command // Tcl_Main can eval multiple commands before the flushing the command
// output, so the log/redirect commands must force a flush. // output, so the log/redirect commands must force a flush.
void void
ReportTcl::logBegin(std::string_view filename) ReportTcl::logBegin(std::string filename)
{ {
flush(); flush();
Report::logBegin(filename); Report::logBegin(filename);
@ -197,14 +197,14 @@ ReportTcl::logEnd()
} }
void void
ReportTcl::redirectFileBegin(std::string_view filename) ReportTcl::redirectFileBegin(std::string filename)
{ {
flush(); flush();
Report::redirectFileBegin(filename); Report::redirectFileBegin(filename);
} }
void void
ReportTcl::redirectFileAppendBegin(std::string_view filename) ReportTcl::redirectFileAppendBegin(std::string filename)
{ {
flush(); flush();
Report::redirectFileAppendBegin(filename); Report::redirectFileAppendBegin(filename);