10 #define PARAMETER_HPP_
16 #include <boost/config/warning_disable.hpp>
17 #include <boost/spirit/include/qi.hpp>
18 #include <boost/fusion/include/adapt_struct.hpp>
19 #include <boost/optional.hpp>
23 #define BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
24 #define BOOST_SPIRIT_QI_DEBUG
42 boost::optional<ast::datatype>
type_m;
51 template <attributes A>
56 std::string attributeString;
60 attributeString =
"symbol";
63 attributeString =
"format_string";
66 attributeString =
"fixed_value";
71 std::cerr << attributeString <<
" not supported yet" <<
std::endl;
76 template <
typename Iterator,
typename Skipper>
80 , Skipper
const& skipper)
85 boost::spirit::qi::float_type float_;
86 return phrase_parse(first, last, float_, skipper, this->
value_m);
90 boost::spirit::qi::double_type double_;
91 return phrase_parse(first, last, double_, skipper, this->
value_m);
95 boost::spirit::qi::short_type short_;
96 return phrase_parse(first, last, short_, skipper, this->
value_m);
100 boost::spirit::qi::long_type long_;
101 return phrase_parse(first, last, long_, skipper, this->
value_m);
105 boost::spirit::qi::char_type char_;
106 return phrase_parse(first, last, char_, skipper, this->
value_m);
111 return phrase_parse(first, last,
string, skipper, this->
value_m);
120 template <
typename Iterator>
123 template <
typename,
typename>
133 if (param.
name_m) out <<
"name = " << *param.
name_m <<
", ";
134 if (param.
type_m) out <<
"type = " << *param.
type_m <<
", ";
137 out <<
"order = " << param.
order_m;
145 (boost::optional<std::string>, name_m)
146 (boost::optional<SDDS::ast::datatype>, type_m)
147 (boost::optional<std::string>, units_m)
148 (boost::optional<std::string>, description_m)
152 namespace SDDS {
namespace parser
154 namespace qi = boost::spirit::qi;
155 namespace ascii = boost::spirit::ascii;
156 namespace phx = boost::phoenix;
158 template <
typename Iterator>
159 struct parameter_parser: qi::grammar<Iterator, parameter(), skipper<Iterator> >
161 parameter_parser(error_handler<Iterator> & _error_handler);
163 qi::rule<Iterator, std::string(), skipper<Iterator> > string, quoted_string, units;
164 qi::rule<Iterator, std::string(), skipper<Iterator> > parameter_name, parameter_units,
165 parameter_description, parameter_symbol, parameter_format;
166 qi::rule<Iterator, ast::datatype(), skipper<Iterator> > parameter_type;
167 qi::rule<Iterator, long(), skipper<Iterator> > parameter_fixed;
168 qi::rule<Iterator, parameter(), skipper<Iterator> > start;
169 qi::rule<Iterator, ast::nil(), skipper<Iterator> > parameter_unsupported_pre,
170 parameter_unsupported_post;
171 qi::symbols<char, ast::datatype>
datatype;
boost::optional< ast::datatype > type_m
bool checkMandatories() const
boost::variant< float, double, short, long, char, std::string > variant_t
BOOST_FUSION_ADAPT_STRUCT(SDDS::column,(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
void operator()(parameter ¶m, Iterator) const
static unsigned int count_m
boost::optional< std::string > description_m
boost::optional< std::string > units_m
boost::optional< std::string > name_m
std::ostream & operator<<(std::ostream &out, const array &)
Inform & endl(Inform &inf)
bool parse(Iterator &first, Iterator last, Skipper const &skipper)