Skip to content

Commit

Permalink
Removed dependency on boost.spirit
Browse files Browse the repository at this point in the history
This reduces compile time slightly.
  • Loading branch information
KazDragon committed Jan 7, 2024
1 parent ac86f02 commit 5388bc9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
1 change: 0 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ install:
- vcpkg install boost-container-hash:%platform%-windows
- vcpkg install boost-core:%platform%-windows
- vcpkg install boost-range:%platform%-windows
- vcpkg install boost-spirit:%platform%-windows
- vcpkg install gsl-lite:%platform%-windows
- vcpkg install fmt:%platform%-windows
- vcpkg install gtest:%platform%-windows
Expand Down
21 changes: 16 additions & 5 deletions src/control_sequence.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "terminalpp/control_sequence.hpp"
#include <boost/spirit/home/karma.hpp>
#include <boost/range/adaptor/indexed.hpp>
#include <boost/range/algorithm/copy.hpp>
#include <algorithm>
#include <iostream>
#include <numeric>

Expand Down Expand Up @@ -75,10 +77,19 @@ static void output_arguments(
{
output_comma(out, comma);

boost::spirit::karma::generate(
std::ostream_iterator<char>(out),
"args:\"" << boost::spirit::karma::string % ';' << "\"",
arguments);
out << R"(args:")";

for (auto const &[index, value] : arguments | boost::adaptors::indexed())
{
if (index != 0)
{
out << ";";
}

boost::range::copy(value, std::ostream_iterator<char>(out));
}

out << R"(")";
}
}

Expand Down
12 changes: 5 additions & 7 deletions test/control_sequence_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static control_sequence_test_data const control_sequence_strings[] = {
default_sequence.command,
default_sequence.meta,
{"arg0"_tb}},
"control_sequence[args:\"arg0\"]"},
R"(control_sequence[args:"arg0"])"},

// A control sequence with multiple arguments outputs the arguments
// separated by ;
Expand All @@ -85,14 +85,14 @@ static control_sequence_test_data const control_sequence_strings[] = {
default_sequence.command,
default_sequence.meta,
{"arg0"_tb, "arg1"_tb}},
"control_sequence[args:\"arg0;arg1\"]"},
R"(control_sequence[args:"arg0;arg1"])"},
control_sequence_test_data{
terminalpp::control_sequence{
default_sequence.initiator,
default_sequence.command,
default_sequence.meta,
{"arg0"_tb, "arg1"_tb, "arg2"_tb}},
"control_sequence[args:\"arg0;arg1;arg2\"]"},
R"(control_sequence[args:"arg0;arg1;arg2"])"},

// control sequences with only an extender output only the extender
control_sequence_test_data{
Expand All @@ -115,14 +115,12 @@ static control_sequence_test_data const control_sequence_strings[] = {
// Control sequences with multiple active fields separate them with commas
control_sequence_test_data{
terminalpp::control_sequence{'[', 'H', true, {"29"_tb}, '?'},
"control_sequence[initiator:'[', command:'H', meta, args:\"29\", "
"extender:'?']"},
R"(control_sequence[initiator:'[', command:'H', meta, args:"29", extender:'?'])"},

control_sequence_test_data{
terminalpp::control_sequence{
'[', 'H', default_sequence.meta, {"29"_tb}, '?'},
"control_sequence[initiator:'[', command:'H', args:\"29\", "
"extender:'?']"},
R"(control_sequence[initiator:'[', command:'H', args:"29", extender:'?'])"},

};

Expand Down

0 comments on commit 5388bc9

Please sign in to comment.