OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::anonymous_namespace{GCodeProcessor.cpp}::GCodeFileWriter Class Reference
Collaboration diagram for Slic3r::anonymous_namespace{GCodeProcessor.cpp}::GCodeFileWriter:

Public Member Functions

 GCodeFileWriter (FilePtr &out, const std::string &out_path, std::vector< size_t > &lines_ends, const char *error_message)
 ~GCodeFileWriter ()
void append (std::string_view text)
void flush ()

Private Attributes

FilePtr & m_out
const std::string & m_out_path
std::vector< size_t > & m_lines_ends
const char * m_error_message
std::string m_buffer
size_t m_file_pos {0}

Detailed Description

Constructor & Destructor Documentation

◆ GCodeFileWriter()

Slic3r::anonymous_namespace{GCodeProcessor.cpp}::GCodeFileWriter::GCodeFileWriter ( FilePtr & out,
const std::string & out_path,
std::vector< size_t > & lines_ends,
const char * error_message )
inline
861 : m_out(out), m_out_path(out_path), m_lines_ends(lines_ends), m_error_message(error_message)
862 {}
std::vector< size_t > & m_lines_ends
Definition GCodeProcessor.cpp:892
const std::string & m_out_path
Definition GCodeProcessor.cpp:891
const char * m_error_message
Definition GCodeProcessor.cpp:893
FilePtr & m_out
Definition GCodeProcessor.cpp:890

References m_error_message, m_lines_ends, m_out, and m_out_path.

◆ ~GCodeFileWriter()

Slic3r::anonymous_namespace{GCodeProcessor.cpp}::GCodeFileWriter::~GCodeFileWriter ( )
inline
863{ assert(m_buffer.empty() || std::uncaught_exceptions() > 0); }
std::string m_buffer
Definition GCodeProcessor.cpp:894

References m_buffer.

Member Function Documentation

◆ append()

void Slic3r::anonymous_namespace{GCodeProcessor.cpp}::GCodeFileWriter::append ( std::string_view text)
inline
866 {
867 const size_t text_pos = m_file_pos + m_buffer.size();
868 for (size_t i = text.find('\n'); i != std::string_view::npos; i = text.find('\n', i + 1))
869 m_lines_ends.emplace_back(text_pos + i + 1);
870 m_buffer += text;
872 flush();
873 }
static constexpr size_t Output_Block_Size
Definition GCodeProcessor.hpp:582

References flush(), m_buffer, m_file_pos, m_lines_ends, and Slic3r::GCodeProcessor::Output_Block_Size.

Here is the call graph for this function:

◆ flush()

void Slic3r::anonymous_namespace{GCodeProcessor.cpp}::GCodeFileWriter::flush ( )
inline
876 {
877 if (m_buffer.empty())
878 return;
879 fwrite(m_buffer.data(), 1, m_buffer.size(), m_out.f);
880 if (ferror(m_out.f)) {
881 m_out.close();
882 boost::nowide::remove(m_out_path.c_str());
883 throw Slic3r::RuntimeError(m_error_message);
884 }
885 m_file_pos += m_buffer.size();
886 m_buffer.clear();
887 }

References m_buffer, m_error_message, m_file_pos, m_out, and m_out_path.

Referenced by append().

Here is the caller graph for this function:

Member Data Documentation

◆ m_buffer

std::string Slic3r::anonymous_namespace{GCodeProcessor.cpp}::GCodeFileWriter::m_buffer
private

Referenced by ~GCodeFileWriter(), append(), and flush().

◆ m_error_message

const char* Slic3r::anonymous_namespace{GCodeProcessor.cpp}::GCodeFileWriter::m_error_message
private

Referenced by GCodeFileWriter(), and flush().

◆ m_file_pos

size_t Slic3r::anonymous_namespace{GCodeProcessor.cpp}::GCodeFileWriter::m_file_pos {0}
private
895{0};

Referenced by append(), and flush().

◆ m_lines_ends

std::vector<size_t>& Slic3r::anonymous_namespace{GCodeProcessor.cpp}::GCodeFileWriter::m_lines_ends
private

Referenced by GCodeFileWriter(), and append().

◆ m_out

FilePtr& Slic3r::anonymous_namespace{GCodeProcessor.cpp}::GCodeFileWriter::m_out
private

Referenced by GCodeFileWriter(), and flush().

◆ m_out_path

const std::string& Slic3r::anonymous_namespace{GCodeProcessor.cpp}::GCodeFileWriter::m_out_path
private

Referenced by GCodeFileWriter(), and flush().


The documentation for this class was generated from the following file: