26 enum Type { Int, Float };
28 explicit CPPValue(
char c) : type(Int) { v.l = c; }
29 explicit CPPValue(
long val=0) : type(Int) { v.l = val; }
30 explicit CPPValue(
double val) : type(Float) { v.d = val; }
32 operator double ()
const {
return type==Int ?
static_cast<double>(v.l) : v.d; }
33 operator long ()
const {
return type==Int ? v.l :
static_cast<long>(v.d); }
35 bool isInt()
const {
return type == Int; }
40 printf(
"(%ld)\n",v.l);
44 static CPPValue parseOctal(
const std::string& token);
45 static CPPValue parseDecimal(
const std::string& token);
46 static CPPValue parseHexadecimal(
const std::string& token);
47 static CPPValue parseBinary(
const std::string& token);
48 static CPPValue parseCharacter(
const std::string& token);
49 static CPPValue parseFloat(
const std::string& token);
A class representing a C-preprocessor value.
Definition: cppvalue.h:23