File indexing completed on 2024-04-06 12:11:35
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include <boost/regex.hpp>
0015
0016
0017 #include "Fireworks/Core/src/expressionFormatHelpers.h"
0018
0019
0020
0021
0022
0023 namespace fireworks {
0024 namespace expression {
0025 std::string oldToNewFormat(const std::string& iExpression) {
0026
0027 const std::string variable;
0028 static boost::regex const reVarName("(\\$\\.)|(\\(\\))");
0029
0030 return boost::regex_replace(iExpression, reVarName, variable);
0031 }
0032
0033 long indexFromNewFormatToOldFormat(const std::string& iNewFormat,
0034 long iNewFormatIndex,
0035 const std::string& iOldFormat) {
0036 if (iNewFormat.substr(0, iNewFormatIndex) == iOldFormat.substr(0, iNewFormatIndex)) {
0037 return iNewFormatIndex;
0038 }
0039 assert(iNewFormat.size() < iOldFormat.size());
0040 std::string::const_iterator itNew = iNewFormat.begin(), itOld = iOldFormat.begin(), itNewEnd = iNewFormat.end();
0041 for (; itNew != itNewEnd && itNew - iNewFormat.begin() < iNewFormatIndex; ++itNew, ++itOld) {
0042 while (*itNew != *itOld) {
0043 assert(itOld != iOldFormat.end());
0044 ++itOld;
0045 }
0046 }
0047 return itOld - iOldFormat.begin();
0048 }
0049 }
0050 }