summaryrefslogtreecommitdiff
path: root/src/cppvalue.h
diff options
context:
space:
mode:
authorAnas Nashif <anas.nashif@intel.com>2012-11-08 06:36:54 -0800
committerAnas Nashif <anas.nashif@intel.com>2012-11-08 06:36:54 -0800
commitcccf3a7c7888ce7bd7a8f8d48a34c5474ad9feeb (patch)
tree7f31b77ace4359e85dc3d3f66c853858c0bca7a4 /src/cppvalue.h
downloaddoxygen-cccf3a7c7888ce7bd7a8f8d48a34c5474ad9feeb.tar.gz
doxygen-cccf3a7c7888ce7bd7a8f8d48a34c5474ad9feeb.tar.bz2
doxygen-cccf3a7c7888ce7bd7a8f8d48a34c5474ad9feeb.zip
Imported Upstream version 1.8.2upstream/1.8.2
Diffstat (limited to 'src/cppvalue.h')
-rw-r--r--src/cppvalue.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/cppvalue.h b/src/cppvalue.h
new file mode 100644
index 0000000..f94d0a6
--- /dev/null
+++ b/src/cppvalue.h
@@ -0,0 +1,61 @@
+/******************************************************************************
+ *
+ * $Id: cppvalue.h,v 1.7 2001/03/19 19:27:40 root Exp $
+ *
+ *
+ * Copyright (C) 1997-2012 by Dimitri van Heesch.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation under the terms of the GNU General Public License is hereby
+ * granted. No representations are made about the suitability of this software
+ * for any purpose. It is provided "as is" without express or implied warranty.
+ * See the GNU General Public License for more details.
+ *
+ * Documents produced by Doxygen are derivative works derived from the
+ * input used in their production; they are not affected by this license.
+ *
+ */
+
+#ifndef _CPPVALUE_H
+#define _CPPVALUE_H
+
+#include <stdio.h>
+#include <qglobal.h>
+
+/** A class representing a C-preprocessor value. */
+class CPPValue
+{
+ public:
+ enum Type { Int, Float };
+
+ CPPValue(long val=0) : type(Int) { v.l = val; }
+ CPPValue(double val) : type(Float) { v.d = val; }
+
+ operator double () const { return type==Int ? (double)v.l : v.d; }
+ operator long () const { return type==Int ? v.l : (long)v.d; }
+
+ bool isInt() const { return type == Int; }
+
+ void print() const
+ {
+ if (type==Int)
+ printf("(%ld)\n",v.l);
+ else
+ printf("(%f)\n",v.d);
+ }
+
+ private:
+ Type type;
+ union {
+ double d;
+ long l;
+ } v;
+};
+
+extern CPPValue parseOctal();
+extern CPPValue parseDecimal();
+extern CPPValue parseHexadecimal();
+extern CPPValue parseCharacter();
+extern CPPValue parseFloat();
+
+#endif