| 161 | } |
| 162 | |
| 163 | void IncludeProcessor::parseInclude(std::string & trimmedLine, CompositeStringSource * compositeSource, std::stringstream & destinationstream) |
| 164 | { |
| 165 | size_t leftBracketPosition = trimmedLine.find_first_of('<'); |
| 166 | size_t rightBracketPosition = trimmedLine.find_last_of('>'); |
| 167 | size_t leftQuotePosition = trimmedLine.find_first_of('"'); |
| 168 | size_t rightQuotePosition = trimmedLine.find_last_of('"'); |
| 169 | |
| 170 | size_t leftDelimiter = std::string::npos; |
| 171 | size_t rightDelimiter = std::string::npos; |
| 172 | |
| 173 | if (leftBracketPosition != std::string::npos && rightBracketPosition != std::string::npos) |
| 174 | { |
| 175 | leftDelimiter = leftBracketPosition; |
| 176 | rightDelimiter = rightBracketPosition; |
| 177 | } |
| 178 | else if (leftQuotePosition != std::string::npos && rightQuotePosition != std::string::npos && leftQuotePosition < rightQuotePosition) |
| 179 | { |
| 180 | leftDelimiter = leftQuotePosition; |
| 181 | rightDelimiter = rightQuotePosition; |
| 182 | } |
| 183 | |
| 184 | if (leftDelimiter != std::string::npos && rightDelimiter != std::string::npos) |
| 185 | { |
| 186 | std::string include = trimmedLine.substr(leftDelimiter+1, rightDelimiter - leftDelimiter - 1); |
| 187 | |
| 188 | if (include.size() != 0 && !endsWith(include, '/')) |
| 189 | { |
| 190 | processInclude(include, compositeSource, destinationstream); |
| 191 | } |
| 192 | else |
| 193 | { |
| 194 | warning() << "Malformed #include " << include; |
| 195 | } |
| 196 | } |
| 197 | else |
| 198 | { |
| 199 | warning() << "Malformed #include " << trimmedLine; |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | void IncludeProcessor::processInclude(std::string & include, CompositeStringSource * compositeSource, std::stringstream & destinationstream) |
| 204 | { |