Orb/Doxygen/src/cppvalue.h
changeset 0 42188c7ea2d9
child 4 468f4c8d3d5b
equal deleted inserted replaced
-1:000000000000 0:42188c7ea2d9
       
     1 /******************************************************************************
       
     2  *
       
     3  * 
       
     4  *
       
     5  *
       
     6  * Copyright (C) 1997-2008 by Dimitri van Heesch.
       
     7  *
       
     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.
       
    13  *
       
    14  * Documents produced by Doxygen are derivative works derived from the
       
    15  * input used in their production; they are not affected by this license.
       
    16  *
       
    17  */
       
    18 
       
    19 #ifndef _CPPVALUE_H
       
    20 #define _CPPVALUE_H
       
    21 
       
    22 #include <stdio.h>
       
    23 #include <qglobal.h> 
       
    24 
       
    25 class CPPValue
       
    26 {
       
    27   public:
       
    28   
       
    29   
       
    30     enum Type { Int, Float };
       
    31   
       
    32     CPPValue(long val=0) : type(Int) { v.l = val; }
       
    33     CPPValue(double val) : type(Float) { v.d = val; }
       
    34 
       
    35     operator double () const { return type==Int ? (double)v.l : v.d; }
       
    36     operator long ()   const { return type==Int ? v.l : (long)v.d;   }
       
    37 
       
    38     bool isInt() const { return type == Int; }
       
    39      
       
    40     void print() const
       
    41     {
       
    42       if (type==Int) 
       
    43         printf("(%ld)\n",v.l);
       
    44       else
       
    45         printf("(%f)\n",v.d);
       
    46     }
       
    47 
       
    48   private:
       
    49     Type type;
       
    50     union {
       
    51       double d;
       
    52       long l;
       
    53     } v;
       
    54 };
       
    55 
       
    56 extern CPPValue parseOctal();
       
    57 extern CPPValue parseDecimal();
       
    58 extern CPPValue parseHexadecimal();
       
    59 extern CPPValue parseCharacter();
       
    60 extern CPPValue parseFloat();
       
    61 
       
    62 #endif