A class representing a C-preprocessor value.
More...
#include <src/cppvalue.h>
A class representing a C-preprocessor value.
Definition at line 23 of file cppvalue.h.
◆ Type
◆ CPPValue() [1/3]
CPPValue::CPPValue |
( |
char | c | ) |
|
|
inlineexplicit |
◆ CPPValue() [2/3]
CPPValue::CPPValue |
( |
long | val = 0 | ) |
|
|
inlineexplicit |
◆ CPPValue() [3/3]
CPPValue::CPPValue |
( |
double | val | ) |
|
|
inlineexplicit |
◆ isInt()
bool CPPValue::isInt |
( |
| ) |
const |
|
inline |
◆ operator double()
CPPValue::operator double |
( |
| ) |
const |
|
inline |
◆ operator long()
CPPValue::operator long |
( |
| ) |
const |
|
inline |
◆ parseBinary()
CPPValue CPPValue::parseBinary |
( |
const std::string & | token | ) |
|
|
static |
Definition at line 54 of file cppvalue.cpp.
55{
56 long val = 0;
57 for (const char *p = token.c_str(); *p != 0; p++)
58 {
59 if (*p >= '0' && *p <= '1') val = val * 2 + *p - '0';
60 }
62}
References CPPValue().
◆ parseCharacter()
CPPValue CPPValue::parseCharacter |
( |
const std::string & | token | ) |
|
|
static |
Definition at line 64 of file cppvalue.cpp.
65{
66 if (token[1]=='\\')
67 {
68 switch(token[2])
69 {
81 case '0':
82 case '1':
83 case '2':
84 case '3':
85 case '4':
86 case '5':
87 case '6':
88 case '7':
90 case 'x':
92 default: printf("Invalid escape sequence %s found!\n",token.c_str());
94 }
95 }
97}
static CPPValue parseOctal(const std::string &token)
static CPPValue parseHexadecimal(const std::string &token)
References CPPValue(), parseHexadecimal(), and parseOctal().
◆ parseDecimal()
CPPValue CPPValue::parseDecimal |
( |
const std::string & | token | ) |
|
|
static |
Definition at line 31 of file cppvalue.cpp.
32{
33 long val = 0;
34 for (const char *p = token.c_str(); *p != 0; p++)
35 {
36 if (*p >= '0' && *p <= '9') val = val * 10 + *p - '0';
37 }
39}
References CPPValue().
◆ parseFloat()
CPPValue CPPValue::parseFloat |
( |
const std::string & | token | ) |
|
|
static |
◆ parseHexadecimal()
CPPValue CPPValue::parseHexadecimal |
( |
const std::string & | token | ) |
|
|
static |
Definition at line 41 of file cppvalue.cpp.
42{
43 long val = 0;
44 for (const char *p = token.c_str(); *p != 0; p++)
45 {
46 if (*p >= '0' && *p <= '9') val = val * 16 + *p - '0';
47 else if (*p >= 'a' && *p <= 'f') val = val * 16 + *p - 'a' + 10;
48 else if (*p >= 'A' && *p <= 'F') val = val * 16 + *p - 'A' + 10;
49 }
50
52}
References CPPValue().
Referenced by parseCharacter().
◆ parseOctal()
CPPValue CPPValue::parseOctal |
( |
const std::string & | token | ) |
|
|
static |
Definition at line 21 of file cppvalue.cpp.
22{
23 long val = 0;
24 for (const char *p = token.c_str(); *p != 0; p++)
25 {
26 if (*p >= '0' && *p <= '7') val = val * 8 + *p - '0';
27 }
29}
References CPPValue().
Referenced by parseCharacter().
◆ print()
void CPPValue::print |
( |
| ) |
const |
|
inline |
Definition at line 37 of file cppvalue.h.
38 {
40 printf(
"(%ld)\n",
v.l);
41 else
43 }
References Int, type, and v.
◆ type
◆ [union]
union { ... } CPPValue::v |
The documentation for this class was generated from the following files: