test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 //
21 // constants, enums and typedefs
22 //
23 
24 namespace fireworks {
25  namespace expression {
26  std::string oldToNewFormat(const std::string& iExpression) {
27  //Backwards compatibility with old format: If find a $. or a () just remove them
28  const std::string variable;
29  static boost::regex const reVarName("(\\$\\.)|(\\(\\))");
30 
31  return boost::regex_replace(iExpression,reVarName,variable);
32  }
33 
35  long iNewFormatIndex,
36  const std::string& iOldFormat)
37  {
38  if(iNewFormat.substr(0,iNewFormatIndex) ==
39  iOldFormat.substr(0,iNewFormatIndex)) {
40  return iNewFormatIndex;
41  }
42  assert(iNewFormat.size()< iOldFormat.size());
43  std::string::const_iterator itNew = iNewFormat.begin(), itOld = iOldFormat.begin(),
44  itNewEnd = iNewFormat.end();
45  for(;
46  itNew != itNewEnd && itNew-iNewFormat.begin() < iNewFormatIndex;
47  ++itNew, ++itOld) {
48  while(*itNew != *itOld) {
49  assert(itOld != iOldFormat.end());
50  ++itOld;
51  }
52  }
53  return itOld - iOldFormat.begin();
54  }
55  }
56 }
long indexFromNewFormatToOldFormat(const std::string &iNewFormat, long iNewFormatIndex, const std::string &iOldFormat)
assert(m_qm.get())
std::string oldToNewFormat(const std::string &iExpression)