Skip to content

Commit

Permalink
Print each line on seperate line
Browse files Browse the repository at this point in the history
CURA-10561
  • Loading branch information
casperlamboo committed Oct 27, 2023
1 parent 01f73f3 commit ad56e31
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ target_link_libraries(dulcificum
PUBLIC
nlohmann_json::nlohmann_json
ctre::ctre
PRIVATE
range-v3::range-v3
spdlog::spdlog)

Expand Down
19 changes: 13 additions & 6 deletions include/dulcificum.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,26 @@
#include <dulcificum/gcode/parse.h>
#include <dulcificum/miracle_jtp/mgjtp_command_to_json.h>

#include <range/v3/view/transform.hpp>
#include <range/v3/view/join.hpp>

#include <fmt/format.h>
#include <fmt/ranges.h>

namespace dulcificum
{

[[nodiscard]] std::string GCode2Miracle_JTP(const std::string& content)
{
auto gcode_ast = dulcificum::gcode::parse(content);
auto command_list = dulcificum::gcode::toCommand(gcode_ast);
auto json_commands = nlohmann::json::array();
for (const auto& command : command_list)
{
json_commands.emplace_back(dulcificum::miracle_jtp::toJson(*command));
}
return json_commands.dump();
auto commands = command_list
| ranges::views::transform([](const auto& command)
{
return dulcificum::miracle_jtp::toJson(*command).dump();
})
| ranges::views::join(",\n");
return fmt::format("[\n{}\n]", commands);
}


Expand Down

0 comments on commit ad56e31

Please sign in to comment.