#include "gcode.h" #include "../string_utils.h" std::vector iosender::ToIndices(iosender::AxisFlags flags) { std::vector result; int i = 0, j = (int) flags; while (j != 0) { if ((j & 0x01) != 0) result.push_back(i); i++; j >>= 1; } return result; } std::vector iosender::ToIndices(iosender::IJKFlags flags) { std::vector result; int i = 0, j = (int) flags; while (j != 0) { if ((j & 0x01) != 0) result.push_back(i); i++; j >>= 1; } return result; } std::vector iosender::ToIndices(iosender::ThreadingFlags flags) { std::vector result; int i = 0, j = (int) flags; while (j != 0) { if ((j & 0x01) != 0) result.push_back(i); i++; j >>= 1; } return result; } std::string iosender::GCodeUtils::StripSpaces(std::string line) { std::string s; bool skip = true; s = to_upper(line); if (string_contains(s, "(MSG,")) { s = ""; for (auto c: line) { switch (c) { case '(': s += c; skip = false; break; case ')': skip = true; s += c; break; case ' ': if (!skip) s += c; break; default: s += c; break; } } } else { s = remove_spaces(line); } return s; }