From 3d0eec828b5d7a8a57b64d68c8af58a612c80f06 Mon Sep 17 00:00:00 2001 From: Guenter Obiltschnig Date: Sat, 10 Nov 2012 12:01:18 +0100 Subject: [PATCH] - fixed a CppParser issue when parsing templates with default template args (such as Poco::SharedPtr) --- CppParser/src/Symbol.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/CppParser/src/Symbol.cpp b/CppParser/src/Symbol.cpp index 778bb1071..cbcc74f9d 100644 --- a/CppParser/src/Symbol.cpp +++ b/CppParser/src/Symbol.cpp @@ -1,7 +1,7 @@ // // Symbol.cpp // -// $Id: //poco/1.4/CppParser/src/Symbol.cpp#1 $ +// $Id: //poco/1.4/CppParser/src/Symbol.cpp#2 $ // // Library: CppParser // Package: SymbolTable @@ -160,8 +160,27 @@ std::string Symbol::extractName(const std::string& decl) if (pos == std::string::npos || (pos > 0 && decl[pos - 1] == '(')) pos = decl.size(); --pos; - // check for constant - std::string::size_type eqPos = decl.find('='); + // check for constant; start searching after template + std::string::size_type eqStart = 0; + if (decl.compare(0, 8, "template") == 0) + { + eqStart = 8; + while (std::isspace(decl[eqStart]) && eqStart < decl.size()) ++eqStart; + if (eqStart < decl.size() && decl[eqStart] == '<') + { + ++eqStart; + int tc = 1; + while (tc > 0 && eqStart < decl.size()) + { + if (decl[eqStart] == '<') + ++tc; + else if (decl[eqStart] == '>') + --tc; + ++eqStart; + } + } + } + std::string::size_type eqPos = decl.find('=', eqStart); if (eqPos != std::string::npos) { // special case: default template parameter