File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -28,5 +28,33 @@ inline std::string trim(const std::string& s) {
2828 return s.substr (start, end - start + 1 );
2929}
3030
31+ // function to find top-level '=' that's not part of ==, <=, >=, !=
32+ static size_t findTopLevelEquals (const std::string& str) {
33+ int depth = 0 ;
34+
35+ for (size_t i = 0 ; i < str.size (); ++i) {
36+ char c = str[i];
37+ if (c == ' (' ) {
38+ ++depth;
39+ } else if (c == ' )' ) {
40+ --depth;
41+ } else if (c == ' =' && depth == 0 ) {
42+ // check it's not part of ==, <=, >=, !=
43+ bool isOperator = false ;
44+ if (i > 0 && (str[i-1 ] == ' =' || str[i-1 ] == ' <' || str[i-1 ] == ' >' || str[i-1 ] == ' !' )) {
45+ isOperator = true ;
46+ }
47+ if (i + 1 < str.size () && str[i+1 ] == ' =' ) {
48+ isOperator = true ;
49+ }
50+
51+ if (!isOperator) {
52+ return i;
53+ }
54+ }
55+ }
56+ return std::string::npos;
57+ }
58+
3159#endif // IMGRAPH_FUNCS_HPP
3260
You can’t perform that action at this time.
0 commit comments