summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Klopcic <marko.klopcic@isystem.si>2012-08-26 15:34:46 +0000
committerMarko Klopcic <marko.klopcic@isystem.si>2012-08-26 15:34:46 +0000
commitc9eda79264ecb1b82c69ec7bf611918aa5feb9bf (patch)
tree29bed426642031697c6ea831d57d7e749ca27526
parenta753f3e799170959c2dcfef2f4cd60efe31b20c6 (diff)
downloadswig-c9eda79264ecb1b82c69ec7bf611918aa5feb9bf.tar.gz
refactored DoxygenEntity class
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13724 626c5289-ae23-0410-ae9c-e8d60b6d4f22
-rw-r--r--Source/DoxygenTranslator/src/DoxygenEntity.cpp182
-rw-r--r--Source/DoxygenTranslator/src/DoxygenEntity.h27
-rw-r--r--Source/DoxygenTranslator/src/DoxygenParser.cpp72
-rw-r--r--Source/DoxygenTranslator/src/DoxygenParser.h75
-rw-r--r--Source/DoxygenTranslator/src/DoxygenTranslator.cpp24
-rw-r--r--Source/DoxygenTranslator/src/DoxygenTranslator.h26
-rw-r--r--Source/DoxygenTranslator/src/JavaDocConverter.cpp2
7 files changed, 155 insertions, 253 deletions
diff --git a/Source/DoxygenTranslator/src/DoxygenEntity.cpp b/Source/DoxygenTranslator/src/DoxygenEntity.cpp
index 4039ccc99..7b0088e06 100644
--- a/Source/DoxygenTranslator/src/DoxygenEntity.cpp
+++ b/Source/DoxygenTranslator/src/DoxygenEntity.cpp
@@ -14,182 +14,66 @@
#include "DoxygenEntity.h"
#include <iostream>
-DoxygenEntity::DoxygenEntity(std::string typeEnt) {
- typeOfEntity = typeEnt;
- data = "";
- isLeaf = true;
-}
+using std::cout;
+
+DoxygenEntity::DoxygenEntity(const std::string &typeEnt) :
+ typeOfEntity(typeEnt),
+ isLeaf(true)
+{}
+
/* Basic node for commands that have
- * only 1 thing after them
+ * only 1 item after them
* example: \b word
* OR holding a std::string
*/
-DoxygenEntity::DoxygenEntity(std::string typeEnt, std::string param1) {
- typeOfEntity = typeEnt;
- data = param1;
- isLeaf = true;
-}
+DoxygenEntity::DoxygenEntity(const std::string &typeEnt,
+ const std::string &param1) :
+ typeOfEntity(typeEnt),
+ data(param1),
+ isLeaf(true)
+{}
+
/* Nonterminal node
* contains
*/
-DoxygenEntity::DoxygenEntity(std::string typeEnt, std::list < DoxygenEntity > &entList) {
- typeOfEntity = typeEnt;
- data = "";
- isLeaf = false;
- entityList = entList;
-}
+DoxygenEntity::DoxygenEntity(const std::string &typeEnt,
+ const DoxygenEntityList &entList) :
+ typeOfEntity(typeEnt),
+ isLeaf(false),
+ entityList(entList)
+{}
+
void DoxygenEntity::printEntity(int level) const {
+
int thisLevel = level;
+
if (isLeaf) {
for (int i = 0; i < thisLevel; i++) {
- std::cout << "\t";
+ cout << "\t";
}
- std::cout << "Node Command: " << typeOfEntity << " ";
+ cout << "Node Command: " << typeOfEntity << " ";
- if (data.compare("") != 0) {
- std::cout << "Node Data: " << data;
+ if (!data.empty()) {
+ cout << "Node Data: " << data;
}
- std::cout << std::endl;
+ cout << std::endl;
} else {
for (int i = 0; i < thisLevel; i++) {
- std::cout << "\t";
+ cout << "\t";
}
- std::cout << "Node Command : " << typeOfEntity << std::endl;
+ cout << "Node Command : " << typeOfEntity << std::endl;
- std::list < DoxygenEntity >::const_iterator p = entityList.begin();
thisLevel++;
- while (p != entityList.end()) {
- (*p).printEntity(thisLevel);
- p++;
+ for (DoxygenEntityListCIt p = entityList.begin(); p != entityList.end(); p++) {
+ p->printEntity(thisLevel);
}
}
}
-
-// not used, completely wrong - currently std lib reports 'invalid operator <'
-bool CompareDoxygenEntities::operator() (DoxygenEntity & first, DoxygenEntity & second) {
-
- // return first.typeOfEntity < second.typeOfEntity;
- if (first.typeOfEntity.compare("brief") == 0)
- return true;
- if (second.typeOfEntity.compare("brief") == 0)
- return false;
- if (first.typeOfEntity.compare("details") == 0)
- return true;
- if (second.typeOfEntity.compare("details") == 0)
- return false;
- if (first.typeOfEntity.compare("partofdescription") == 0)
- return true;
- if (second.typeOfEntity.compare("partofdescription") == 0)
- return false;
- if (first.typeOfEntity.compare("plainstd::string") == 0)
- return true;
- if (second.typeOfEntity.compare("plainstd::string") == 0)
- return false;
- if (first.typeOfEntity.compare("param") == 0) {
- if (second.typeOfEntity.compare("param") == 0)
- return true;
- if (second.typeOfEntity.compare("return") == 0)
- return true;
- if (second.typeOfEntity.compare("exception") == 0)
- return true;
- if (second.typeOfEntity.compare("author") == 0)
- return true;
- if (second.typeOfEntity.compare("version") == 0)
- return true;
- if (second.typeOfEntity.compare("see") == 0)
- return true;
- if (second.typeOfEntity.compare("since") == 0)
- return true;
- if (second.typeOfEntity.compare("deprecated") == 0)
- return true;
- return false;
- }
- if (first.typeOfEntity.compare("return") == 0) {
- if (second.typeOfEntity.compare("return") == 0)
- return true;
- if (second.typeOfEntity.compare("exception") == 0)
- return true;
- if (second.typeOfEntity.compare("author") == 0)
- return true;
- if (second.typeOfEntity.compare("version") == 0)
- return true;
- if (second.typeOfEntity.compare("see") == 0)
- return true;
- if (second.typeOfEntity.compare("since") == 0)
- return true;
- if (second.typeOfEntity.compare("deprecated") == 0)
- return true;
- return false;
- }
- if (first.typeOfEntity.compare("exception") == 0) {
- if (second.typeOfEntity.compare("exception") == 0)
- return true;
- if (second.typeOfEntity.compare("author") == 0)
- return true;
- if (second.typeOfEntity.compare("version") == 0)
- return true;
- if (second.typeOfEntity.compare("see") == 0)
- return true;
- if (second.typeOfEntity.compare("since") == 0)
- return true;
- if (second.typeOfEntity.compare("deprecated") == 0)
- return true;
- return false;
- }
- if (first.typeOfEntity.compare("author") == 0) {
- if (second.typeOfEntity.compare("author") == 0)
- return true;
- if (second.typeOfEntity.compare("version") == 0)
- return true;
- if (second.typeOfEntity.compare("see") == 0)
- return true;
- if (second.typeOfEntity.compare("since") == 0)
- return true;
- if (second.typeOfEntity.compare("deprecated") == 0)
- return true;
- return false;
- }
- if (first.typeOfEntity.compare("version") == 0) {
- if (second.typeOfEntity.compare("version") == 0)
- return true;
- if (second.typeOfEntity.compare("see") == 0)
- return true;
- if (second.typeOfEntity.compare("since") == 0)
- return true;
- if (second.typeOfEntity.compare("deprecated") == 0)
- return true;
- return false;
- }
- if (first.typeOfEntity.compare("see") == 0 || first.typeOfEntity.compare("sa") == 0) {
- if (second.typeOfEntity.compare("see") == 0)
- return true;
- if (second.typeOfEntity.compare("sa") == 0)
- return true;
- if (second.typeOfEntity.compare("since") == 0)
- return true;
- if (second.typeOfEntity.compare("deprecated") == 0)
- return true;
- return false;
- }
- if (first.typeOfEntity.compare("since") == 0) {
- if (second.typeOfEntity.compare("since") == 0)
- return true;
- if (second.typeOfEntity.compare("deprecated") == 0)
- return true;
- return false;
- }
- if (first.typeOfEntity.compare("deprecated") == 0) {
- if (second.typeOfEntity.compare("deprecated") == 0)
- return true;
- return false;
- }
- return true;
-}
diff --git a/Source/DoxygenTranslator/src/DoxygenEntity.h b/Source/DoxygenTranslator/src/DoxygenEntity.h
index 9e6fda4cb..cf03240d2 100644
--- a/Source/DoxygenTranslator/src/DoxygenEntity.h
+++ b/Source/DoxygenTranslator/src/DoxygenEntity.h
@@ -36,29 +36,28 @@ typedef enum {
COMMAND
} DoxyCommandEnum;
+class DoxygenEntity;
+
+typedef std::list <DoxygenEntity> DoxygenEntityList;
+typedef DoxygenEntityList::iterator DoxygenEntityListIt;
+typedef DoxygenEntityList::const_iterator DoxygenEntityListCIt;
+
+
/*
* Structure to represent a doxygen comment entry
*/
-struct DoxygenEntity {
+class DoxygenEntity {
+public:
std::string typeOfEntity;
- std::list < DoxygenEntity > entityList;
std::string data;
bool isLeaf;
+ DoxygenEntityList entityList;
- DoxygenEntity(std::string typeEnt);
- DoxygenEntity(std::string typeEnt, std::string param1);
- DoxygenEntity(std::string typeEnt, std::list < DoxygenEntity > &entList);
+ DoxygenEntity(const std::string &typeEnt);
+ DoxygenEntity(const std::string &typeEnt, const std::string &param1);
+ DoxygenEntity(const std::string & typeEnt, const DoxygenEntityList &entList);
void printEntity(int level) const;
};
-/*
- * Functor that sorts entities by javaDoc standard order for commands.
- * NOTE: will not behave entirely properly until "First level" comments
- * such as brief descriptions are TAGGED as such
- */
-struct CompareDoxygenEntities {
- bool operator() (DoxygenEntity & first, DoxygenEntity & second);
-};
-
#endif
diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp
index 10126808d..a66d66c28 100644
--- a/Source/DoxygenTranslator/src/DoxygenParser.cpp
+++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp
@@ -102,8 +102,8 @@ bool DoxygenParser::isSectionIndicator(const std::string &smallString) {
}
-void DoxygenParser::printTree(const std::list <DoxygenEntity> &rootList) {
- std::list < DoxygenEntity >::const_iterator p = rootList.begin();
+void DoxygenParser::printTree(const DoxygenEntityList &rootList) {
+ DoxygenEntityList::const_iterator p = rootList.begin();
while (p != rootList.end()) {
(*p).printEntity(0);
p++;
@@ -297,7 +297,7 @@ DoxygenParser::TokenListCIt DoxygenParser::getEndCommand(const std::string & the
int DoxygenParser::addSimpleCommand(const std::string &theCommand,
- std::list < DoxygenEntity > &doxyList) {
+ DoxygenEntityList &doxyList) {
if (noisy)
cout << "Parsing " << theCommand << endl;
@@ -308,13 +308,13 @@ int DoxygenParser::addSimpleCommand(const std::string &theCommand,
int DoxygenParser::addCommandWord(const std::string &theCommand,
const TokenList &tokList,
- std::list < DoxygenEntity > &doxyList) {
+ DoxygenEntityList &doxyList) {
if (noisy)
cout << "Parsing " << theCommand << endl;
std::string name = getNextWord(tokList);
if (!name.empty()) {
- std::list < DoxygenEntity > aNewList;
+ DoxygenEntityList aNewList;
aNewList.push_back(DoxygenEntity("plainstd::string", name));
doxyList.push_back(DoxygenEntity(theCommand, aNewList));
return 1;
@@ -327,11 +327,11 @@ int DoxygenParser::addCommandWord(const std::string &theCommand,
int DoxygenParser::addCommandLine(const std::string &theCommand,
const TokenList &tokList,
- std::list < DoxygenEntity > &doxyList) {
+ DoxygenEntityList &doxyList) {
if (noisy)
cout << "Parsing " << theCommand << endl;
TokenListCIt endOfLine = getOneLine(tokList);
- std::list < DoxygenEntity > aNewList = parse(endOfLine, tokList);
+ DoxygenEntityList aNewList = parse(endOfLine, tokList);
doxyList.push_back(DoxygenEntity(theCommand, aNewList));
return 1;
}
@@ -339,12 +339,12 @@ int DoxygenParser::addCommandLine(const std::string &theCommand,
int DoxygenParser::addCommandParagraph(const std::string &theCommand,
const TokenList &tokList,
- std::list < DoxygenEntity > &doxyList) {
+ DoxygenEntityList &doxyList) {
if (noisy)
cout << "Parsing " << theCommand << endl;
TokenListCIt endOfParagraph = getEndOfParagraph(tokList);
- std::list < DoxygenEntity > aNewList;
+ DoxygenEntityList aNewList;
aNewList = parse(endOfParagraph, tokList);
doxyList.push_back(DoxygenEntity(theCommand, aNewList));
return 1;
@@ -353,7 +353,7 @@ int DoxygenParser::addCommandParagraph(const std::string &theCommand,
int DoxygenParser::addCommandEndCommand(const std::string &theCommand,
const TokenList & tokList,
- std::list < DoxygenEntity > &doxyList) {
+ DoxygenEntityList &doxyList) {
if (noisy)
cout << "Parsing " << theCommand << endl;
TokenListCIt endCommand = getEndCommand("end" + theCommand, tokList);
@@ -361,7 +361,7 @@ int DoxygenParser::addCommandEndCommand(const std::string &theCommand,
printListError(WARN_DOXYGEN_COMMAND_EXPECTED, "Expected end" + theCommand);
return 0;
}
- std::list < DoxygenEntity > aNewList;
+ DoxygenEntityList aNewList;
aNewList = parse(endCommand, tokList);
m_tokenListIt++;
doxyList.push_back(DoxygenEntity(theCommand, aNewList));
@@ -371,7 +371,7 @@ int DoxygenParser::addCommandEndCommand(const std::string &theCommand,
int DoxygenParser::addCommandWordParagraph(const std::string &theCommand,
const TokenList &tokList,
- std::list < DoxygenEntity > &doxyList) {
+ DoxygenEntityList &doxyList) {
if (noisy)
cout << "Parsing " << theCommand << endl;
@@ -382,7 +382,7 @@ int DoxygenParser::addCommandWordParagraph(const std::string &theCommand,
return 0;
}
TokenListCIt endOfParagraph = getEndOfParagraph(tokList);
- std::list < DoxygenEntity > aNewList;
+ DoxygenEntityList aNewList;
aNewList = parse(endOfParagraph, tokList);
aNewList.push_front(DoxygenEntity("plainstd::string", name));
doxyList.push_back(DoxygenEntity(theCommand, aNewList));
@@ -391,7 +391,7 @@ int DoxygenParser::addCommandWordParagraph(const std::string &theCommand,
int DoxygenParser::addCommandWordLine(const std::string &theCommand,
const TokenList & tokList,
- std::list < DoxygenEntity > &doxyList) {
+ DoxygenEntityList &doxyList) {
if (noisy)
cout << "Parsing " << theCommand << endl;
std::string name = getNextWord(tokList);
@@ -401,7 +401,7 @@ int DoxygenParser::addCommandWordLine(const std::string &theCommand,
}
TokenListCIt endOfLine = getOneLine(tokList);
- std::list < DoxygenEntity > aNewList;
+ DoxygenEntityList aNewList;
aNewList = parse(endOfLine, tokList);
aNewList.push_front(DoxygenEntity("plainstd::string", name));
doxyList.push_back(DoxygenEntity(theCommand, aNewList));
@@ -411,7 +411,7 @@ int DoxygenParser::addCommandWordLine(const std::string &theCommand,
int DoxygenParser::addCommandWordOWordOWord(const std::string &theCommand,
const TokenList &tokList,
- std::list < DoxygenEntity > &doxyList) {
+ DoxygenEntityList &doxyList) {
if (noisy)
cout << "Parsing " << theCommand << endl;
@@ -422,7 +422,7 @@ int DoxygenParser::addCommandWordOWordOWord(const std::string &theCommand,
}
std::string headerfile = getNextWord(tokList);
std::string headername = getNextWord(tokList);
- std::list < DoxygenEntity > aNewList;
+ DoxygenEntityList aNewList;
aNewList.push_back(DoxygenEntity("plainstd::string", name));
if (!headerfile.empty())
aNewList.push_back(DoxygenEntity("plainstd::string", headerfile));
@@ -435,12 +435,12 @@ int DoxygenParser::addCommandWordOWordOWord(const std::string &theCommand,
int DoxygenParser::addCommandOWord(const std::string &theCommand,
const TokenList &tokList,
- std::list < DoxygenEntity > &doxyList) {
+ DoxygenEntityList &doxyList) {
if (noisy)
cout << "Parsing " << theCommand << endl;
std::string name = getNextWord(tokList);
- std::list < DoxygenEntity > aNewList;
+ DoxygenEntityList aNewList;
aNewList.push_back(DoxygenEntity("plainstd::string", name));
doxyList.push_back(DoxygenEntity(theCommand, aNewList));
return 1;
@@ -449,7 +449,7 @@ int DoxygenParser::addCommandOWord(const std::string &theCommand,
int DoxygenParser::addCommandErrorThrow(const std::string &theCommand,
const TokenList &tokList,
- std::list < DoxygenEntity > &) {
+ DoxygenEntityList &) {
printListError(WARN_DOXYGEN_COMMAND_ERROR, "Encountered: " + theCommand +
"\nThis command should not have been encountered. Behaviour past this may be unpredictable");
@@ -460,13 +460,13 @@ int DoxygenParser::addCommandErrorThrow(const std::string &theCommand,
int DoxygenParser::addCommandUnique(const std::string &theCommand,
const TokenList &tokList,
- std::list < DoxygenEntity > &doxyList) {
+ DoxygenEntityList &doxyList) {
static std::map<std::string, std::string> endCommands;
- std::list < DoxygenEntity > aNewList;
+ DoxygenEntityList aNewList;
if (theCommand == "arg" || theCommand == "li") {
TokenListCIt endOfSection = getEndOfSection(theCommand, tokList);
- std::list < DoxygenEntity > aNewList;
+ DoxygenEntityList aNewList;
aNewList = parse(endOfSection, tokList);
doxyList.push_back(DoxygenEntity(theCommand, aNewList));
}
@@ -514,7 +514,7 @@ int DoxygenParser::addCommandUnique(const std::string &theCommand,
else if (theCommand == "par") {
TokenListCIt endOfLine = getOneLine(tokList);
aNewList = parse(endOfLine, tokList);
- std::list < DoxygenEntity > aNewList2;
+ DoxygenEntityList aNewList2;
TokenListCIt endOfParagraph = getEndOfParagraph(tokList);
aNewList2 = parse(endOfParagraph, tokList);
aNewList.splice(aNewList.end(), aNewList2);
@@ -523,7 +523,7 @@ int DoxygenParser::addCommandUnique(const std::string &theCommand,
}
// \headerfile <header-file> [<header-name>]
else if (theCommand == "headerfile") {
- std::list < DoxygenEntity > aNewList;
+ DoxygenEntityList aNewList;
std::string name = getNextWord(tokList);
aNewList.push_back(DoxygenEntity("plainstd::string", name));
name = getNextWord(tokList);
@@ -536,7 +536,7 @@ int DoxygenParser::addCommandUnique(const std::string &theCommand,
else if (theCommand == "overload") {
TokenListCIt endOfLine = getOneLine(tokList);
if (endOfLine != m_tokenListIt) {
- std::list < DoxygenEntity > aNewList;
+ DoxygenEntityList aNewList;
aNewList = parse(endOfLine, tokList);
doxyList.push_back(DoxygenEntity(theCommand, aNewList));
} else
@@ -552,7 +552,7 @@ int DoxygenParser::addCommandUnique(const std::string &theCommand,
printListError(WARN_DOXYGEN_COMMAND_ERROR, "No word followed " + theCommand + " command. Not added");
return 0;
}
- std::list < DoxygenEntity > aNewList;
+ DoxygenEntityList aNewList;
TokenListCIt endOfLine = getOneLine(tokList);
if (endOfLine != m_tokenListIt) {
aNewList = parse(endOfLine, tokList);
@@ -656,7 +656,7 @@ int DoxygenParser::addCommandUnique(const std::string &theCommand,
std::string caption = getNextWord(tokList);
std::string size = getNextWord(tokList);
- std::list < DoxygenEntity > aNewList;
+ DoxygenEntityList aNewList;
aNewList.push_back(DoxygenEntity("plainstd::string", format));
aNewList.push_back(DoxygenEntity("plainstd::string", file));
if (!caption.empty())
@@ -674,7 +674,7 @@ int DoxygenParser::addCommandUnique(const std::string &theCommand,
printListError(WARN_DOXYGEN_COMMAND_ERROR, "No word followed " + theCommand + " command. Not added");
return 0;
}
- std::list < DoxygenEntity > aNewList;
+ DoxygenEntityList aNewList;
TokenListCIt endOfLine = getOneLine(tokList);
if (endOfLine != m_tokenListIt) {
aNewList = parse(endOfLine, tokList);
@@ -726,7 +726,7 @@ int DoxygenParser::addCommandUnique(const std::string &theCommand,
return 0;
}
- std::list < DoxygenEntity > aNewList;
+ DoxygenEntityList aNewList;
aNewList = parse(endCommand, tokList);
if (skipEndif)
m_tokenListIt++;
@@ -740,7 +740,7 @@ int DoxygenParser::addCommandUnique(const std::string &theCommand,
int DoxygenParser::addCommand(const std::string &commandString,
const TokenList &tokList,
- std::list < DoxygenEntity > &doxyList) {
+ DoxygenEntityList &doxyList) {
std::string theCommand = stringToLower(commandString);
if (theCommand == "plainstd::string") {
@@ -778,12 +778,12 @@ int DoxygenParser::addCommand(const std::string &commandString,
}
-std::list < DoxygenEntity > DoxygenParser::parse(TokenListCIt endParsingIndex,
+DoxygenEntityList DoxygenParser::parse(TokenListCIt endParsingIndex,
const TokenList &tokList,
bool root) {
// if we are root, than any strings should be added as 'partofdescription', else as 'plainstd::string'
std::string currPlainstringCommandType = root ? "partofdescription" : "plainstd::string";
- std::list < DoxygenEntity > aNewList;
+ DoxygenEntityList aNewList;
while (m_tokenListIt != endParsingIndex) {
@@ -812,13 +812,13 @@ std::list < DoxygenEntity > DoxygenParser::parse(TokenListCIt endParsingIndex,
}
-std::list < DoxygenEntity > DoxygenParser::createTree(const std::string &doxygenBlob, const std::string &fileName, int lineNumber) {
+DoxygenEntityList DoxygenParser::createTree(const std::string &doxygenBlob, const std::string &fileName, int lineNumber) {
TokenList tokList = tokenizeDoxygenComment(doxygenBlob, fileName, lineNumber);
if (noisy) {
cout << "---TOKEN LIST---" << endl;
printList();
}
- std::list < DoxygenEntity > rootList;
+ DoxygenEntityList rootList;
rootList = parse(tokList.end(), tokList, true);
if (noisy) {
cout << "PARSED LIST" << endl;
@@ -856,7 +856,7 @@ DoxygenParser::TokenList DoxygenParser::tokenizeDoxygenComment(const std::string
pos++;
}
// also strip the command till the first nonalpha char
- for (int i = 2; i < currentWord.size(); i++) {
+ for (size_t i = 2; i < currentWord.size(); i++) {
if (!isalpha(currentWord[i])) {
currentWord = currentWord.substr(0, i);
// set current parsing pos back, to parse the rest of the command
diff --git a/Source/DoxygenTranslator/src/DoxygenParser.h b/Source/DoxygenTranslator/src/DoxygenParser.h
index 2dea05f6e..d015c1896 100644
--- a/Source/DoxygenTranslator/src/DoxygenParser.h
+++ b/Source/DoxygenTranslator/src/DoxygenParser.h
@@ -23,7 +23,6 @@ private:
/** This class contains parts of Doxygen comment as a token. */
class Token {
public:
- // typedef enum {COMMAND, PLAINSTRING, END_LINE, PARAGRAPH_END} ETokenType;
DoxyCommandEnum m_tokenType;
std::string m_tokenString; /* the data , such as param for @param */
@@ -132,9 +131,9 @@ private:
TokenListCIt getEndOfParagraph(const TokenList &tokList);
/*
- * Returns the end of a section, defined as the first blank line OR first encounter of the same
- * command. Example of this behaviour is \arg
- * if no end is encountered, returns the last token of the std::list.
+ * Returns the end of a section, defined as the first blank line OR first
+ * encounter of the same command. Example of this behaviour is \arg.
+ * If no end is encountered, returns the last token of the std::list.
*/
TokenListCIt getEndOfSection(const std::string &theCommand,
const TokenList &tokList);
@@ -149,7 +148,8 @@ private:
TokenListCIt getEndCommand(const std::string &theCommand,
const TokenList &tokList);
/*
- * A specialty method for commands such as \arg that end at the end of a paragraph OR when another \arg is encountered
+ * A special method for commands such as \arg that end at the end of a
+ * paragraph OR when another \arg is encountered
//TODO getTilAnyCommand
TokenListCIt getTilAnyCommand(const std::string &theCommand,
const TokenList &tokList);
@@ -162,47 +162,51 @@ private:
* \n \\ \@ \& \$ \# \< \> \%
*/
int addSimpleCommand(const std::string &theCommand,
- std::list < DoxygenEntity > &doxyList);
+ DoxygenEntityList &doxyList);
/*
* CommandWord
* Format: @command <word>
* Commands with a single WORD after then such as @b
* "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package",
- * "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno"
+ * "relates", "namespace", "relatesalso","anchor", "dontinclude", "include",
+ * "includelineno"
*/
int addCommandWord(const std::string &theCommand,
const TokenList &tokList,
- std::list < DoxygenEntity > &doxyList);
+ DoxygenEntityList &doxyList);
/*
* CommandLine
* Format: @command (line)
* Commands with a single LINE after then such as @var
- * "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property"
+ * "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip",
+ * "until", "property"
*/
int addCommandLine(const std::string &theCommand,
const TokenList &tokList,
- std::list < DoxygenEntity > &doxyList);
+ DoxygenEntityList &doxyList);
/*
* CommandParagraph
* Format: @command {paragraph}
* Commands with a single paragraph after then such as @return
- * "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant",
- * "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "arg", "author"
+ * "return", "remarks", "since", "test", "sa", "see", "pre", "post",
+ * "details", "invariant", "deprecated", "date", "note", "warning",
+ * "version", "todo", "bug", "attention", "brief", "arg", "author"
*/
int addCommandParagraph(const std::string &theCommand,
const TokenList &tokList,
- std::list < DoxygenEntity > &doxyList);
+ DoxygenEntityList &doxyList);
/*
* Command EndCommand
* Format: @command and ends at @endcommand
- * Commands that take in a block of text such as @code
- * "code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly",
- * "verbatim", "xmlonly", "cond", "if", "ifnot", "link"
+ * Commands that take in a block of text such as @code:
+ * "code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly",
+ * "latexonly", "manonly", "verbatim", "xmlonly", "cond", "if", "ifnot",
+ * "link"
* Returns 1 if success, 0 if the endcommand is never encountered.
*/
int addCommandEndCommand(const std::string &theCommand,
const TokenList & tokList,
- std::list < DoxygenEntity > &doxyList);
+ DoxygenEntityList &doxyList);
/*
* CommandWordParagraph
* Format: @command <word> {paragraph}
@@ -211,7 +215,7 @@ private:
*/
int addCommandWordParagraph(const std::string &theCommand,
const TokenList & tokList,
- std::list < DoxygenEntity > &doxyList);
+ DoxygenEntityList &doxyList);
/*
* CommandWordLine
* Format: @command <word> (line)
@@ -220,15 +224,16 @@ private:
*/
int addCommandWordLine(const std::string &theCommand,
const TokenList &tokList,
- std::list < DoxygenEntity > &doxyList);
+ DoxygenEntityList &doxyList);
/*
* Command Word Optional Word Optional Word
* Format: @command <word> [<header-file>] [<header-name>]
* Commands such as class
* "category", "class", "protocol", "interface", "struct", "union"
*/
- int addCommandWordOWordOWord(const std::string &theCommand, const TokenList &tokList,
- std::list < DoxygenEntity > &doxyList);
+ int addCommandWordOWordOWord(const std::string &theCommand,
+ const TokenList &tokList,
+ DoxygenEntityList &doxyList);
/*
* Command Optional Word
* Format: @command [<word>]
@@ -237,28 +242,34 @@ private:
*/
int addCommandOWord(const std::string &theCommand,
const TokenList &tokList,
- std::list < DoxygenEntity > &doxyList);
+ DoxygenEntityList &doxyList);
+
/*
* Commands that should not be encountered (such as PHP only)
* goes til the end of line then returns
*/
int addCommandErrorThrow(const std::string &theCommand,
const TokenList &tokList,
- std::list < DoxygenEntity > &doxyList);
+ DoxygenEntityList &doxyList);
+
/*
*Adds the unique commands- different process for each unique command
*/
- int addCommandUnique(const std::string &theCommand, const TokenList &tokList, std::list < DoxygenEntity > &doxyList);
+ int addCommandUnique(const std::string &theCommand,
+ const TokenList &tokList,
+ DoxygenEntityList &doxyList);
+
/*
- * The actual "meat" of the doxygen parser. Calls the correct addCommand* function
+ * The actual "meat" of the doxygen parser. Calls the correct addCommand...()
+ * function.
*/
int addCommand(const std::string &commandString,
const TokenList &tokList,
- std::list < DoxygenEntity > &doxyList);
+ DoxygenEntityList &doxyList);
- std::list < DoxygenEntity > parse(TokenListCIt endParsingIndex,
- const TokenList &tokList,
- bool root = false);
+ DoxygenEntityList parse(TokenListCIt endParsingIndex,
+ const TokenList &tokList,
+ bool root = false);
/*
* Fill static doxygenCommands and sectionIndicators containers
@@ -274,9 +285,9 @@ private:
public:
DoxygenParser(bool noisy = false);
virtual ~DoxygenParser();
- std::list < DoxygenEntity > createTree(const std::string &doxygen,
- const std::string &fileName,
- int lineNumber);
+ DoxygenEntityList createTree(const std::string &doxygen,
+ const std::string &fileName,
+ int lineNumber);
};
#endif
diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp
index d9bf5f059..8175629d1 100644
--- a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp
+++ b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp
@@ -14,16 +14,21 @@
#include "DoxygenTranslator.h"
-DoxygenTranslator::DoxygenTranslator(bool debugTranslator, bool debugParser)
-: debug(debugTranslator), parser(debugParser) {
-}
+DoxygenTranslator::DoxygenTranslator(bool debugTranslator, bool debugParser) :
+ debug(debugTranslator),
+ parser(debugParser)
+{}
+
+
DoxygenTranslator::~DoxygenTranslator() {
}
+
bool DoxygenTranslator::hasDocumentation(Node *node) {
return getDoxygenComment(node);
}
+
String *DoxygenTranslator::getDoxygenComment(Node *node) {
return Getattr(node, "doxygen");
}
@@ -31,16 +36,17 @@ String *DoxygenTranslator::getDoxygenComment(Node *node) {
String *DoxygenTranslator::getDocumentation(Node *node) {
- if (!hasDocumentation(node))
+ if (!hasDocumentation(node)) {
return NewString("");
+ }
return makeDocumentation(node);
}
-void DoxygenTranslator::printTree(std::list < DoxygenEntity > &entityList) {
- std::list < DoxygenEntity >::iterator p = entityList.begin();
- while (p != entityList.end()) {
- (*p).printEntity(0);
- p++;
+
+void DoxygenTranslator::printTree(const DoxygenEntityList &entityList) {
+
+ for (DoxygenEntityListCIt p = entityList.begin(); p != entityList.end(); p++) {
+ p->printEntity(0);
}
}
diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.h b/Source/DoxygenTranslator/src/DoxygenTranslator.h
index f24ad6c86..173bd58f0 100644
--- a/Source/DoxygenTranslator/src/DoxygenTranslator.h
+++ b/Source/DoxygenTranslator/src/DoxygenTranslator.h
@@ -23,8 +23,9 @@
/*
- * A class to translate doxygen comments attached to parser nodes
- * into alternative formats for use in code generated for target languages.
+ * This is a base class for translator classes. It defines the basic interface
+ * for translators, which convert Doxygen comments into alternative formats for
+ * target languages.
*/
class DoxygenTranslator {
public:
@@ -32,41 +33,42 @@ public:
* Constructor
*/
DoxygenTranslator(bool debugTranslator = false, bool debugParser = false);
+
/*
* Virtual destructor.
*/
- virtual ~ DoxygenTranslator();
+ virtual ~DoxygenTranslator();
+
/*
* Return the documentation for a given node formated for the correct
* documentation system.
*/
String *getDocumentation(Node *node);
+
/*
- * Whether the specified node has comment or not
+ * Returns truem is the specified node has comment attached.
*/
bool hasDocumentation(Node *node);
+
/*
- * Get original, Doxygen-format comment string
+ * Get original comment string in Doxygen-format.
*/
String *getDoxygenComment(Node *node);
protected:
bool debug;
+ DoxygenParser parser;
+
/*
- * Overridden in subclasses to return the documentation formatted for a given
- * documentation system.
+ * Returns the documentation formatted for a target language.
*/
virtual String *makeDocumentation(Node *node) = 0;
/*
* Prints the details of a parsed entity list to stdout (for debugging).
*/
- void printTree(std::list < DoxygenEntity > &entityList);
+ void printTree(const DoxygenEntityList &entityList);
- /*
- * Doxygen parser object
- */
- DoxygenParser parser;
};
#endif
diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp
index 20fc175da..171ef4dc7 100644
--- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp
+++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp
@@ -458,7 +458,7 @@ int JavaDocConverter::cleanUpTree(DoxygenEntity &root, int level)
return 0;
int removedCount = 0;
- while (root.entityList.rbegin()->typeOfEntity == "plainstd::endl") {
+ while (!root.entityList.empty() && root.entityList.rbegin()->typeOfEntity == "plainstd::endl") {
root.entityList.pop_back();
removedCount++;
}