lib/antlr/src/String.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
#include "antlr/String.hpp"
00009
00010
#include <cctype>
00011
00012
#ifdef HAS_NOT_CSTDIO_H
00013
#include <stdio.h>
00014
#else
00015
#include <cstdio>
00016
#endif
00017
00018
#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
00019
namespace antlr {
00020
#endif
00021
ANTLR_C_USING(sprintf)
00022
00023 ANTLR_USE_NAMESPACE(std)string operator+( const ANTLR_USE_NAMESPACE(std)string& lhs, const
int rhs )
00024 {
00025
char tmp[100];
00026 sprintf(tmp,
"%d",rhs);
00027
return lhs+tmp;
00028 }
00029
00032 ANTLR_USE_NAMESPACE(std)string charName(
int ch)
00033 {
00034
if (ch == EOF)
00035
return "EOF";
00036
else
00037 {
00038
ANTLR_USE_NAMESPACE(std)string s;
00039
00040
#ifdef ANTLR_CCTYPE_NEEDS_STD
00041
if(
ANTLR_USE_NAMESPACE(std)isprint( ch ) )
00042
#else
00043
if( isprint( ch ) )
00044
#endif
00045
{
00046 s.append(
"'");
00047 s += ch;
00048 s.append(
"'");
00049
00050 }
00051
else
00052 {
00053 s +=
"0x";
00054
00055
unsigned int t = ch >> 4;
00056
if( t < 10 )
00057 s += t | 0x30;
00058
else
00059 s += t + 0x37;
00060 t = ch & 0xF;
00061
if( t < 10 )
00062 s += t | 0x30;
00063
else
00064 s += t + 0x37;
00065 }
00066
return s;
00067 }
00068 }
00069
00070
#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
00071
}
00072
#endif
00073
This file is part of the documentation for KDevelop Version 3.0.4.