1 /******************************************************************************
3 * $Id: cppvalue.h,v 1.7 2001/03/19 19:27:40 root Exp $
6 * Copyright (C) 1997-2012 by Dimitri van Heesch.
8 * Permission to use, copy, modify, and distribute this software and its
9 * documentation under the terms of the GNU General Public License is hereby
10 * granted. No representations are made about the suitability of this software
11 * for any purpose. It is provided "as is" without express or implied warranty.
12 * See the GNU General Public License for more details.
14 * Documents produced by Doxygen are derivative works derived from the
15 * input used in their production; they are not affected by this license.
25 /** A class representing a C-preprocessor value. */
29 enum Type { Int, Float };
31 CPPValue(long val=0) : type(Int) { v.l = val; }
32 CPPValue(double val) : type(Float) { v.d = val; }
34 operator double () const { return type==Int ? (double)v.l : v.d; }
35 operator long () const { return type==Int ? v.l : (long)v.d; }
37 bool isInt() const { return type == Int; }
42 printf("(%ld)\n",v.l);
55 extern CPPValue parseOctal();
56 extern CPPValue parseDecimal();
57 extern CPPValue parseHexadecimal();
58 extern CPPValue parseCharacter();
59 extern CPPValue parseFloat();