Files
grbl-sender/grbl.h
T

52 lines
1.1 KiB
C++
Raw Normal View History

2023-04-27 14:31:06 +03:00
#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);
2023-04-28 18:42:18 +03:00
bool load_from_file(std::string filename);
bool load_from_stream(std::istream& in);
2023-04-27 14:31:06 +03:00
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{};
};
}