MCPcopy Create free account
hub / github.com/Kitware/VTK / OperatorWithinVariable

Method OperatorWithinVariable

Common/Misc/vtkFunctionParser.cxx:1115–1184  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1113
1114//------------------------------------------------------------------------------
1115int vtkFunctionParser::OperatorWithinVariable(int idx)
1116{
1117 char* tmpString = nullptr;
1118
1119 for (int i = 0, max = this->GetNumberOfScalarVariables(); i < max; i++)
1120 {
1121 int end = 0;
1122
1123 if (strchr(this->ScalarVariableNames[i].c_str(), this->Function[idx]) != nullptr)
1124 {
1125 if ((tmpString = strstr(this->Function, this->ScalarVariableNames[i].c_str())))
1126 {
1127 do
1128 {
1129 if (tmpString)
1130 {
1131 int start = static_cast<int>(tmpString - this->Function);
1132 end = start + static_cast<int>(this->ScalarVariableNames[i].size());
1133
1134 // the variable being investigated does contain an operator (at idx)
1135 if (start <= idx && idx <= end)
1136 return 1;
1137
1138 // just in case of one or even more occurrences of the
1139 // variable name (being investigated) preceding "idx" in this->Function[]
1140 // As suggested by 7islands, a greedy search is used here
1141 if (end <= idx) // to save strstr() whenever possible
1142 tmpString = strstr(this->Function + end, this->ScalarVariableNames[i].c_str());
1143 }
1144 else
1145 break;
1146 } while (end <= idx);
1147 }
1148 }
1149 }
1150
1151 for (int i = 0, max = this->GetNumberOfVectorVariables(); i < max; i++)
1152 {
1153 int end = 0;
1154
1155 if (strchr(this->VectorVariableNames[i].c_str(), this->Function[idx]) != nullptr)
1156 {
1157 if ((tmpString = strstr(this->Function, this->VectorVariableNames[i].c_str())))
1158 {
1159 do
1160 {
1161 if (tmpString)
1162 {
1163 int start = static_cast<int>(tmpString - this->Function);
1164 end = start + static_cast<int>(this->VectorVariableNames[i].size());
1165
1166 // the variable being investigated does contain an operator (at idx)
1167 if (start <= idx && idx <= end)
1168 return 1;
1169
1170 // just in case of one or even more occurrences of the
1171 // variable name (being investigated) preceding "idx" in this->Function[]
1172 // As suggested by 7islands, a greedy search is used here

Callers 1

Calls 2

c_strMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected