17 #ifndef PARAMETER_HPP_
18 #define PARAMETER_HPP_
24 #include <boost/config/warning_disable.hpp>
25 #include <boost/spirit/include/qi.hpp>
26 #include <boost/fusion/include/adapt_struct.hpp>
27 #include <boost/optional.hpp>
31 #define BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
32 #define BOOST_SPIRIT_QI_DEBUG
50 boost::optional<ast::datatype>
type_m;
59 template <attributes A>
64 std::string attributeString;
68 attributeString =
"symbol";
71 attributeString =
"format_string";
74 attributeString =
"fixed_value";
79 std::cerr << attributeString <<
" not supported yet" <<
std::endl;
84 template <
typename Iterator,
typename Skipper>
88 , Skipper
const& skipper)
90 switch(*this->type_m) {
93 boost::spirit::qi::float_type float_;
94 return phrase_parse(first, last, float_, skipper, this->value_m);
98 boost::spirit::qi::double_type double_;
99 return phrase_parse(first, last, double_, skipper, this->value_m);
103 boost::spirit::qi::short_type short_;
104 return phrase_parse(first, last, short_, skipper, this->value_m);
108 boost::spirit::qi::long_type long_;
109 return phrase_parse(first, last, long_, skipper, this->value_m);
113 boost::spirit::qi::char_type char_;
114 return phrase_parse(first, last, char_, skipper, this->value_m);
119 return phrase_parse(first, last,
string, skipper, this->value_m);
128 template <
typename Iterator>
131 template <
typename,
typename>
141 if (param.
name_m) out <<
"name = " << *param.
name_m <<
", ";
142 if (param.
type_m) out <<
"type = " << *param.
type_m <<
", ";
145 out <<
"order = " << param.
order_m;
153 (boost::optional<std::string>, name_m)
154 (boost::optional<SDDS::ast::datatype>, type_m)
155 (boost::optional<std::string>, units_m)
156 (boost::optional<std::string>, description_m)
160 namespace SDDS {
namespace parser
162 namespace qi = boost::spirit::qi;
163 namespace ascii = boost::spirit::ascii;
164 namespace phx = boost::phoenix;
166 template <
typename Iterator>
167 struct parameter_parser: qi::grammar<Iterator, parameter(), skipper<Iterator> >
169 parameter_parser(error_handler<Iterator> & _error_handler);
171 qi::rule<Iterator, std::string(), skipper<Iterator> > string, quoted_string, units;
172 qi::rule<Iterator, std::string(), skipper<Iterator> > parameter_name, parameter_units,
173 parameter_description, parameter_symbol, parameter_format;
174 qi::rule<Iterator,
ast::datatype(), skipper<Iterator> > parameter_type;
175 qi::rule<Iterator, long(), skipper<Iterator> > parameter_fixed;
176 qi::rule<Iterator, parameter(), skipper<Iterator> > start;
177 qi::rule<Iterator, ast::nil(), skipper<Iterator> > parameter_unsupported_pre,
178 parameter_unsupported_post;
179 qi::symbols<char, ast::datatype>
datatype;
Inform & endl(Inform &inf)
BOOST_FUSION_ADAPT_STRUCT(SDDS::parameter,(boost::optional< std::string >, name_m)(boost::optional< SDDS::ast::datatype >, type_m)(boost::optional< std::string >, units_m)(boost::optional< std::string >, description_m)(SDDS::ast::variant_t, value_m)) namespace SDDS
std::ostream & operator<<(std::ostream &out, const array &)
boost::variant< float, double, short, long, char, std::string > variant_t
boost::optional< std::string > name_m
boost::optional< ast::datatype > type_m
bool parse(Iterator &first, Iterator last, Skipper const &skipper)
boost::optional< std::string > units_m
boost::optional< std::string > description_m
static unsigned int count_m
bool checkMandatories() const
void operator()(parameter ¶m, Iterator) const