Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:47:43

0001 #include "FWCore/ParameterSet/interface/defaultModuleLabel.h"
0002 
0003 #include <algorithm>
0004 
0005 namespace edm {
0006   std::string defaultModuleLabel(std::string label) {
0007     // remove all colons (module type may contain namespace)
0008     label.erase(std::remove(label.begin(), label.end(), ':'), label.end());
0009 
0010     // remove everything after first '@' (used for module alternatives)
0011     label.erase(std::find(label.begin(), label.end(), '@'), label.end());
0012 
0013     // the following code originates from HLTrigger/HLTcore/interface/defaultModuleLabel.h
0014     // if the label is all uppercase, change it to all lowercase
0015     // if the label starts with more than one uppercase letter, change n-1 to lowercase
0016     // otherwise, change the first letter to lowercase
0017     unsigned int ups = 0;
0018     for (char c : label)
0019       if (std::isupper(c))
0020         ++ups;
0021       else
0022         break;
0023     if (ups > 1 and ups != label.size())
0024       --ups;
0025     for (unsigned int i = 0; i < ups; ++i)
0026       label[i] = std::tolower(label[i]);
0027 
0028     return label;
0029   }
0030 }  // namespace edm