summaryrefslogtreecommitdiffstats
path: root/src/doxygen.cpp
diff options
context:
space:
mode:
authorDimitri van Heesch <dimitri@stack.nl>2005-10-10 19:22:31 (GMT)
committerDimitri van Heesch <dimitri@stack.nl>2005-10-10 19:22:31 (GMT)
commitc9ed38abcef60f4ecb9fc08a1ddd936762d5342c (patch)
tree30215767ee72661b15eae6b66e51b409feff64cf /src/doxygen.cpp
parentc1cf420f89fe57c162372b66bca70ff2e055f48f (diff)
downloadDoxygen-c9ed38abcef60f4ecb9fc08a1ddd936762d5342c.zip
Doxygen-c9ed38abcef60f4ecb9fc08a1ddd936762d5342c.tar.gz
Doxygen-c9ed38abcef60f4ecb9fc08a1ddd936762d5342c.tar.bz2
Release-1.4.5-20051010
Diffstat (limited to 'src/doxygen.cpp')
-rw-r--r--src/doxygen.cpp98
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);