CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1MuGMTLUTHelpers.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: L1MuGMTLUTHelpers
8 //
9 // $Date: 2006/05/15 13:56:02 $
10 // $Revision: 1.1 $
11 //
12 // Author :
13 // H. Sakulin HEPHY Vienna
14 //
15 // Migrated to CMSSW:
16 // I. Mikulec
17 //
18 //--------------------------------------------------
19 
21 //---------------
22 // C++ Headers --
23 //---------------
24 #include <ctype.h>
25 
26 using namespace std;
27 
28 //--------------------------------------------------------------------------------
29 // Replace substring in string
30 
31 int L1MuGMTLUTHelpers::replace(string & input, const string& gone, const string& it, bool multiple) {
32  int n=0;
33  size_t i = input.find(gone,0);
34  while(i!=string::npos) {
35  n++;
36  input.replace(i,gone.size(),it);
37  i = input.find(gone,i+(multiple ? 0 : it.size()));
38  }
39  return n;
40 }
41 
42 //--------------------------------------------------------------------------------
43 // Make an uppercase copy of s
44 
45 string L1MuGMTLUTHelpers::upperCase(const string& s) {
46  char* buf = new char[s.length()];
47  s.copy(buf, s.length());
48  for(unsigned i = 0; i < s.length(); i++)
49  buf[i] = toupper(buf[i]);
50  string r(buf, s.length());
51  delete buf;
52  return r;
53 }
54 
55 
56 
57 //--------------------------------------------------------------------------------
58 // Make an lowercase copy of s
59 
60 string L1MuGMTLUTHelpers::lowerCase(const string& s) {
61  char* buf = new char[s.length()];
62  s.copy(buf, s.length());
63  for(unsigned i = 0; i < s.length(); i++)
64  buf[i] = tolower(buf[i]);
65  string r(buf, s.length());
66  delete buf;
67  return r;
68 }
69 
70 
71 
72 
73 
int i
Definition: DBlmapReader.cc:9
static std::string lowerCase(const std::string &s)
static std::string upperCase(const std::string &s)
tuple input
Definition: collect_tpl.py:10
static int replace(std::string &input, const std::string &gone, const std::string &it, bool multiple)
string s
Definition: asciidump.py:422