CMS 3D CMS Logo

stringTools.cc File Reference

#include "Utilities/General/interface/stringTools.h"

Go to the source code of this file.

Functions

int replace (string &input, const string &gone, const string &it, bool multiple)
int replaceRange (string &input, const string &first, const string &last, const string &it, bool multiple)
void strip (std::string &input, const std::string &blanks)


Function Documentation

int replace ( string &  input,
const string &  gone,
const string &  it,
bool  multiple 
)

Definition at line 5 of file stringTools.cc.

References i, and n.

00005                                                                                 {
00006   int n=0;
00007   size_t i = input.find(gone,0);
00008   while(i!=string::npos) {
00009       n++;
00010       input.replace(i,gone.size(),it);
00011       i = input.find(gone,i+(multiple ? 0 : it.size()));
00012   }
00013   return n;
00014 }

int replaceRange ( string &  input,
const string &  first,
const string &  last,
const string &  it,
bool  multiple 
)

Definition at line 23 of file stringTools.cc.

References e, i, and n.

00023                                                                                                           {
00024   int n=0;
00025   size_t i = input.find(first,0);
00026   while(i!=string::npos) {
00027     size_t e = input.find(last,i);
00028     if (e!=string::npos) {
00029       n++;
00030       input.replace(i,e+last.size()-i,it);
00031       i = input.find(first,i+(multiple ? 0 : it.size()));
00032     } else break;
00033   }
00034   return n;
00035 }

void strip ( std::string &  input,
const std::string &  blanks 
)

Definition at line 16 of file stringTools.cc.

References b, and e.

00016                                                        {
00017   size_t b = input.find_first_not_of(blanks);
00018   if (b==std::string::npos) { input.clear(); return;}
00019   size_t e = input.find_last_not_of(blanks);
00020   input = input.substr(b,e-b+1);
00021 }


Generated on Tue Jun 9 17:56:01 2009 for CMSSW by  doxygen 1.5.4