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 =
"field_length";
79 std::cerr << attributeString <<
" not supported yet" <<
std::endl;
84 template <
typename Iterator,
typename Skipper>
88 , Skipper
const& skipper)
90 switch(*this->type_m) {
94 boost::spirit::qi::float_type float_;
95 if (phrase_parse(first, last, float_, skipper, f)) {
96 this->values_m.push_back(f);
104 boost::spirit::qi::double_type double_;
105 if (phrase_parse(first, last, double_, skipper, d)) {
106 this->values_m.push_back(d);
114 boost::spirit::qi::short_type short_;
115 if (phrase_parse(first, last, short_, skipper, s)) {
116 this->values_m.push_back(s);
124 boost::spirit::qi::long_type long_;
125 if (phrase_parse(first, last, long_, skipper, l)) {
126 this->values_m.push_back(l);
134 boost::spirit::qi::char_type char_;
135 if (phrase_parse(first, last, char_, skipper,
c)) {
136 this->values_m.push_back(
c);
145 if (phrase_parse(first, last, qstring, skipper, s)) {
146 this->values_m.push_back(s);
158 template <
typename Iterator>
161 template <
typename,
typename>
171 if (col.
name_m) out <<
"name = " << *col.
name_m <<
", ";
172 if (col.
type_m) out <<
"type = " << *col.
type_m <<
", ";
175 out <<
"order = " << col.
order_m;
183 (boost::optional<std::string>, name_m)
184 (boost::optional<SDDS::ast::datatype>, type_m)
185 (boost::optional<std::string>, units_m)
186 (boost::optional<std::string>, description_m)
190namespace SDDS {
namespace parser
192 namespace qi = boost::spirit::qi;
193 namespace ascii = boost::spirit::ascii;
194 namespace phx = boost::phoenix;
199 template <
typename Iterator>
200 struct column_parser: qi::grammar<Iterator, column(), skipper<Iterator> >
202 column_parser(error_handler<Iterator> & _error_handler);
204 qi::rule<Iterator, std::string(), skipper<Iterator> > string, quoted_string, units;
205 qi::rule<Iterator, std::string(), skipper<Iterator> > column_name, column_units,
206 column_description, column_symbol, column_format;
207 qi::rule<Iterator,
ast::datatype(), skipper<Iterator> > column_type;
208 qi::rule<Iterator, column(), skipper<Iterator> > start;
209 qi::rule<Iterator, long(), skipper<Iterator> > column_field;
210 qi::rule<Iterator, ast::nil(), skipper<Iterator> > column_unsupported_pre,
211 column_unsupported_post;
212 qi::symbols<char, ast::datatype>
datatype;
Inform & endl(Inform &inf)
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
constexpr double c
The velocity of light in m/s.
std::ostream & operator<<(std::ostream &out, const array &)
std::vector< variant_t > columnData_t
boost::variant< float, double, short, long, char, std::string > variant_t
boost::optional< std::string > name_m
boost::optional< std::string > units_m
boost::optional< ast::datatype > type_m
ast::columnData_t values_m
bool checkMandatories() const
bool parse(Iterator &first, Iterator last, Skipper const &skipper)
boost::optional< std::string > description_m
static unsigned int count_m
void operator()(column &col, Iterator) const