CMS 3D CMS Logo

expressionFormatHelpers.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : expressionFormatHelpers
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Fri Aug 22 12:25:04 EDT 2008
11 //
12 
13 // system include files
14 #include <boost/regex.hpp>
15 
16 // user include files
18 
19 //
20 // constants, enums and typedefs
21 //
22 
23 namespace fireworks {
24  namespace expression {
25  std::string oldToNewFormat(const std::string& iExpression) {
26  //Backwards compatibility with old format: If find a $. or a () just remove them
27  const std::string variable;
28  static boost::regex const reVarName("(\\$\\.)|(\\(\\))");
29 
30  return boost::regex_replace(iExpression, reVarName, variable);
31  }
32 
34  long iNewFormatIndex,
35  const std::string& iOldFormat) {
36  if (iNewFormat.substr(0, iNewFormatIndex) == iOldFormat.substr(0, iNewFormatIndex)) {
37  return iNewFormatIndex;
38  }
39  assert(iNewFormat.size() < iOldFormat.size());
40  std::string::const_iterator itNew = iNewFormat.begin(), itOld = iOldFormat.begin(), itNewEnd = iNewFormat.end();
41  for (; itNew != itNewEnd && itNew - iNewFormat.begin() < iNewFormatIndex; ++itNew, ++itOld) {
42  while (*itNew != *itOld) {
43  assert(itOld != iOldFormat.end());
44  ++itOld;
45  }
46  }
47  return itOld - iOldFormat.begin();
48  }
49  } // namespace expression
50 } // namespace fireworks
fireworks::expression::oldToNewFormat
std::string oldToNewFormat(const std::string &iExpression)
Definition: expressionFormatHelpers.cc:25
cms::cuda::assert
assert(be >=bs)
expressionFormatHelpers.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
fireworks::expression::indexFromNewFormatToOldFormat
long indexFromNewFormatToOldFormat(const std::string &iNewFormat, long iNewFormatIndex, const std::string &iOldFormat)
Definition: expressionFormatHelpers.cc:33
taus_updatedMVAIds_cff.variable
variable
Definition: taus_updatedMVAIds_cff.py:33
fireworks
Definition: FWTauProxyBuilderBase.h:35