OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GCode::GCodeOutputStream Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/GCode.hpp>

Collaboration diagram for Slic3r::GCode::GCodeOutputStream:

Public Member Functions

 GCodeOutputStream (FILE *f, GCodeProcessor &processor)
 ~GCodeOutputStream ()
bool is_open () const
bool is_error () const
void flush ()
void close ()
void write (const std::string &what)
void write (const char *what)
void writeln (const std::string &what)
void write_format (const char *format,...)

Private Attributes

FILE * f = nullptr
GCodeProcessor & m_processor

Detailed Description

Constructor & Destructor Documentation

◆ GCodeOutputStream()

Slic3r::GCode::GCodeOutputStream::GCodeOutputStream ( FILE * f,
GCodeProcessor & processor )
inline
413: f(f), m_processor(processor) {}
FILE * f
Definition GCode.hpp:435
GCodeProcessor & m_processor
Definition GCode.hpp:436

References f, and m_processor.

◆ ~GCodeOutputStream()

Slic3r::GCode::GCodeOutputStream::~GCodeOutputStream ( )
inline
414{ this->close(); }
void close()
Definition GCode.cpp:9063

References close().

Here is the call graph for this function:

Member Function Documentation

◆ close()

void Slic3r::GCode::GCodeOutputStream::close ( )
9064{
9065 if (this->f) {
9066 ::fclose(this->f);
9067 this->f = nullptr;
9068 }
9069}

References f.

Referenced by ~GCodeOutputStream(), and Slic3r::GCode::do_export().

Here is the caller graph for this function:

◆ flush()

void Slic3r::GCode::GCodeOutputStream::flush ( )
9059{
9060 ::fflush(this->f);
9061}

References f.

Referenced by Slic3r::GCode::do_export().

Here is the caller graph for this function:

◆ is_error()

bool Slic3r::GCode::GCodeOutputStream::is_error ( ) const
9054{
9055 return ::ferror(this->f);
9056}

References f.

Referenced by Slic3r::GCode::do_export().

Here is the caller graph for this function:

◆ is_open()

bool Slic3r::GCode::GCodeOutputStream::is_open ( ) const
inline
416{ return f; }

References f.

Referenced by Slic3r::GCode::do_export().

Here is the caller graph for this function:

◆ write() [1/2]

void Slic3r::GCode::GCodeOutputStream::write ( const char * what)
9072{
9073 if (what != nullptr) {
9074 const char* gcode = what;
9075 // writes string to file
9076 fwrite(gcode, 1, ::strlen(gcode), this->f);
9077 //FIXME don't allocate a string, maybe process a batch of lines?
9078 m_processor.process_buffer(std::string(gcode));
9079 }
9080}
@ gcode
Definition Time.hpp:14

References f, and m_processor.

◆ write() [2/2]

void Slic3r::GCode::GCodeOutputStream::write ( const std::string & what)
inline
423{ this->write(what.c_str()); }
void write(const std::string &what)
Definition GCode.hpp:423

References write().

Referenced by Slic3r::GCode::_do_export(), Slic3r::GCode::_print_first_layer_bed_temperature(), Slic3r::GCode::_print_first_layer_extruder_temperatures(), write(), write_format(), and writeln().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write_format()

void Slic3r::GCode::GCodeOutputStream::write_format ( const char * format,
... )
9089{
9090 va_list args;
9091 va_start(args, format);
9092
9093 int buflen;
9094 {
9095 va_list args2;
9096 va_copy(args2, args);
9097 buflen =
9098 #ifdef _MSC_VER
9099 ::_vscprintf(format, args2)
9100 #else
9101 ::vsnprintf(nullptr, 0, format, args2)
9102 #endif
9103 + 1;
9104 va_end(args2);
9105 }
9106
9107 char buffer[1024];
9108 bool buffer_dynamic = buflen > 1024;
9109 char *bufptr = buffer_dynamic ? (char*)malloc(buflen) : buffer;
9110 int res = ::vsnprintf(bufptr, buflen, format, args);
9111 if (res > 0)
9112 this->write(bufptr);
9113
9114 if (buffer_dynamic)
9115 free(bufptr);
9116
9117 va_end(args);
9118}
std::string format(const char *fmt, TArgs &&... args)
Definition format.hpp:45

References Slic3r::format(), and write().

Referenced by Slic3r::GCode::_do_export(), Slic3r::GCode::print_machine_envelope(), and Slic3r::BeltGCode::write_belt_header().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeln()

void Slic3r::GCode::GCodeOutputStream::writeln ( const std::string & what)
9083{
9084 if (! what.empty())
9085 this->write(what.back() == '\n' ? what : what + '\n');
9086}

References write().

Referenced by Slic3r::GCode::_do_export().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ f

FILE* Slic3r::GCode::GCodeOutputStream::f = nullptr
private

◆ m_processor

GCodeProcessor& Slic3r::GCode::GCodeOutputStream::m_processor
private

Referenced by GCodeOutputStream(), and write().


The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/GCode.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/GCode.cpp