src/GenericUtils.h
/// tells whether a position in a string is surrounded by round braces
/// e.g. true  for arguments {"a(b)", 2}
/// e.g. true  for arguments {"a()", 1}  by convention
/// e.g. false for arguments {"a()", 2}  by convention
/// e.g. false for arguments {"a(b)", 0}
/// e.g. false for arguments {"a(b)c", 4}
/// e.g. false for arguments {"a(b)c(d)", 4}
/// e.g. true  for arguments {"a((b)c(d))", 5}
tells whether a position in a string is surrounded by round braces
e.g.
tells whether a position in a string is surrounded by round braces e . g .
inline bool WithinMatchedParentheses(string_view haystack, size_t charPosition)
    {
        const auto hayLen = haystack.length();
        int nesting = 0;
        for (size_t pos = 0; pos <= charPosition && pos < hayLen; ++pos)
        {
            nesting += haystack[pos] == '(' ? 1
                : (haystack[pos] == ')' ? -1 : 0);
        }
        return nesting > 0;
    }
inline bool WithinMatchedParentheses ( string_view haystack , size_t charPosition ) { const auto hayLen = haystack . length ( ) ; int nesting = 0 ; for ( size_t pos = 0 ; pos <= charPosition && pos < hayLen ; ++ pos ) { nesting += haystack [ pos ] == ' ' ? 1 : ( haystack [ pos ] == ' ' ? -1 : 0 ) ; } return nesting > 0 ; }
tells whether a position in a string is surrounded by round braces
e.g.
tells whether a position in a string is surrounded by round braces e . g .
// we don't even need to be looking at the left side, we suppose balanced construction. // let's evaluate the level of nesting at the asked pos.