LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
fhicl::hex_parser Struct Reference

#include "tokens.h"

Inheritance diagram for fhicl::hex_parser:

Classes

struct  attribute
 

Public Member Functions

template<typename Iterator , typename Context , typename Skipper , typename Attribute >
bool parse (Iterator &first, Iterator const &last, Context &, Skipper const &skipper, Attribute &attr) const
 
template<typename Context >
boost::spirit::info what (Context &) const
 

Detailed Description

Definition at line 208 of file tokens.h.

Member Function Documentation

template<typename Iterator , typename Context , typename Skipper , typename Attribute >
bool fhicl::hex_parser::parse ( Iterator &  first,
Iterator const &  last,
Context &  ,
Skipper const &  skipper,
Attribute &  attr 
) const
inline

Definition at line 221 of file tokens.h.

References fhicl::maximally_munched_number().

226  {
227  boost::spirit::qi::skip_over(first, last, skipper);
228 
229  static std::string const allowed{"0123456789abcdefABCDEF"};
230  Iterator it = first;
231 
232  if (it == last || *it != '0')
233  return false;
234 
235  ++it;
236 
237  if (it == last || toupper(*it) != 'X')
238  return false;
239 
240  ++it;
241 
242  while (it != last && allowed.find(*it) != std::string::npos)
243  ++it;
244 
245  if (it != last && !maximally_munched_number(*it))
246  return false;
247 
248  Attribute raw(first, it);
249  if (raw.empty() || raw.size() == 2)
250  return false;
251 
252  Attribute result;
253  if (!cet::canonical_number(raw, result))
254  return false;
255 
256  first = it;
257  boost::spirit::traits::assign_to(result, attr);
258  return true;
259  }
Raw data description.
Definition: RawTypes.h:6
bool maximally_munched_number(char const ch)
Definition: tokens.h:35
template<typename Context >
boost::spirit::info fhicl::hex_parser::what ( Context &  ) const
inline

Definition at line 264 of file tokens.h.

265  {
266  return boost::spirit::info{"fhicl::hex"};
267  }

The documentation for this struct was generated from the following file: