Classes | Functions
cppvalue.h File Reference
#include <stdio.h>
#include <qglobal.h>

Go to the source code of this file.

Classes

class  CPPValue
 

Functions

CPPValue parseOctal ()
 
CPPValue parseDecimal ()
 
CPPValue parseHexadecimal ()
 
CPPValue parseCharacter ()
 
CPPValue parseFloat ()
 

Function Documentation

CPPValue parseCharacter ( )

Definition at line 57 of file cppvalue.cpp.

58 {
59  if (g_strToken[1]=='\\')
60  {
61  switch(g_strToken[2])
62  {
63  case 'n': return CPPValue((long)'\n');
64  case 't': return CPPValue((long)'\t');
65  case 'v': return CPPValue((long)'\v');
66  case 'b': return CPPValue((long)'\b');
67  case 'r': return CPPValue((long)'\r');
68  case 'f': return CPPValue((long)'\f');
69  case 'a': return CPPValue((long)'\a');
70  case '\\': return CPPValue((long)'\\');
71  case '?': return CPPValue((long)'\?');
72  case '\'': return CPPValue((long)'\'');
73  case '"': return CPPValue((long)'"');
74  case '0': // fall through
75  case '1': // fall through
76  case '2': // fall through
77  case '3': // fall through
78  case '4': // fall through
79  case '5': // fall through
80  case '6': // fall through
81  case '7': // fall through
82  return parseOctal();
83  case 'x':
84  case 'X': return parseHexadecimal();
85  default: printf("Invalid escape sequence %s found!\n",g_strToken.data());
86  return CPPValue(0L);
87  }
88  }
89  return CPPValue((long)g_strToken[1]);
90 }
QCString g_strToken
Definition: constexp.cpp:561
CPPValue parseOctal()
Definition: cppvalue.cpp:24
const char * data() const
Definition: qcstring.h:207
CPPValue parseHexadecimal()
Definition: cppvalue.cpp:44
CPPValue parseDecimal ( )

Definition at line 34 of file cppvalue.cpp.

35 {
36  long val = 0;
37  for (const char *p = g_strToken.data(); *p != 0; p++)
38  {
39  if (*p >= '0' && *p <= '9') val = val * 10 + *p - '0';
40  }
41  return CPPValue(val);
42 }
QCString g_strToken
Definition: constexp.cpp:561
p
Definition: test.py:223
const char * data() const
Definition: qcstring.h:207
CPPValue parseFloat ( )

Definition at line 92 of file cppvalue.cpp.

93 {
94  return CPPValue(atof(g_strToken));
95 }
QCString g_strToken
Definition: constexp.cpp:561
CPPValue parseHexadecimal ( )

Definition at line 44 of file cppvalue.cpp.

45 {
46  long val = 0;
47  for (const char *p = g_strToken.data(); *p != 0; p++)
48  {
49  if (*p >= '0' && *p <= '9') val = val * 16 + *p - '0';
50  else if (*p >= 'a' && *p <= 'f') val = val * 16 + *p - 'a' + 10;
51  else if (*p >= 'A' && *p <= 'F') val = val * 16 + *p - 'A' + 10;
52  }
53  //printf("parseHexadecimal %s->%x\n",g_strToken.data(),val);
54  return CPPValue(val);
55 }
QCString g_strToken
Definition: constexp.cpp:561
p
Definition: test.py:223
const char * data() const
Definition: qcstring.h:207
CPPValue parseOctal ( )

Definition at line 24 of file cppvalue.cpp.

25 {
26  long val = 0;
27  for (const char *p = g_strToken.data(); *p != 0; p++)
28  {
29  if (*p >= '0' && *p <= '7') val = val * 8 + *p - '0';
30  }
31  return CPPValue(val);
32 }
QCString g_strToken
Definition: constexp.cpp:561
p
Definition: test.py:223
const char * data() const
Definition: qcstring.h:207