Refactor to provide an istream prototype for parse()

This commit is contained in:
Joseph Lenox 2018-07-14 20:19:28 -05:00
parent 2f8c88cb96
commit 1bf8ca7a59
2 changed files with 7 additions and 1 deletions

View File

@ -17,8 +17,13 @@ void
GCodeReader::parse(const std::string &gcode, callback_t callback)
{
std::istringstream ss(gcode);
this->parse_stream(ss, callback);
}
void GCodeReader::parse_stream(std::istream &gcode, callback_t callback)
{
std::string line;
while (std::getline(ss, line))
while (std::getline(gcode, line))
this->parse_line(line, callback);
}

View File

@ -54,6 +54,7 @@ class GCodeReader {
GCodeReader() : X(0), Y(0), Z(0), E(0), F(0), verbose(false), _extrusion_axis('E') {};
void apply_config(const PrintConfigBase &config);
void parse(const std::string &gcode, callback_t callback);
void parse_stream(std::istream &gcode, callback_t callback);
void parse_line(std::string line, callback_t callback);
void parse_file(const std::string &file, callback_t callback);