CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/L1Trigger/GlobalMuonTrigger/src/L1MuGMTLUTHelpers.cc

Go to the documentation of this file.
00001 //-------------------------------------------------
00002 //
00003 //   Class: L1MuGMTLUTHelpers
00008 //
00009 //   $Date: 2007/03/23 18:51:35 $
00010 //   $Revision: 1.2 $
00011 //
00012 //   Author :
00013 //   H. Sakulin            HEPHY Vienna
00014 //
00015 //   Migrated to CMSSW:
00016 //   I. Mikulec
00017 //
00018 //--------------------------------------------------
00019 
00020 #include "L1Trigger/GlobalMuonTrigger/src/L1MuGMTLUTHelpers.h"
00021 //---------------
00022 // C++ Headers --
00023 //---------------
00024 #include <ctype.h>
00025 
00026 using namespace std;
00027 
00028 //--------------------------------------------------------------------------------
00029 // Replace substring in string
00030 
00031 int L1MuGMTLUTHelpers::replace(string & input, const string& gone, const string& it, bool multiple) {
00032   int n=0;
00033   size_t i = input.find(gone,0);
00034   while(i!=string::npos) {
00035       n++;
00036       input.replace(i,gone.size(),it);
00037       i = input.find(gone,i+(multiple ? 0 : it.size()));
00038   }
00039   return n;
00040 }
00041 
00042 //--------------------------------------------------------------------------------
00043 // Make an uppercase copy of s
00044 
00045 string L1MuGMTLUTHelpers::upperCase(const string& s) {
00046   char* buf = new char[s.length()];
00047   s.copy(buf, s.length());
00048   for(unsigned i = 0; i < s.length(); i++)
00049     buf[i] = toupper(buf[i]);
00050   string r(buf, s.length());
00051   delete buf;
00052   return r;
00053 }
00054 
00055 
00056 
00057 //--------------------------------------------------------------------------------
00058 // Make an lowercase copy of s
00059 
00060 string L1MuGMTLUTHelpers::lowerCase(const string& s) {
00061   char* buf = new char[s.length()];
00062   s.copy(buf, s.length());
00063   for(unsigned i = 0; i < s.length(); i++)
00064     buf[i] = tolower(buf[i]);
00065   string r(buf, s.length());
00066   delete buf;
00067   return r;
00068 }
00069 
00070 
00071 
00072 
00073