Loading...
Searching...
No Matches
AddressParser.hpp
1#pragma once
2#include <State/Address.hpp>
3#include <State/Relation.hpp>
4#include <State/ValueParser.hpp>
5BOOST_FUSION_ADAPT_STRUCT(State::Address, (QString, device)(QStringList, path))
6
7BOOST_FUSION_ADAPT_STRUCT(
8 ossia::destination_qualifiers,
9 (ossia::destination_index, accessors)(ossia::unit_t, unit))
10
11BOOST_FUSION_ADAPT_STRUCT(
13 (State::Address, address)(ossia::destination_qualifiers, qualifiers))
14BOOST_FUSION_ADAPT_STRUCT(State::Pulse, (State::Address, address))
15
16namespace
17{
19namespace qi = boost::spirit::qi;
20
21using boost::spirit::qi::rule;
22
23template <typename Iterator>
24struct Address_parser : qi::grammar<Iterator, State::Address()>
25{
26 Address_parser()
27 : Address_parser::base_type(start)
28 {
29 using qi::alnum;
30 // OPTIMIZEME
31 dev = +qi::char_(std::string(ossia::net::device_characters()));
32 member_elt = +qi::char_(std::string(ossia::net::pattern_match_characters()));
33 path %= (+("/" >> member_elt) | "/");
34 start %= -dev >> ":" >> path;
35 }
36
37 qi::rule<Iterator, QString()> dev;
38 qi::rule<Iterator, QString()> member_elt;
39 qi::rule<Iterator, QStringList()> path;
40 qi::rule<Iterator, State::Address()> start;
41};
42
43template <typename Iterator>
44struct AccessorList_parser : qi::grammar<Iterator, ossia::destination_index()>
45{
46 AccessorList_parser()
47 : AccessorList_parser::base_type(start)
48 {
49 using boost::spirit::int_;
50 using boost::spirit::qi::skip;
51 using boost::spirit::standard::space;
52 using qi::alnum;
53
54 index %= skip(space)["[" >> int_ >> "]"];
55 start %= skip(space)[+(index)];
56 }
57
58 qi::rule<Iterator, ossia::destination_index()> start;
59 qi::rule<Iterator, uint8_t()> index;
60};
61
62template <typename Iterator>
63struct AddressQualifiers_parser : qi::grammar<Iterator, ossia::destination_qualifiers()>
64{
65 AddressQualifiers_parser()
66 : AddressQualifiers_parser::base_type(start)
67 {
68 using boost::spirit::int_;
69 using boost::spirit::qi::skip;
70 using boost::spirit::standard::space;
71 using qi::alnum;
72
73 unit %= boost::spirit::eoi;
74 start %= "@" >> ((accessors >> -unit) | ("[" >> ossia::get_unit_parser() >> "]"));
75 }
76
77 qi::rule<Iterator, ossia::destination_qualifiers()> start;
78 AccessorList_parser<Iterator> accessors;
79 qi::rule<Iterator, ossia::unit_t()> unit;
80};
81
82template <typename Iterator>
83struct AddressAccessor_parser : qi::grammar<Iterator, State::AddressAccessor()>
84{
85 AddressAccessor_parser()
86 : AddressAccessor_parser::base_type(start)
87 {
88 using boost::spirit::int_;
89 using boost::spirit::qi::skip;
90 using boost::spirit::standard::space;
91 using qi::alnum;
92
93 start %= skip(space)[address >> qualifiers];
94 }
95
96 qi::rule<Iterator, State::AddressAccessor()> start;
97 Address_parser<Iterator> address;
98 AddressQualifiers_parser<Iterator> qualifiers;
99};
100}
Definition lv2_atom_helpers.hpp:99
Definition Address.hpp:108
The Address struct.
Definition Address.hpp:58
Definition Relation.hpp:71