My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Functions
cppvalue.h File Reference
#include <stdio.h>
#include <qglobal.h>

Go to the source code of this file.

Classes

class  CPPValue
 

Functions

CPPValue parseOctal ()
 
CPPValue parseDecimal ()
 
CPPValue parseHexadecimal ()
 
CPPValue parseCharacter ()
 
CPPValue parseFloat ()
 

Function Documentation

CPPValue parseCharacter ( )

Definition at line 57 of file cppvalue.cpp.

References g_strToken, parseHexadecimal(), and parseOctal().

{
if (g_strToken[1]=='\\')
{
switch(g_strToken[2])
{
case 'n': return CPPValue((long)'\n');
case 't': return CPPValue((long)'\t');
case 'v': return CPPValue((long)'\v');
case 'b': return CPPValue((long)'\b');
case 'r': return CPPValue((long)'\r');
case 'f': return CPPValue((long)'\f');
case 'a': return CPPValue((long)'\a');
case '\\': return CPPValue((long)'\\');
case '?': return CPPValue((long)'\?');
case '\'': return CPPValue((long)'\'');
case '"': return CPPValue((long)'"');
case '0': // fall through
case '1': // fall through
case '2': // fall through
case '3': // fall through
case '4': // fall through
case '5': // fall through
case '6': // fall through
case '7': // fall through
return parseOctal();
case 'x':
case 'X': return parseHexadecimal();
default: printf("Invalid escape sequence %s found!\n",g_strToken.data());
return CPPValue(0L);
}
}
return CPPValue((long)g_strToken[1]);
}
CPPValue parseDecimal ( )

Definition at line 34 of file cppvalue.cpp.

References g_strToken.

{
long val = 0;
for (const char *p = g_strToken.data(); *p != 0; p++)
{
if (*p >= '0' && *p <= '9') val = val * 10 + *p - '0';
}
return CPPValue(val);
}
CPPValue parseFloat ( )

Definition at line 92 of file cppvalue.cpp.

References g_strToken.

{
return CPPValue(atof(g_strToken));
}
CPPValue parseHexadecimal ( )

Definition at line 44 of file cppvalue.cpp.

References g_strToken.

Referenced by parseCharacter().

{
long val = 0;
for (const char *p = g_strToken.data(); *p != 0; p++)
{
if (*p >= '0' && *p <= '9') val = val * 16 + *p - '0';
else if (*p >= 'a' && *p <= 'f') val = val * 16 + *p - 'a' + 10;
else if (*p >= 'A' && *p <= 'F') val = val * 16 + *p - 'A' + 10;
}
//printf("parseHexadecimal %s->%x\n",g_strToken.data(),val);
return CPPValue(val);
}
CPPValue parseOctal ( )

Definition at line 24 of file cppvalue.cpp.

References g_strToken.

Referenced by parseCharacter().

{
long val = 0;
for (const char *p = g_strToken.data(); *p != 0; p++)
{
if (*p >= '0' && *p <= '7') val = val * 8 + *p - '0';
}
return CPPValue(val);
}