CMS 3D CMS Logo

Functions

fireworks::expression Namespace Reference

Functions

long indexFromNewFormatToOldFormat (const std::string &iNewFormat, long iNewFormatIndex, const std::string &iOldFormat)
std::string oldToNewFormat (const std::string &iExpression)

Function Documentation

long fireworks::expression::indexFromNewFormatToOldFormat ( const std::string &  iNewFormat,
long  iNewFormatIndex,
const std::string &  iOldFormat 
)

Definition at line 35 of file expressionFormatHelpers.cc.

Referenced by FWModelExpressionSelector::select(), FWExpressionEvaluator::setExpression(), and FWModelFilter::setExpression().

      {
         if(iNewFormat.substr(0,iNewFormatIndex) ==
            iOldFormat.substr(0,iNewFormatIndex)) {
            return iNewFormatIndex;
         }
         assert(iNewFormat.size()< iOldFormat.size());
         std::string::const_iterator itNew = iNewFormat.begin(), itOld = iOldFormat.begin(),
                                     itNewEnd = iNewFormat.end();
         for(;
             itNew != itNewEnd && itNew-iNewFormat.begin() < iNewFormatIndex;
             ++itNew, ++itOld) {
            while(*itNew != *itOld) {
               assert(itOld != iOldFormat.end());
               ++itOld;
            }
         }
         return itOld - iOldFormat.begin();
      }
std::string fireworks::expression::oldToNewFormat ( const std::string &  iExpression)

Definition at line 27 of file expressionFormatHelpers.cc.

Referenced by FWItemValueGetter::addEntry(), FWModelExpressionSelector::select(), FWExpressionEvaluator::setExpression(), and FWModelFilter::setExpression().

                                                             {
         //Backwards compatibility with old format: If find a $. or a () just remove them
         const std::string variable;
         static boost::regex const reVarName("(\\$\\.)|(\\(\\))");

         return boost::regex_replace(iExpression,reVarName,variable);
      }