| 108 | #if BOOST_VERSION > 105500 |
| 109 | |
| 110 | inline void substituteInternal( const char *s, const StringAlgo::VariableProvider &variables, std::string &result, const int recursionDepth, unsigned substitutions ) |
| 111 | { |
| 112 | if( recursionDepth > 8 ) |
| 113 | { |
| 114 | throw IECore::Exception( "StringAlgo::substitute() : maximum recursion depth reached." ); |
| 115 | } |
| 116 | |
| 117 | while( *s ) |
| 118 | { |
| 119 | switch( *s ) |
| 120 | { |
| 121 | case '\\' : |
| 122 | { |
| 123 | if( substitutions & StringAlgo::EscapeSubstitutions ) |
| 124 | { |
| 125 | s++; |
| 126 | if( *s ) |
| 127 | { |
| 128 | result.push_back( *s++ ); |
| 129 | } |
| 130 | } |
| 131 | else |
| 132 | { |
| 133 | // variable substitutions disabled |
| 134 | result.push_back( *s++ ); |
| 135 | } |
| 136 | break; |
| 137 | } |
| 138 | case '$' : |
| 139 | { |
| 140 | if( substitutions & StringAlgo::VariableSubstitutions ) |
| 141 | { |
| 142 | s++; // skip $ |
| 143 | bool bracketed = *s =='{'; |
| 144 | const char *variableNameStart = nullptr; |
| 145 | const char *variableNameEnd = nullptr; |
| 146 | if( bracketed ) |
| 147 | { |
| 148 | s++; // skip initial bracket |
| 149 | variableNameStart = s; |
| 150 | while( *s && *s != '}' ) |
| 151 | { |
| 152 | s++; |
| 153 | } |
| 154 | variableNameEnd = s; |
| 155 | if( *s ) |
| 156 | { |
| 157 | s++; // skip final bracket |
| 158 | } |
| 159 | } |
| 160 | else |
| 161 | { |
| 162 | variableNameStart = s; |
| 163 | while( isalnum( *s ) ) |
| 164 | { |
| 165 | s++; |
| 166 | } |
| 167 | variableNameEnd = s; |
no test coverage detected