52 lines
1.1 KiB
C++
52 lines
1.1 KiB
C++
|
|
#pragma once
|
||
|
|
|
||
|
|
#include <string>
|
||
|
|
#include <utility>
|
||
|
|
#include <vector>
|
||
|
|
|
||
|
|
namespace grbl {
|
||
|
|
|
||
|
|
enum class instruction_type {
|
||
|
|
gcode,
|
||
|
|
comment,
|
||
|
|
user_message
|
||
|
|
};
|
||
|
|
|
||
|
|
struct instruction {
|
||
|
|
static instruction new_gcode(size_t line, std::string cmd, std::string comment = "");
|
||
|
|
static instruction new_user_message(size_t line, std::string comment = "");
|
||
|
|
static instruction new_comment(size_t line, std::string comment = "");
|
||
|
|
|
||
|
|
size_t line = 0;
|
||
|
|
instruction_type type = instruction_type::comment;
|
||
|
|
std::string command;
|
||
|
|
std::string comment;
|
||
|
|
};
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
struct program {
|
||
|
|
program() = default;
|
||
|
|
explicit program(std::string filename);
|
||
|
|
|
||
|
|
bool load(std::string filename);
|
||
|
|
bool load(std::istream& in);
|
||
|
|
bool load_from_string(const std::string& content);
|
||
|
|
|
||
|
|
void dump(std::ostream& out);
|
||
|
|
|
||
|
|
size_t number_of_instructions() const {
|
||
|
|
return instructions.size();
|
||
|
|
}
|
||
|
|
|
||
|
|
instruction instruction_at(size_t index) {
|
||
|
|
return instructions.at(index);
|
||
|
|
}
|
||
|
|
|
||
|
|
bool is_loaded = false;
|
||
|
|
std::string filename;
|
||
|
|
std::vector<instruction> instructions{};
|
||
|
|
};
|
||
|
|
|
||
|
|
}
|