#include <ctype.h>
#include <string.h>
#include "TFNameConvert.h"
ClassImp(TFNameConvert)
TFNameConvert::TFNameConvert()
{
fFrom = NULL;
fResult = NULL;
SetCaseMode(kNoChange);
SetCharConversion(NULL, ' ');
}
TFNameConvert::TFNameConvert(TFUpLow upLow, const char * from, char to)
{
fFrom = NULL;
fResult = NULL;
SetCaseMode(upLow);
SetCharConversion(from, to);
}
TFNameConvert::TFNameConvert(const char * from, char to)
{
fFrom = NULL;
fResult = NULL;
SetCaseMode(kNoChange);
SetCharConversion(from, to);
}
TFNameConvert::~TFNameConvert()
{
delete [] fFrom;
delete [] fResult;
}
const char * TFNameConvert::Conv(const char * name)
{
if (fFrom == NULL && fUpLow == kNoChange)
return name;
delete [] fResult;
fResult = new char [strlen(name) + 1];
int index = 0;
while (*name)
{
if (fUpLow == kToLower)
fResult[index] = tolower(*name);
else if (fUpLow == kToUpper)
fResult[index] = toupper(*name);
else
fResult[index] = *name;
if (fFrom && strchr(fFrom, fResult[index]) )
fResult[index] = fTo;
name++;
index++;
}
fResult[index] = 0;
return fResult;
}
void TFNameConvert::SetCharConversion(const char * from, char to)
{
delete [] fFrom;
if (from == NULL)
{
fFrom = NULL;
fTo = ' ';
return;
}
fFrom = new char [strlen(from) + 1];
strcpy(fFrom, from);
fTo = to;
}
Last update: Fri Mar 14 13:55:22 2008
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.