My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Private Attributes | List of all members
CPPValue Class Reference

#include <cppvalue.h>

Public Types

enum  Type { Int, Float }
 

Public Member Functions

 CPPValue (long val=0)
 
 CPPValue (double val)
 
 operator double () const
 
 operator long () const
 
bool isInt () const
 
void print () const
 

Private Attributes

Type type
 
union {
   double   d
 
   long   l
 
v
 

Detailed Description

A class representing a C-preprocessor value.

Definition at line 26 of file cppvalue.h.

Member Enumeration Documentation

Enumerator
Int 
Float 

Definition at line 29 of file cppvalue.h.

{ Int, Float };

Constructor & Destructor Documentation

CPPValue::CPPValue ( long  val = 0)
inline

Definition at line 31 of file cppvalue.h.

References v.

: type(Int) { v.l = val; }
CPPValue::CPPValue ( double  val)
inline

Definition at line 32 of file cppvalue.h.

References v.

: type(Float) { v.d = val; }

Member Function Documentation

bool CPPValue::isInt ( ) const
inline

Definition at line 37 of file cppvalue.h.

References Int, and type.

{ return type == Int; }
CPPValue::operator double ( ) const
inline

Definition at line 34 of file cppvalue.h.

References Int, type, and v.

{ return type==Int ? (double)v.l : v.d; }
CPPValue::operator long ( ) const
inline

Definition at line 35 of file cppvalue.h.

References Int, type, and v.

{ return type==Int ? v.l : (long)v.d; }
void CPPValue::print ( ) const
inline

Definition at line 39 of file cppvalue.h.

References Int, type, and v.

{
if (type==Int)
printf("(%ld)\n",v.l);
else
printf("(%f)\n",v.d);
}

Member Data Documentation

double CPPValue::d

Definition at line 50 of file cppvalue.h.

long CPPValue::l

Definition at line 51 of file cppvalue.h.

Type CPPValue::type
private

Definition at line 48 of file cppvalue.h.

Referenced by isInt(), operator double(), operator long(), and print().

union { ... } CPPValue::v

The documentation for this class was generated from the following file: