diff options
author | dimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7> | 2005-10-10 19:22:31 (GMT) |
---|---|---|
committer | dimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7> | 2005-10-10 19:22:31 (GMT) |
commit | b7ae07dc2e3b4b635cc59a49d326a88d45f9206b (patch) | |
tree | 30215767ee72661b15eae6b66e51b409feff64cf /src/doxygen.cpp | |
parent | 22eb9881c15ad001246cfcde1c727a2f98f472df (diff) | |
download | Doxygen-b7ae07dc2e3b4b635cc59a49d326a88d45f9206b.zip Doxygen-b7ae07dc2e3b4b635cc59a49d326a88d45f9206b.tar.gz Doxygen-b7ae07dc2e3b4b635cc59a49d326a88d45f9206b.tar.bz2 |
Release-1.4.5-20051010
Diffstat (limited to 'src/doxygen.cpp')
-rw-r--r-- | src/doxygen.cpp | 98 |
1 files changed, 81 insertions, 17 deletions
diff --git a/src/doxygen.cpp b/src/doxygen.cpp index 95cce31..ff2606a 100644 --- a/src/doxygen.cpp +++ b/src/doxygen.cpp @@ -3511,6 +3511,85 @@ static bool isRecursiveBaseClass(const QCString &scope,const QCString &name) return result; } +/*! Searches for the end of a template in prototype \a s starting from + * character position \a startPos. If the end was found the position + * of the closing \> is returned, otherwise -1 is returned. + * + * Handles exotic cases such as + * \code + * Class<(id<0)> + * Class<bits<<2> + * Class<"<"> + * Class<'<'> + * Class<(")<")> + * \endcode + */ +static int findEndOfTemplate(const QCString &s,int startPos) +{ + // locate end of template + int e=startPos; + int brCount=1; + int roundCount=0; + int len = s.length(); + bool insideString=FALSE; + bool insideChar=FALSE; + char pc = 0; + while (e<len && brCount!=0) + { + char c=s.at(e); + switch(c) + { + case '<': + if (!insideString && !insideChar) + { + if (e<len-1 && s.at(e+1)=='<') + e++; + else if (roundCount==0) + brCount++; + } + break; + case '>': + if (!insideString && !insideChar) + { + if (e<len-1 && s.at(e+1)=='>') + e++; + else if (roundCount==0) + brCount--; + } + break; + case '(': + if (!insideString && !insideChar) + roundCount++; + break; + case ')': + if (!insideString && !insideChar) + roundCount--; + break; + case '"': + if (!insideChar) + { + if (insideString && pc!='\\') + insideString=FALSE; + else + insideString=TRUE; + } + break; + case '\'': + if (!insideString) + { + if (insideChar && pc!='\\') + insideChar=FALSE; + else + insideChar=TRUE; + } + break; + } + pc = c; + e++; + } + return brCount==0 ? e : -1; +} + static bool findClassRelation( Entry *root, Definition *context, @@ -3603,23 +3682,8 @@ static bool findClassRelation( { // TODO: here we should try to find the correct template specialization // but for now, we only look for the unspecializated base class. - // locate end of template - int e=i+1; - int brCount=1; - int typeLen = baseClassName.length(); - while (e<typeLen && brCount!=0) - { - if (baseClassName.at(e)=='<') - { - if (e<typeLen-1 && baseClassName.at(e+1)=='<') e++; else brCount++; - } - if (baseClassName.at(e)=='>') - { - if (e<typeLen-1 && baseClassName.at(e+1)=='>') e++; else brCount--; - } - e++; - } - if (brCount==0) // end of template was found at e + int e=findEndOfTemplate(baseClassName,i+1); + if (e!=-1) // end of template was found at e { templSpec=baseClassName.mid(i,e-i); baseClassName=baseClassName.left(i)+baseClassName.right(baseClassName.length()-e); |