fipa_acl  1.4
Classes | Public Types | Public Member Functions | List of all members
convertToNumberTokenImpl Struct Reference

#include <grammar_common.h>

Classes

struct  result
 

Public Types

typedef std::string result_type
 

Public Member Functions

template<typename T >
result_type operator() (T arg) const
 
std::string convert (char lowerbyte) const
 

Detailed Description

Convert byte to number according to the FIPA definition

Definition at line 254 of file grammar_common.h.

Member Typedef Documentation

Definition at line 256 of file grammar_common.h.

Member Function Documentation

std::string convertToNumberTokenImpl::convert ( char  lowerbyte) const
inline

Definition at line 283 of file grammar_common.h.

284  {
285  // make sure high order bytes are set to 0
286  lowerbyte &= 0x0F;
287 
288  // There will be more efficient ways to do that, but for clarity
289  switch(lowerbyte)
290  {
291  case 0x00: return "";
292  case 0x01: return "0";
293  case 0x02: return "1";
294  case 0x03: return "2";
295  case 0x04: return "3";
296  case 0x05: return "4";
297  case 0x06: return "5";
298  case 0x07: return "6";
299  case 0x08: return "7";
300  case 0x09: return "8";
301  case 0x0a: return "9";
302  case 0x0c: return "+";
303  case 0x0d: return "E";
304  case 0x0e: return "-";
305  case 0x0f: return ".";
306  default: return "";
307  }
308  }
template<typename T >
result_type convertToNumberTokenImpl::operator() ( arg) const
inline

Definition at line 265 of file grammar_common.h.

266  {
267 
268  // Each bytes contains two numbers:
269  // one in the highbytes and one in the lowerbytes
270  char highbytes = arg;
271  char lowerbytes = arg;
272 
273  // Shift to lowerbytes so that we can use the convert
274  // function here as well
275  highbytes >>= 4;
276 
277  std::string tmp = convert(highbytes);
278  tmp += convert(lowerbytes);
279 
280  return std::string(tmp);
281  }
std::string convert(char lowerbyte) const

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