File tree Expand file tree Collapse file tree 2 files changed +28
-28
lines changed
Expand file tree Collapse file tree 2 files changed +28
-28
lines changed Original file line number Diff line number Diff line change 2020
2121namespace App {
2222
23- // function to find top-level '=' that's not part of ==, <=, >=, !=
24- static size_t findTopLevelEquals (const std::string& str) {
25- int depth = 0 ;
26-
27- for (size_t i = 0 ; i < str.size (); ++i) {
28- char c = str[i];
29- if (c == ' (' ) {
30- ++depth;
31- } else if (c == ' )' ) {
32- --depth;
33- } else if (c == ' =' && depth == 0 ) {
34- // check it's not part of ==, <=, >=, !=
35- bool isOperator = false ;
36- if (i > 0 && (str[i-1 ] == ' =' || str[i-1 ] == ' <' || str[i-1 ] == ' >' || str[i-1 ] == ' !' )) {
37- isOperator = true ;
38- }
39- if (i + 1 < str.size () && str[i+1 ] == ' =' ) {
40- isOperator = true ;
41- }
42-
43- if (!isOperator) {
44- return i;
45- }
46- }
47- }
48- return std::string::npos;
49- }
50-
5123Application::Application (const std::string& title) {
5224 APP_PROFILE_FUNCTION ();
5325
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