Bayeux  3.4.1
Core Foundation library for SuperNEMO
parsers.h
Go to the documentation of this file.
1 /* Author(s) : Francois Mauger <mauger@lpccaen.in2p3.fr>
3  * Creation date : 2016-10-26
4  * Last modified : 2017-01-12
5  *
6  * Copyright (C) 2016-2017 Francois Mauger <mauger@lpccaen.in2p3.fr>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or (at
11  * your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  *
23  * Description:
24  *
25  * Parsers for variant items.
26  *
27  */
28 
29 #ifndef DATATOOLS_CONFIGURATION_PARSERS_H
30 #define DATATOOLS_CONFIGURATION_PARSERS_H
31 
32 // Third party:
33 // - Boost:
34 #include <boost/spirit/include/qi.hpp>
35 #include <boost/spirit/include/qi_grammar.hpp>
36 
37 namespace datatools {
38 
39  namespace configuration {
40 
53  template <typename Iterator>
55  : boost::spirit::qi::grammar<Iterator, std::string()>
56  {
59  {
60  namespace qi = boost::spirit::qi;
61  // Rule definitions:
62  start %= ( qi::char_("a-zA-Z_") >> *qi::char_("a-zA-Z_0-9"));
63  return;
64  }
65 
66  // Rules:
67  boost::spirit::qi::rule<Iterator, std::string()> start;
68  };
69 
82  template <typename Iterator>
84  : boost::spirit::qi::grammar<Iterator, std::string()>
85  {
88  {
89  namespace qi = boost::spirit::qi;
90  // Rule definitions:
91  start %= ( qi::char_("a-zA-Z_") >> *qi::char_("a-zA-Z_0-9"));
92  return;
93  }
94 
95  // Rules:
96  boost::spirit::qi::rule<Iterator, std::string()> start;
97  };
98 
112  template <typename Iterator>
114  : boost::spirit::qi::grammar<Iterator, std::string()>
115  {
117  : param_name_instance_grammar::base_type(start)
118  {
119  namespace qi = boost::spirit::qi;
120  // Rule definitions:
121  start %= ( qi::char_("a-zA-Z_") >> *qi::char_("a-zA-Z0-9_"))
122  >> -( qi::char_('[') >> +qi::digit >> qi::char_(']') );
123  return;
124  }
125 
126  // Rules:
127  boost::spirit::qi::rule<Iterator, std::string()> start;
128  };
129 
144  template <typename Iterator>
146  : boost::spirit::qi::grammar<Iterator,
147  std::string()>
148  {
150  : group_name_instance_grammar::base_type(start)
151  {
152  namespace qi = boost::spirit::qi;
153  // Rule definitions:
154  // instance_name %= ( qi::char_("a-zA-Z_") >> *qi::char_("a-zA-Z_0-9"));
155  start %= (
156  subgrpg
157  >> *( qi::char_('/') >> subgrpg)
158  );
159  // start %= ( qi::char_("a-zA-Z_") >> *qi::char_("a-zA-Z_0-9"));
160  return;
161  }
162 
163  // Rules:
164  boost::spirit::qi::rule<Iterator, std::string()> start;
166  //boost::spirit::qi::rule<Iterator, std::string()> instance_name;
167  };
168 
182  template <typename Iterator>
184  : boost::spirit::qi::grammar<Iterator, std::string()>
185  {
188  {
189  namespace qi = boost::spirit::qi;
190  // Rule definitions:
191  start %= (
192  pnig
193  >> *( qi::char_('/') >> vnig >> qi::char_('/') >> pnig)
194  );
195  return;
196  }
197  // Rules:
198  boost::spirit::qi::rule<Iterator, std::string()> start;
201  };
202 
203 
217  template <typename Iterator>
219  : boost::spirit::qi::grammar<Iterator, std::string()>
220  {
223  {
224  namespace qi = boost::spirit::qi;
225  // Rule definitions:
226  start %= (
227  (pnig >> qi::char_('/') >> vnig)
228  >> *( qi::char_('/') >> pnig >> qi::char_('/') >> vnig)
229  );
230  return;
231  }
232 
233  // Rules:
234  boost::spirit::qi::rule<Iterator, std::string()> start;
237 
238  };
239 
254  template <typename Iterator>
256  : boost::spirit::qi::grammar<Iterator, std::string()>
257  {
260  {
261  namespace qi = boost::spirit::qi;
262  // Rule definitions:
263  start %= (rnig >> qi::char_(':') >> lppig);
264  return;
265  }
266  // Rules:
267  boost::spirit::qi::rule<Iterator, std::string()> start;
270  };
271 
289  template <typename Iterator>
291  : boost::spirit::qi::grammar<Iterator, std::string()>
292  {
295  {
296  namespace qi = boost::spirit::qi;
297  // Rule definitions:
298  start %= (rnig >> qi::char_(':') >> lvpig);
299  return;
300  }
301  // Rules:
302  boost::spirit::qi::rule<Iterator, std::string()> start;
305  };
306 
323  template <typename Iterator>
325  : boost::spirit::qi::grammar<Iterator, std::string()>
326  {
329  {
330  namespace qi = boost::spirit::qi;
331  // Rule definitions:
332  start %= (fppig >> qi::char_('@') >> gnig);
333  return;
334  }
335  // Rules:
336  boost::spirit::qi::rule<Iterator, std::string()> start;
339  };
340 
341 
354  template <typename Iterator>
356  : boost::spirit::qi::grammar<Iterator, std::string()>
357  {
360  {
361  namespace qi = boost::spirit::qi;
362  namespace bsa = boost::spirit::ascii;
363  // Rule definitions:
364  start %= ( +qi::char_ );
365  // // Rule definitions:
366  // start %= ( qi::char_("a-zA-Z_")
367  // | (
368  // qi::char_("a-zA-Z_")
369  // >> -(+qi::char_("a-zA-Z0-9_:.-/")
370  // >> qi::char_("a-zA-Z0-9_")
371  // )
372  // )
373  // );
374  return;
375  }
376 
377  // Rules:
378  boost::spirit::qi::rule<Iterator, std::string()> start;
379  };
380 
397  template <typename Iterator>
399  : boost::spirit::qi::grammar<Iterator, std::string()>
400  {
403  {
404  namespace qi = boost::spirit::qi;
405  // Rule definitions:
406  start %= (fppig >> qi::char_('=') >> esvrig);
407  return;
408  }
409  // Rules:
410  boost::spirit::qi::rule<Iterator, std::string()> start;
413  };
414 
415  } // end of namespace configuration
416 
417 } // end of namespace datatools
418 
419 #endif // DATATOOLS_CONFIGURATION_PARSERS_H
420 
421 // Local Variables: --
422 // mode: c++ --
423 // c-file-style: "gnu" --
424 // tab-width: 2 --
425 // End: --
Parser for a full variant parameter value path.
Definition: parsers.h:398
boost::spirit::qi::rule< Iterator, std::string()> start
Definition: parsers.h:378
full_param_path_instance_grammar< Iterator > fppig
Definition: parsers.h:337
Parser for a local variant parameter path.
Definition: parsers.h:183
boost::spirit::qi::rule< Iterator, std::string()> start
Definition: parsers.h:302
registry_name_instance_grammar< Iterator > rnig
Definition: parsers.h:303
enumerated_string_value_repr_instance_grammar< Iterator > esvrig
Definition: parsers.h:412
boost::spirit::qi::rule< Iterator, std::string()> start
Definition: parsers.h:164
full_param_path_instance_grammar< Iterator > fppig
Definition: parsers.h:411
boost::spirit::qi::rule< Iterator, std::string()> start
Definition: parsers.h:410
boost::spirit::qi::rule< Iterator, std::string()> start
Definition: parsers.h:67
registry_name_instance_grammar< Iterator > rnig
Definition: parsers.h:268
param_name_instance_grammar< Iterator > pnig
Definition: parsers.h:199
Parser for a full variant parameter value group path.
Definition: parsers.h:324
local_variant_path_instance_grammar< Iterator > lvpig
Definition: parsers.h:304
Parser for a local variant path.
Definition: parsers.h:218
boost::spirit::qi::rule< Iterator, std::string()> start
Definition: parsers.h:267
boost::spirit::qi::rule< Iterator, std::string()> start
Definition: parsers.h:234
variant_name_instance_grammar< Iterator > subgrpg
Definition: parsers.h:165
boost::spirit::qi::rule< Iterator, std::string()> start
Definition: parsers.h:127
Parser for a enumerated string value representation.
Definition: parsers.h:355
variant_name_instance_grammar< Iterator > vnig
Definition: parsers.h:236
boost::spirit::qi::rule< Iterator, std::string()> start
Definition: parsers.h:96
Parser for a variant name.
Definition: parsers.h:83
group_name_instance_grammar< Iterator > gnig
Definition: parsers.h:338
param_name_instance_grammar< Iterator > pnig
Definition: parsers.h:235
boost::spirit::qi::rule< Iterator, std::string()> start
Definition: parsers.h:198
Parser for a variant parameter name.
Definition: parsers.h:113
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13
variant_name_instance_grammar< Iterator > vnig
Definition: parsers.h:200
Parser for a full variant parameter path.
Definition: parsers.h:255
Parser for a registry name.
Definition: parsers.h:54
Parser for a variant parameter group name.
Definition: parsers.h:145
Parser for a full variant path.
Definition: parsers.h:290
boost::spirit::qi::rule< Iterator, std::string()> start
Definition: parsers.h:336
local_param_path_instance_grammar< Iterator > lppig
Definition: parsers.h:269