6 #if defined(_GLIBCXX_DEBUG)
7 #define BOOST_PHOENIX_USING_LIBCPP
9 #include <ossia/network/base/name_validation.hpp>
10 #include <ossia/network/value/value.hpp>
12 #include <boost/fusion/adapted.hpp>
13 #include <boost/fusion/adapted/std_array.hpp>
14 #include <boost/spirit/home/x3.hpp>
16 BOOST_FUSION_ADAPT_STRUCT(ossia::impulse)
17 namespace ossia::detail::parse
19 using namespace boost::fusion;
20 namespace x3 = boost::spirit::x3;
24 using x3::real_parser;
27 struct BoolParse_map : x3::symbols<bool>
31 add(
"bool: true",
true)(
"bool: false",
false)(
"bool: 1",
true)(
"bool: 0",
false);
35 const x3::rule<class value_, ossia::value> value_ =
"value";
36 const x3::rule<class o_impulse_, ossia::impulse> o_impulse_ =
"impulse";
37 const x3::rule<class o_str_, std::string> o_str_ =
"str";
38 const x3::rule<class o_vec2_, std::array<float, 2>> o_vec2_ =
"vec2";
39 const x3::rule<class o_vec3_, std::array<float, 3>> o_vec3_ =
"vec3";
40 const x3::rule<class o_vec4_, std::array<float, 4>> o_vec4_ =
"vec4";
41 const x3::rule<class o_list_, std::vector<ossia::value>> o_list_ =
"list";
43 struct EscapedChar : x3::symbols<const char>
45 EscapedChar() { add(
"\\\"",
'\"'); }
47 using float_p = real_parser<float, x3::real_policies<float>>;
49 const auto o_impulse__def = x3::lit(
"impulse")[([](
auto&) {
return ossia::impulse{}; })];
51 =
"string: \"" >> (x3::lexeme[*(EscapedChar() | (char_ -
'"'))]) >>
'"';
52 const auto o_vec2__def =
"vec2f: [" >> float_p() >>
"," >> float_p() >>
"]";
53 const auto o_vec3__def
54 =
"vec3f: [" >> float_p() >>
"," >> float_p() >>
"," >> float_p() >>
"]";
55 const auto o_vec4__def =
"vec4f: [" >> float_p() >>
"," >> float_p() >>
"," >> float_p()
56 >>
"," >> float_p() >>
"]";
57 const auto o_list__def =
"list: [" >> *(value_ % x3::lit(
",")) >>
"]";
59 BOOST_SPIRIT_DEFINE(o_impulse_)
60 BOOST_SPIRIT_DEFINE(o_str_)
61 BOOST_SPIRIT_DEFINE(o_vec2_)
62 BOOST_SPIRIT_DEFINE(o_vec3_)
63 BOOST_SPIRIT_DEFINE(o_vec4_)
64 BOOST_SPIRIT_DEFINE(o_list_)
66 const auto value__def = (
"float: " >> float_p()) | (
"char: '" >> (char_ -
"'") >>
"'")
67 | (
"int: " >> int_) | BoolParse_map{} | o_impulse_ | o_str_
68 | o_vec2_ | o_vec3_ | o_vec4_ | o_list_;
70 BOOST_SPIRIT_DEFINE(value_)
72 const x3::rule<class address_, std::string> address_ =
"address";
73 const auto address__def = x3::lexeme[(
74 +(
"/" >> +x3::char_(std::string{ossia::net::name_characters()})) |
"/")];
75 BOOST_SPIRIT_DEFINE(address_)
77 const x3::rule<class preset_pair_, std::pair<std::string, ossia::value>> preset_pair_
79 const auto preset_pair__def
80 = x3::lexeme[+x3::char_(std::string{ossia::net::path_characters()}) >> x3::lit(
"\t")]
82 BOOST_SPIRIT_DEFINE(preset_pair_)
84 const x3::rule<class preset_, std::vector<std::pair<std::string, ossia::value>>> preset_
86 const auto preset__def = *(preset_pair_ % x3::lexeme[x3::eol]);
87 BOOST_SPIRIT_DEFINE(preset_)