Remove "using std" clause and use namespaces properly. Minor refactoring as well.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@10839 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Jamie Kirkpatrick 2008-09-12 11:18:35 +00:00
commit d12b8bc06e
9 changed files with 638 additions and 657 deletions

View file

@ -1,19 +1,24 @@
/* -----------------------------------------------------------------------------
* See the LICENSE file for information on copyright, usage and redistribution
* of SWIG, and the README file for authors - http://www.swig.org/release.html.
*
* python.cxx
*
* Part of the Doxygen comment translation module of SWIG.
* ----------------------------------------------------------------------------- */
#include "DoxygenEntity.h" #include "DoxygenEntity.h"
#include <string>
#include <iostream> #include <iostream>
/* Little data class for Doxygen Commands */
/*
/* Basic node for commands that have * Basic node for commands that have nothing after them (eg: \n)
* nothing after them
* example: \n
*/ */
string commandArray2[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attention", std::string DoxygenEntity::commandArray[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attention",
"author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category",
"class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def",
"defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e",
"else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif", "else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif",
"endlatexonly", "endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", "std::endlatexonly", "std::endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly",
"enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile",
"hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include",
"includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li",
@ -24,19 +29,9 @@ string commandArray2[] = {"a", "addindex", "addtogroup", "anchor", "arg", "atten
"sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage",
"subsection", "subsubsection", "test", "throw", "todo", "tparam", "typedef", "union", "until", "subsection", "subsubsection", "test", "throw", "todo", "tparam", "typedef", "union", "until",
"var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem",
"$", "@", string(1, 92), "&", "~", "<", ">", "#", "%"}; "$", "@", std::string(1, 92), "&", "~", "<", ">", "#", "%"};
string findCommand(int commandNum){ DoxygenEntity::DoxygenEntity(std::string typeEnt){
int arraySize = sizeof(commandArray2)/sizeof(*commandArray2);
if (commandNum - 101 >= 0 && commandNum - 101 < arraySize){
return commandArray2[commandNum - 101];
}
return "" ;
}
DoxygenEntity::DoxygenEntity(string typeEnt){
typeOfEntity = typeEnt; typeOfEntity = typeEnt;
data = ""; data = "";
isLeaf = 1; isLeaf = 1;
@ -45,9 +40,9 @@ DoxygenEntity::DoxygenEntity(string typeEnt){
/* Basic node for commands that have /* Basic node for commands that have
* only 1 thing after them * only 1 thing after them
* example: \b word * example: \b word
* OR holding a string * OR holding a std::string
*/ */
DoxygenEntity::DoxygenEntity(string typeEnt, string param1){ DoxygenEntity::DoxygenEntity(std::string typeEnt, std::string param1){
typeOfEntity = typeEnt; typeOfEntity = typeEnt;
data = param1; data = param1;
isLeaf = 1; isLeaf = 1;
@ -56,26 +51,25 @@ DoxygenEntity::DoxygenEntity(string typeEnt, string param1){
/* Nonterminal node /* Nonterminal node
* contains * contains
*/ */
DoxygenEntity::DoxygenEntity(string typeEnt, list <DoxygenEntity> &entList ){ DoxygenEntity::DoxygenEntity(std::string typeEnt, std::list <DoxygenEntity> &entList ){
typeOfEntity = typeEnt; typeOfEntity = typeEnt;
data = ""; data = "";
isLeaf = 0; isLeaf = 0;
entityList = entList; entityList = entList;
} }
void DoxygenEntity::printEntity(int level){ void DoxygenEntity::printEntity(int level){
int thisLevel = level; int thisLevel = level;
if (isLeaf) { if (isLeaf) {
for (int i = 0; i < thisLevel; i++) {cout << "\t";} for (int i = 0; i < thisLevel; i++) {std::cout << "\t";}
cout << "Node Command: " << typeOfEntity << " "; std::cout << "Node Command: " << typeOfEntity << " ";
if (data.compare("") != 0) cout << "Node Data: " << data; if (data.compare("") != 0) std::cout << "Node Data: " << data;
cout << endl; std::cout << std::endl;
} }
else{ else{
for (int i = 0; i < thisLevel; i++) {cout << "\t";} for (int i = 0; i < thisLevel; i++) {std::cout << "\t";}
cout << "Node Command : " << typeOfEntity << endl; std::cout << "Node Command : " << typeOfEntity << std::endl;
list<DoxygenEntity>::iterator p = entityList.begin(); std::list<DoxygenEntity>::iterator p = entityList.begin();
thisLevel++; thisLevel++;
while (p != entityList.end()){ while (p != entityList.end()){
(*p).printEntity(thisLevel); (*p).printEntity(thisLevel);
@ -84,6 +78,122 @@ void DoxygenEntity::printEntity(int level){
} }
} }
DoxygenEntity::~DoxygenEntity() bool CompareDoxygenEntities::operator()(DoxygenEntity& first, DoxygenEntity& second){
{ 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(first.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;
}

View file

@ -1,37 +1,40 @@
/* -----------------------------------------------------------------------------
* See the LICENSE file for information on copyright, usage and redistribution
* of SWIG, and the README file for authors - http://www.swig.org/release.html.
*
* python.cxx
*
* Part of the Doxygen comment translation module of SWIG.
* ----------------------------------------------------------------------------- */
#ifndef DOXYGENENTITY_H_ #ifndef DOXYGENENTITY_H_
#define DOXYGENENTITY_H_ #define DOXYGENENTITY_H_
#include <string> #include <string>
#include <list> #include <list>
using namespace std; /*
* Structure to represent a doxygen comment entry
class DoxygenEntity{ */
struct DoxygenEntity{
public: DoxygenEntity(std::string typeEnt);
DoxygenEntity(string typeEnt); DoxygenEntity(std::string typeEnt, std::string param1);
DoxygenEntity(string typeEnt, string param1); DoxygenEntity(std::string typeEnt, std::list <DoxygenEntity> &entList );
DoxygenEntity(string typeEnt, list <DoxygenEntity> &entList );
~DoxygenEntity();
void printEntity(int level); void printEntity(int level);
string typeOfEntity; std::string typeOfEntity;
list <DoxygenEntity> entityList; std::list <DoxygenEntity> entityList;
string data; std::string data;
int isLeaf; int isLeaf;
static std::string commandArray[];
}; };
struct find_entity { /*
find_entity(string typeString) { * Functor that sorts entities by javaDoc standard order for commands.
typeOfEntity = typeString; * NOTE: will not behave entirely properly until "First level" comments
} * such as brief descriptions are TAGGED as such
*/
bool operator()(DoxygenEntity& entity) { struct CompareDoxygenEntities {
return entity.typeOfEntity == typeOfEntity; bool operator()(DoxygenEntity& first, DoxygenEntity& second);
}
string typeOfEntity;
}; };
#endif /*TOKENLIST_H_*/ #endif /*TOKENLIST_H_*/

View file

@ -19,8 +19,6 @@
#define PARAGRAPH_END 102 #define PARAGRAPH_END 102
#define PLAINSTRING 103 #define PLAINSTRING 103
#define COMMAND 104 #define COMMAND 104
using namespace std;
DoxygenParser::DoxygenParser() DoxygenParser::DoxygenParser()
{ {
@ -32,13 +30,13 @@ DoxygenParser::~DoxygenParser()
////////////////////////////////////////// //////////////////////////////////////////
int noisy = 0; // set this to 1 for extra chatter from the parsing stage. int noisy = 0; // set this to 1 for extra chatter from the parsing stage.
int addCommand(string currCommand, TokenList &tokList, list <DoxygenEntity> &aNewList); int addCommand(std::string currCommand, TokenList &tokList, std::list <DoxygenEntity> &aNewList);
list <DoxygenEntity> parse(list<Token>::iterator endParsingIndex, TokenList &tokList); std::list <DoxygenEntity> parse(std::list<Token>::iterator endParsingIndex, TokenList &tokList);
////////////////////////////////////////// //////////////////////////////////////////
string commandArray[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attention", std::string commandArray[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attention",
"author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category",
"class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def",
"defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e",
@ -57,49 +55,49 @@ string commandArray[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attent
"$", "@", "\\","&", "~", "<", ">", "#", "%"}; "$", "@", "\\","&", "~", "<", ">", "#", "%"};
string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "date", "deprecated", "details", std::string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "date", "deprecated", "details",
"else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param", "else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param",
"tparam", "post" , "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "todo", "tparam", "post" , "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "todo",
"version", "warning", "xrefitem" }; "version", "warning", "xrefitem" };
/* All of the doxygen commands divided up by how they are parsed */ /* All of the doxygen commands divided up by how they are parsed */
string simpleCommands[] = {"n", "$", "@", "\\", "&", "~", "<", ">", "#", "%"}; std::string simpleCommands[] = {"n", "$", "@", "\\", "&", "~", "<", ">", "#", "%"};
string ignoredSimpleCommands[] = {"nothing at the moment"}; std::string ignoredSimpleCommands[] = {"nothing at the moment"};
string commandWords[] = {"a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", std::string commandWords[] = {"a", "b", "c", "e", "em", "p", "def", "enum", "example", "package",
"relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno"}; "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno"};
string ignoredCommandWords[] = {"copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"}; std::string ignoredCommandWords[] = {"copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"};
string commandLines[] = {"addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property"}; std::string commandLines[] = {"addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property"};
string ignoreCommandLines[] = {"nothing at the moment"}; std::string ignoreCommandLines[] = {"nothing at the moment"};
string commandParagraph[] = {"partofdescription", "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", std::string commandParagraph[] = {"partofdescription", "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant",
"deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "author"}; "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "author"};
string ignoreCommandParagraphs[] = {"nothing at the moment"}; std::string ignoreCommandParagraphs[] = {"nothing at the moment"};
string commandEndCommands[] = {"code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", std::string commandEndCommands[] = {"code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly",
"verbatim", "xmlonly", "cond", "if", "ifnot", "link"}; "verbatim", "xmlonly", "cond", "if", "ifnot", "link"};
string commandWordParagraphs[] = {"param", "tparam", "throw", "retval", "exception"}; std::string commandWordParagraphs[] = {"param", "tparam", "throw", "retval", "exception"};
string commandWordLines[] = {"page", "subsection", "subsubsection", "section", "paragraph", "defgroup"}; std::string commandWordLines[] = {"page", "subsection", "subsubsection", "section", "paragraph", "defgroup"};
string commandWordOWordOWords [] = {"category", "class", "protocol", "interface", "struct", "union"}; std::string commandWordOWordOWords [] = {"category", "class", "protocol", "interface", "struct", "union"};
string commandOWords[] = {"dir", "file", "cond"}; std::string commandOWords[] = {"dir", "file", "cond"};
string commandErrorThrowings[] = {"annotatedclasslist", "classhierarchy", "define", "functionindex", "header", std::string commandErrorThrowings[] = {"annotatedclassstd::list", "classhierarchy", "define", "functionindex", "header",
"headerfilelist", "inherit", "l", "postheader", "private", "privatesection", "protected", "headerfilestd::list", "inherit", "l", "postheader", "private", "privatesection", "protected",
"protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly", "protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly",
"endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endcond", "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endcond",
"endif"}; "endif"};
string commandUniques[] = {"xrefitem", "arg", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", std::string commandUniques[] = {"xrefitem", "arg", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref",
"subpage", "dotfile", "image", "addtogroup", "li"}; "subpage", "dotfile", "image", "addtogroup", "li"};
/* Changes a string to all lower case */ /* Changes a std::string to all lower case */
string StringToLower(string stringToConvert){ std::string StringToLower(std::string stringToConvert){
for(unsigned int i=0;i<stringToConvert.length();i++){ for(unsigned int i=0;i<stringToConvert.length();i++){
stringToConvert[i] = tolower(stringToConvert[i]); stringToConvert[i] = tolower(stringToConvert[i]);
} }
return stringToConvert; //return the converted string return stringToConvert; //return the converted std::string
} }
/* finds out if a command exists (is a possible command) /* finds out if a command exists (is a possible command)
* from the string array commandArray * from the std::string array commandArray
* returns -1 if no match is found */ * returns -1 if no match is found */
int findCommand(string smallString){ int findCommand(std::string smallString){
smallString = StringToLower(smallString); smallString = StringToLower(smallString);
int a; int a;
for (int i = 0; i < sizeof(commandArray)/sizeof(*commandArray); i++){ for (int i = 0; i < sizeof(commandArray)/sizeof(*commandArray); i++){
@ -114,7 +112,7 @@ int findCommand(string smallString){
* This is a helper method for finding the end of a paragraph * This is a helper method for finding the end of a paragraph
* by Doxygen's terms * by Doxygen's terms
*/ */
int isSectionIndicator(string smallString){ int isSectionIndicator(std::string smallString){
smallString = StringToLower(smallString); smallString = StringToLower(smallString);
for (int i = 0; i < sizeof( sectionIndicators)/sizeof(* sectionIndicators); i++){ for (int i = 0; i < sizeof( sectionIndicators)/sizeof(* sectionIndicators); i++){
if( smallString.compare( sectionIndicators[i]) == 0){ if( smallString.compare( sectionIndicators[i]) == 0){
@ -125,8 +123,8 @@ int isSectionIndicator(string smallString){
} }
/* prints the parse tree */ /* prints the parse tree */
void printTree( list <DoxygenEntity> &rootList){ void printTree( std::list <DoxygenEntity> &rootList){
list<DoxygenEntity>::iterator p = rootList.begin(); std::list<DoxygenEntity>::iterator p = rootList.begin();
while (p != rootList.end()){ while (p != rootList.end()){
(*p).printEntity(0); (*p).printEntity(0);
p++; p++;
@ -136,8 +134,8 @@ void printTree( list <DoxygenEntity> &rootList){
/* Determines how a command should be handled (what group it belongs to /* Determines how a command should be handled (what group it belongs to
* for parsing rules * for parsing rules
*/ */
int commandBelongs(string theCommand){ int commandBelongs(std::string theCommand){
string smallString = StringToLower(theCommand); std::string smallString = StringToLower(theCommand);
//cout << " Looking for command " << theCommand << endl; //cout << " Looking for command " << theCommand << endl;
int i = 0; int i = 0;
for ( i = 0; i < sizeof(simpleCommands)/sizeof(*simpleCommands); i++){ for ( i = 0; i < sizeof(simpleCommands)/sizeof(*simpleCommands); i++){
@ -189,10 +187,10 @@ int commandBelongs(string theCommand){
} }
/* Returns the next word ON THE CURRENT LINE ONLY /* Returns the next word ON THE CURRENT LINE ONLY
* if a new line is encountered, returns a blank string. * if a new line is encountered, returns a blank std::string.
* Updates the index it is given if success. * Updates the index it is given if success.
*/ */
string getNextWord(TokenList &tokList){ std::string getNextWord(TokenList &tokList){
Token nextToken = tokList.peek(); Token nextToken = tokList.peek();
if (nextToken.tokenType == PLAINSTRING ){ if (nextToken.tokenType == PLAINSTRING ){
nextToken = tokList.next(); nextToken = tokList.next();
@ -204,8 +202,8 @@ string getNextWord(TokenList &tokList){
/* Returns the location of the end of the line as /* Returns the location of the end of the line as
* an iterator. * an iterator.
*/ */
list<Token>::iterator getOneLine(TokenList &tokList){ std::list<Token>::iterator getOneLine(TokenList &tokList){
list<Token>::iterator endOfLine = tokList.iteratorCopy(); std::list<Token>::iterator endOfLine = tokList.iteratorCopy();
while(endOfLine!= tokList.end()){ while(endOfLine!= tokList.end()){
if ((* endOfLine).tokenType == END_LINE){ if ((* endOfLine).tokenType == END_LINE){
//cout << "REACHED END" << endl; //cout << "REACHED END" << endl;
@ -219,11 +217,11 @@ list<Token>::iterator getOneLine(TokenList &tokList){
return tokList.end(); return tokList.end();
} }
/* Returns a properly formatted string /* Returns a properly formatted std::string
* up til ANY command or end of line is encountered. * up til ANY command or end of line is encountered.
*/ */
string getStringTilCommand(TokenList &tokList){ std::string getStringTilCommand(TokenList &tokList){
string description; std::string description;
if (tokList.peek().tokenType == 0) return ""; if (tokList.peek().tokenType == 0) return "";
while(tokList.peek().tokenType == PLAINSTRING){ while(tokList.peek().tokenType == PLAINSTRING){
Token currentToken = tokList.next(); Token currentToken = tokList.next();
@ -234,13 +232,13 @@ string getStringTilCommand(TokenList &tokList){
return description; return description;
} }
/* Returns a properly formatted string /* Returns a properly formatted std::string
* up til the command specified is encountered * up til the command specified is encountered
*/ */
//TODO check that this behaves properly for formulas //TODO check that this behaves properly for formulas
string getStringTilEndCommand(string theCommand, TokenList &tokList){ std::string getStringTilEndCommand(std::string theCommand, TokenList &tokList){
string description; std::string description;
if (tokList.peek().tokenType == 0) return ""; if (tokList.peek().tokenType == 0) return "";
while(tokList.peek().tokenString.compare(theCommand) != 0 ){ while(tokList.peek().tokenString.compare(theCommand) != 0 ){
Token currentToken = tokList.next(); Token currentToken = tokList.next();
@ -253,8 +251,8 @@ string getStringTilEndCommand(string theCommand, TokenList &tokList){
* Paragraph is defined in Doxygen to be a paragraph of text * Paragraph is defined in Doxygen to be a paragraph of text
* seperate by either a structural command or a blank line * seperate by either a structural command or a blank line
*/ */
list<Token>::iterator getEndOfParagraph(TokenList &tokList){ std::list<Token>::iterator getEndOfParagraph(TokenList &tokList){
list<Token>::iterator endOfParagraph = tokList.iteratorCopy(); std::list<Token>::iterator endOfParagraph = tokList.iteratorCopy();
while(endOfParagraph != tokList.end()){ while(endOfParagraph != tokList.end()){
if ((* endOfParagraph).tokenType == END_LINE){ if ((* endOfParagraph).tokenType == END_LINE){
endOfParagraph++; endOfParagraph++;
@ -278,10 +276,10 @@ list<Token>::iterator getEndOfParagraph(TokenList &tokList){
/* Returns the end of a section, defined as the first blank line OR first encounter of the same /* 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 * command. Example of this behaviour is \arg
* if no end is encountered, returns the last token of the list. * if no end is encountered, returns the last token of the std::list.
*/ */
list<Token>::iterator getEndOfSection(string theCommand, TokenList &tokList){ std::list<Token>::iterator getEndOfSection(std::string theCommand, TokenList &tokList){
list<Token>::iterator endOfParagraph = tokList.iteratorCopy(); std::list<Token>::iterator endOfParagraph = tokList.iteratorCopy();
while(endOfParagraph != tokList.end()){ while(endOfParagraph != tokList.end()){
if ((* endOfParagraph).tokenType == COMMAND){ if ((* endOfParagraph).tokenType == COMMAND){
if(theCommand.compare((*endOfParagraph).tokenString) == 0) return endOfParagraph; if(theCommand.compare((*endOfParagraph).tokenString) == 0) return endOfParagraph;
@ -305,10 +303,10 @@ list<Token>::iterator getEndOfSection(string theCommand, TokenList &tokList){
* that begins with a \command and ends in \endcommand * that begins with a \command and ends in \endcommand
* such as \code and \endcode. The proper usage is * such as \code and \endcode. The proper usage is
* progressTilEndCommand("endcode", tokenList); * progressTilEndCommand("endcode", tokenList);
* If the end is never encountered, it returns the end of the list. * If the end is never encountered, it returns the end of the std::list.
*/ */
list<Token>::iterator getEndCommand(string theCommand, TokenList &tokList){ std::list<Token>::iterator getEndCommand(std::string theCommand, TokenList &tokList){
list<Token>::iterator endOfCommand = tokList.iteratorCopy(); std::list<Token>::iterator endOfCommand = tokList.iteratorCopy();
while (endOfCommand!= tokList.end()){ while (endOfCommand!= tokList.end()){
if ((*endOfCommand).tokenType == COMMAND){ if ((*endOfCommand).tokenType == COMMAND){
if (theCommand.compare((* endOfCommand).tokenString) == 0){ if (theCommand.compare((* endOfCommand).tokenString) == 0){
@ -324,8 +322,8 @@ list<Token>::iterator getEndCommand(string theCommand, 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 specialty method for commands such as \arg that end at the end of a paragraph OR when another \arg is encountered
*/ */
//TODO getTilAnyCommand //TODO getTilAnyCommand
list<Token>::iterator getTilAnyCommand(string theCommand, TokenList &tokList){ std::list<Token>::iterator getTilAnyCommand(std::string theCommand, TokenList &tokList){
list<Token>::iterator anIterator; std::list<Token>::iterator anIterator;
return anIterator; return anIterator;
} }
@ -337,7 +335,7 @@ list<Token>::iterator getTilAnyCommand(string theCommand, TokenList &tokList){
* Plain commands, such as newline etc, they contain no other data * Plain commands, such as newline etc, they contain no other data
* \n \\ \@ \& \$ \# \< \> \% * \n \\ \@ \& \$ \# \< \> \%
*/ */
int addSimpleCommand(string theCommand, list <DoxygenEntity> &doxyList){ int addSimpleCommand(std::string theCommand, std::list <DoxygenEntity> &doxyList){
if (noisy) cout << "Parsing " << theCommand << endl; if (noisy) cout << "Parsing " << theCommand << endl;
doxyList.push_back(DoxygenEntity(theCommand)); doxyList.push_back(DoxygenEntity(theCommand));
return 1; return 1;
@ -347,7 +345,7 @@ list<Token>::iterator getTilAnyCommand(string theCommand, TokenList &tokList){
* Format: @command * Format: @command
* Plain commands, such as newline etc, they contain no other data * Plain commands, such as newline etc, they contain no other data
*/ */
int ignoreSimpleCommand(string theCommand, list <DoxygenEntity> &doxyList){ int ignoreSimpleCommand(std::string theCommand, std::list <DoxygenEntity> &doxyList){
if (noisy) cout << "Not Adding " << theCommand << endl; if (noisy) cout << "Not Adding " << theCommand << endl;
return 1; return 1;
} }
@ -358,9 +356,9 @@ list<Token>::iterator getTilAnyCommand(string theCommand, TokenList &tokList){
* "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", * "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(string theCommand, TokenList &tokList, list <DoxygenEntity> &doxyList){ int addCommandWord(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){
if (noisy) cout << "Parsing " << theCommand << endl; if (noisy) cout << "Parsing " << theCommand << endl;
string name = getNextWord(tokList); std::string name = getNextWord(tokList);
if (!name.empty()){ if (!name.empty()){
doxyList.push_back(DoxygenEntity(theCommand, name)); doxyList.push_back(DoxygenEntity(theCommand, name));
return 1; return 1;
@ -374,9 +372,9 @@ list<Token>::iterator getTilAnyCommand(string theCommand, TokenList &tokList){
* Commands with a single WORD after then such as @b * Commands with a single WORD after then such as @b
* "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude" * "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"
*/ */
int ignoreCommandWord(string theCommand, TokenList &tokList, list <DoxygenEntity> &doxyList){ int ignoreCommandWord(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){
if (noisy) cout << "Not Adding " << theCommand << endl; if (noisy) cout << "Not Adding " << theCommand << endl;
string name = getNextWord(tokList); std::string name = getNextWord(tokList);
if (!name.empty()){ if (!name.empty()){
return 1; return 1;
} }
@ -389,10 +387,10 @@ list<Token>::iterator getTilAnyCommand(string theCommand, TokenList &tokList){
* Commands with a single LINE after then such as @var * 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(string theCommand, TokenList &tokList, list <DoxygenEntity> &doxyList){ int addCommandLine(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){
if (noisy) cout << "Parsing " << theCommand << endl; if (noisy) cout << "Parsing " << theCommand << endl;
list<Token>::iterator endOfLine = getOneLine(tokList); std::list<Token>::iterator endOfLine = getOneLine(tokList);
list <DoxygenEntity> aNewList; std::list <DoxygenEntity> aNewList;
aNewList = parse(endOfLine, tokList); aNewList = parse(endOfLine, tokList);
doxyList.push_back( DoxygenEntity(theCommand, aNewList)); doxyList.push_back( DoxygenEntity(theCommand, aNewList));
return 1; return 1;
@ -403,9 +401,9 @@ list<Token>::iterator getTilAnyCommand(string theCommand, TokenList &tokList){
* Commands with a single LINE after then such as @var * Commands with a single LINE after then such as @var
* *
*/ */
int ignoreCommandLine(string theCommand, TokenList &tokList, list <DoxygenEntity> &doxyList){ int ignoreCommandLine(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){
if (noisy) cout << "Not Adding " << theCommand << endl; if (noisy) cout << "Not Adding " << theCommand << endl;
list<Token>::iterator endOfLine = getOneLine(tokList); std::list<Token>::iterator endOfLine = getOneLine(tokList);
tokList.setIterator(endOfLine); tokList.setIterator(endOfLine);
return 1; return 1;
} }
@ -416,10 +414,10 @@ list<Token>::iterator getTilAnyCommand(string theCommand, TokenList &tokList){
* "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", * "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant",
* "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "arg", "author" * "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "arg", "author"
*/ */
int addCommandParagraph(string theCommand, TokenList &tokList, list <DoxygenEntity> &doxyList){ int addCommandParagraph(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){
if (noisy) cout << "Parsing " << theCommand << endl; if (noisy) cout << "Parsing " << theCommand << endl;
list<Token>::iterator endOfParagraph = getEndOfParagraph(tokList); std::list<Token>::iterator endOfParagraph = getEndOfParagraph(tokList);
list <DoxygenEntity> aNewList; std::list <DoxygenEntity> aNewList;
aNewList = parse(endOfParagraph, tokList); aNewList = parse(endOfParagraph, tokList);
doxyList.push_back( DoxygenEntity(theCommand, aNewList)); doxyList.push_back( DoxygenEntity(theCommand, aNewList));
return 1; return 1;
@ -430,9 +428,9 @@ list<Token>::iterator getTilAnyCommand(string theCommand, TokenList &tokList){
* Commands with a single LINE after then such as @var * Commands with a single LINE after then such as @var
* *
*/ */
int ignoreCommandParagraph(string theCommand, TokenList &tokList, list <DoxygenEntity> &doxyList){ int ignoreCommandParagraph(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){
if (noisy) cout << "Not Adding " << theCommand << endl; if (noisy) cout << "Not Adding " << theCommand << endl;
list<Token>::iterator endOfParagraph = getEndOfParagraph(tokList); std::list<Token>::iterator endOfParagraph = getEndOfParagraph(tokList);
tokList.setIterator(endOfParagraph); tokList.setIterator(endOfParagraph);
return 1; return 1;
} }
@ -444,9 +442,9 @@ list<Token>::iterator getTilAnyCommand(string theCommand, TokenList &tokList){
* "verbatim", "xmlonly", "cond", "if", "ifnot", "link" * "verbatim", "xmlonly", "cond", "if", "ifnot", "link"
* Returns 1 if success, 0 if the endcommand is never encountered. * Returns 1 if success, 0 if the endcommand is never encountered.
*/ */
int addCommandEndCommand(string theCommand, TokenList &tokList, list <DoxygenEntity> &doxyList){ int addCommandEndCommand(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){
if (noisy) cout << "Not Adding " << theCommand << endl; if (noisy) cout << "Not Adding " << theCommand << endl;
string description = getStringTilEndCommand( "end" + theCommand, tokList); std::string description = getStringTilEndCommand( "end" + theCommand, tokList);
doxyList.push_back(DoxygenEntity(theCommand, description)); doxyList.push_back(DoxygenEntity(theCommand, description));
return 1; return 1;
} }
@ -456,17 +454,17 @@ list<Token>::iterator getTilAnyCommand(string theCommand, TokenList &tokList){
* Commands such as param * Commands such as param
* "param", "tparam", "throw", "retval", "exception" * "param", "tparam", "throw", "retval", "exception"
*/ */
int addCommandWordParagraph(string theCommand, TokenList &tokList, list <DoxygenEntity> &doxyList){ int addCommandWordParagraph(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){
if (noisy) cout << "Parsing " << theCommand << endl; if (noisy) cout << "Parsing " << theCommand << endl;
string name = getNextWord(tokList); std::string name = getNextWord(tokList);
if (name.empty()){ if (name.empty()){
cout << "No word followed " << theCommand << " command. Not added" << endl; cout << "No word followed " << theCommand << " command. Not added" << endl;
return 0; return 0;
} }
list<Token>::iterator endOfParagraph = getEndOfParagraph(tokList); std::list<Token>::iterator endOfParagraph = getEndOfParagraph(tokList);
list <DoxygenEntity> aNewList; std::list <DoxygenEntity> aNewList;
aNewList = parse(endOfParagraph, tokList); aNewList = parse(endOfParagraph, tokList);
aNewList.push_front(DoxygenEntity("plainstring", name)); aNewList.push_front(DoxygenEntity("plainstd::string", name));
doxyList.push_back(DoxygenEntity(theCommand, aNewList)); doxyList.push_back(DoxygenEntity(theCommand, aNewList));
return 1; return 1;
} }
@ -476,17 +474,17 @@ list<Token>::iterator getTilAnyCommand(string theCommand, TokenList &tokList){
* Commands such as param * Commands such as param
* "page", "subsection", "subsubsection", "section", "paragraph", "defgroup" * "page", "subsection", "subsubsection", "section", "paragraph", "defgroup"
*/ */
int addCommandWordLine(string theCommand, TokenList &tokList, list <DoxygenEntity> &doxyList){ int addCommandWordLine(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){
if (noisy) cout << "Parsing " << theCommand << endl; if (noisy) cout << "Parsing " << theCommand << endl;
string name = getNextWord(tokList); std::string name = getNextWord(tokList);
if (name.empty()){ if (name.empty()){
cout << "No word followed " << theCommand << " command. Not added" << endl; cout << "No word followed " << theCommand << " command. Not added" << endl;
return 0; return 0;
} }
list<Token>::iterator endOfLine = getOneLine(tokList); std::list<Token>::iterator endOfLine = getOneLine(tokList);
list <DoxygenEntity> aNewList; std::list <DoxygenEntity> aNewList;
aNewList = parse(endOfLine, tokList); aNewList = parse(endOfLine, tokList);
aNewList.push_front(DoxygenEntity("plainstring", name)); aNewList.push_front(DoxygenEntity("plainstd::string", name));
doxyList.push_back(DoxygenEntity(theCommand, aNewList)); doxyList.push_back(DoxygenEntity(theCommand, aNewList));
return 1; return 1;
@ -498,19 +496,19 @@ list<Token>::iterator getTilAnyCommand(string theCommand, TokenList &tokList){
* Commands such as class * Commands such as class
* "category", "class", "protocol", "interface", "struct", "union" * "category", "class", "protocol", "interface", "struct", "union"
*/ */
int addCommandWordOWordOWord(string theCommand, TokenList &tokList, list <DoxygenEntity> &doxyList){ int addCommandWordOWordOWord(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){
if (noisy) cout << "Parsing " << theCommand << endl; if (noisy) cout << "Parsing " << theCommand << endl;
string name = getNextWord(tokList); std::string name = getNextWord(tokList);
if (name.empty()){ if (name.empty()){
cout << "No word followed " << theCommand << " command. Not added" << endl; cout << "No word followed " << theCommand << " command. Not added" << endl;
return 0; return 0;
} }
string headerfile = getNextWord(tokList); std::string headerfile = getNextWord(tokList);
string headername = getNextWord(tokList); std::string headername = getNextWord(tokList);
list <DoxygenEntity> aNewList; std::list <DoxygenEntity> aNewList;
aNewList.push_back(DoxygenEntity("plainstring", name)); aNewList.push_back(DoxygenEntity("plainstd::string", name));
if (!headerfile.empty()) aNewList.push_back(DoxygenEntity("plainstring", headerfile)); if (!headerfile.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", headerfile));
if (!headername.empty()) aNewList.push_back(DoxygenEntity("plainstring", headername)); if (!headername.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", headername));
doxyList.push_back(DoxygenEntity(theCommand, aNewList)); doxyList.push_back(DoxygenEntity(theCommand, aNewList));
return 1; return 1;
} }
@ -520,9 +518,9 @@ list<Token>::iterator getTilAnyCommand(string theCommand, TokenList &tokList){
* Commands such as dir * Commands such as dir
* "dir", "file", "cond" * "dir", "file", "cond"
*/ */
int addCommandOWord(string theCommand, TokenList &tokList, list <DoxygenEntity> &doxyList){ int addCommandOWord(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){
if (noisy) cout << "Parsing " << theCommand << endl; if (noisy) cout << "Parsing " << theCommand << endl;
string name = getNextWord(tokList); std::string name = getNextWord(tokList);
doxyList.push_back(DoxygenEntity(theCommand, name)); doxyList.push_back(DoxygenEntity(theCommand, name));
return 1; return 1;
} }
@ -530,47 +528,47 @@ list<Token>::iterator getTilAnyCommand(string theCommand, TokenList &tokList){
/* Commands that should not be encountered (such as PHP only) /* Commands that should not be encountered (such as PHP only)
* goes til the end of line then returns * goes til the end of line then returns
*/ */
int addCommandErrorThrow(string theCommand, TokenList &tokList, list <DoxygenEntity> &doxyList){ int addCommandErrorThrow(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){
cout << "Encountered :" << theCommand << endl; cout << "Encountered :" << theCommand << endl;
cout << "This command should not have been encountered. Behaviour past this may be unpredictable " << endl; cout << "This command should not have been encountered. Behaviour past this may be unpredictable " << endl;
list<Token>::iterator endOfLine = getOneLine(tokList); std::list<Token>::iterator endOfLine = getOneLine(tokList);
tokList.setIterator(endOfLine); tokList.setIterator(endOfLine);
return 0; return 0;
} }
/* Adds the unique commands- different process for each unique command */ /* Adds the unique commands- different process for each unique command */
int addCommandUnique(string theCommand, TokenList &tokList, list <DoxygenEntity> &doxyList){ int addCommandUnique(std::string theCommand, TokenList &tokList, std::list <DoxygenEntity> &doxyList){
list <DoxygenEntity> aNewList; std::list <DoxygenEntity> aNewList;
if (theCommand.compare("arg") == 0 || theCommand.compare("li") == 0){ if (theCommand.compare("arg") == 0 || theCommand.compare("li") == 0){
list<Token>::iterator endOfSection = getEndOfSection(theCommand, tokList); std::list<Token>::iterator endOfSection = getEndOfSection(theCommand, tokList);
list <DoxygenEntity> aNewList; std::list <DoxygenEntity> aNewList;
aNewList = parse(endOfSection, tokList); aNewList = parse(endOfSection, tokList);
doxyList.push_back( DoxygenEntity(theCommand, aNewList)); doxyList.push_back( DoxygenEntity(theCommand, aNewList));
} }
// \xrefitem <key> "(heading)" "(list title)" {text} // \xrefitem <key> "(heading)" "(std::list title)" {text}
else if (theCommand.compare("xrefitem") == 0){ else if (theCommand.compare("xrefitem") == 0){
//TODO Implement xrefitem //TODO Implement xrefitem
if (noisy) cout << "Not Adding " << theCommand << endl; if (noisy) cout << "Not Adding " << theCommand << endl;
list<Token>::iterator endOfParagraph = getEndOfParagraph(tokList); std::list<Token>::iterator endOfParagraph = getEndOfParagraph(tokList);
tokList.setIterator(endOfParagraph); tokList.setIterator(endOfParagraph);
return 1; return 1;
} }
// \ingroup (<groupname> [<groupname> <groupname>]) // \ingroup (<groupname> [<groupname> <groupname>])
else if (theCommand.compare("ingroup") == 0){ else if (theCommand.compare("ingroup") == 0){
string name = getNextWord(tokList); std::string name = getNextWord(tokList);
aNewList.push_back(DoxygenEntity("plainstring", name)); aNewList.push_back(DoxygenEntity("plainstd::string", name));
name = getNextWord(tokList); name = getNextWord(tokList);
if(!name.empty()) aNewList.push_back(DoxygenEntity("plainstring", name)); if(!name.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", name));
name = getNextWord(tokList); name = getNextWord(tokList);
if(!name.empty()) aNewList.push_back(DoxygenEntity("plainstring", name)); if(!name.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", name));
doxyList.push_back(DoxygenEntity(theCommand, aNewList)); doxyList.push_back(DoxygenEntity(theCommand, aNewList));
return 1; return 1;
} }
// \par [(paragraph title)] { paragraph } // \par [(paragraph title)] { paragraph }
else if (theCommand.compare("par") == 0){ else if (theCommand.compare("par") == 0){
list<Token>::iterator endOfLine = getOneLine(tokList); std::list<Token>::iterator endOfLine = getOneLine(tokList);
aNewList = parse(endOfLine, tokList); aNewList = parse(endOfLine, tokList);
list <DoxygenEntity> aNewList2; std::list <DoxygenEntity> aNewList2;
aNewList2 = parse(endOfLine, tokList); aNewList2 = parse(endOfLine, tokList);
aNewList.splice(aNewList.end(), aNewList2); aNewList.splice(aNewList.end(), aNewList2);
doxyList.push_back(DoxygenEntity(theCommand, aNewList)); doxyList.push_back(DoxygenEntity(theCommand, aNewList));
@ -578,19 +576,19 @@ list<Token>::iterator getTilAnyCommand(string theCommand, TokenList &tokList){
} }
// \headerfile <header-file> [<header-name>] // \headerfile <header-file> [<header-name>]
else if (theCommand.compare("headerfile") == 0){ else if (theCommand.compare("headerfile") == 0){
list <DoxygenEntity> aNewList; std::list <DoxygenEntity> aNewList;
string name = getNextWord(tokList); std::string name = getNextWord(tokList);
aNewList.push_back(DoxygenEntity("plainstring", name)); aNewList.push_back(DoxygenEntity("plainstd::string", name));
name = getNextWord(tokList); name = getNextWord(tokList);
if(!name.empty()) aNewList.push_back(DoxygenEntity("plainstring", name)); if(!name.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", name));
doxyList.push_back(DoxygenEntity(theCommand, aNewList)); doxyList.push_back(DoxygenEntity(theCommand, aNewList));
return 1; return 1;
} }
// \overload [(function declaration)] // \overload [(function declaration)]
else if (theCommand.compare("overload") == 0){ else if (theCommand.compare("overload") == 0){
list<Token>::iterator endOfLine = getOneLine(tokList); std::list<Token>::iterator endOfLine = getOneLine(tokList);
if (endOfLine != tokList.current()){ if (endOfLine != tokList.current()){
list <DoxygenEntity> aNewList; std::list <DoxygenEntity> aNewList;
aNewList = parse(endOfLine, tokList); aNewList = parse(endOfLine, tokList);
doxyList.push_back(DoxygenEntity(theCommand, aNewList)); doxyList.push_back(DoxygenEntity(theCommand, aNewList));
} }
@ -600,38 +598,38 @@ list<Token>::iterator getTilAnyCommand(string theCommand, TokenList &tokList){
// \weakgroup <name> [(title)] // \weakgroup <name> [(title)]
else if (theCommand.compare("weakgroup") == 0){ else if (theCommand.compare("weakgroup") == 0){
if (noisy) cout << "Parsing " << theCommand << endl; if (noisy) cout << "Parsing " << theCommand << endl;
string name = getNextWord(tokList); std::string name = getNextWord(tokList);
if (name.empty()){ if (name.empty()){
cout << "No word followed " << theCommand << " command. Not added" << endl; cout << "No word followed " << theCommand << " command. Not added" << endl;
return 0; return 0;
} }
list <DoxygenEntity> aNewList; std::list <DoxygenEntity> aNewList;
list<Token>::iterator endOfLine = getOneLine(tokList); std::list<Token>::iterator endOfLine = getOneLine(tokList);
if (endOfLine != tokList.current()) { if (endOfLine != tokList.current()) {
aNewList = parse(endOfLine, tokList); aNewList = parse(endOfLine, tokList);
} }
aNewList.push_front(DoxygenEntity("plainstring", name)); aNewList.push_front(DoxygenEntity("plainstd::string", name));
doxyList.push_back(DoxygenEntity(theCommand, aNewList)); doxyList.push_back(DoxygenEntity(theCommand, aNewList));
} }
// \ref <name> ["(text)"] // \ref <name> ["(text)"]
else if (theCommand.compare("ref") == 0){ else if (theCommand.compare("ref") == 0){
//TODO Implement ref //TODO Implement ref
if (noisy) cout << "Not Adding " << theCommand << endl; if (noisy) cout << "Not Adding " << theCommand << endl;
list<Token>::iterator endOfParagraph = getEndOfParagraph(tokList); std::list<Token>::iterator endOfParagraph = getEndOfParagraph(tokList);
tokList.setIterator(endOfParagraph); tokList.setIterator(endOfParagraph);
} }
// \subpage <name> ["(text)"] // \subpage <name> ["(text)"]
else if (theCommand.compare("subpage") == 0){ else if (theCommand.compare("subpage") == 0){
//TODO implement subpage //TODO implement subpage
if (noisy) cout << "Not Adding " << theCommand << endl; if (noisy) cout << "Not Adding " << theCommand << endl;
list<Token>::iterator endOfParagraph = getEndOfParagraph(tokList); std::list<Token>::iterator endOfParagraph = getEndOfParagraph(tokList);
tokList.setIterator(endOfParagraph); tokList.setIterator(endOfParagraph);
} }
// \dotfile <file> ["caption"] // \dotfile <file> ["caption"]
else if (theCommand.compare("dotfile") == 0){ else if (theCommand.compare("dotfile") == 0){
//TODO implement dotfile //TODO implement dotfile
if (noisy) cout << "Not Adding " << theCommand << endl; if (noisy) cout << "Not Adding " << theCommand << endl;
list<Token>::iterator endOfParagraph = getEndOfParagraph(tokList); std::list<Token>::iterator endOfParagraph = getEndOfParagraph(tokList);
tokList.setIterator(endOfParagraph); tokList.setIterator(endOfParagraph);
} }
// \image <format> <file> ["caption"] [<sizeindication>=<size>] // \image <format> <file> ["caption"] [<sizeindication>=<size>]
@ -641,17 +639,17 @@ list<Token>::iterator getTilAnyCommand(string theCommand, TokenList &tokList){
// \addtogroup <name> [(title)] // \addtogroup <name> [(title)]
else if (theCommand.compare("addtogroup") == 0){ else if (theCommand.compare("addtogroup") == 0){
if (noisy) cout << "Parsing " << theCommand << endl; if (noisy) cout << "Parsing " << theCommand << endl;
string name = getNextWord(tokList); std::string name = getNextWord(tokList);
if (name.empty()){ if (name.empty()){
cout << "No word followed " << theCommand << " command. Not added" << endl; cout << "No word followed " << theCommand << " command. Not added" << endl;
return 0; return 0;
} }
list <DoxygenEntity> aNewList; std::list <DoxygenEntity> aNewList;
list<Token>::iterator endOfLine = getOneLine(tokList); std::list<Token>::iterator endOfLine = getOneLine(tokList);
if (endOfLine != tokList.current()) { if (endOfLine != tokList.current()) {
aNewList = parse(endOfLine, tokList); aNewList = parse(endOfLine, tokList);
} }
aNewList.push_front(DoxygenEntity("plainstring", name)); aNewList.push_front(DoxygenEntity("plainstd::string", name));
doxyList.push_back(DoxygenEntity(theCommand, aNewList)); doxyList.push_back(DoxygenEntity(theCommand, aNewList));
} }
return 0; return 0;
@ -663,12 +661,12 @@ list<Token>::iterator getTilAnyCommand(string theCommand, TokenList &tokList){
*/ */
int addCommand(string commandString, TokenList &tokList,list <DoxygenEntity> &doxyList){ int addCommand(std::string commandString, TokenList &tokList,std::list <DoxygenEntity> &doxyList){
string theCommand = StringToLower(commandString); std::string theCommand = StringToLower(commandString);
if (theCommand.compare("plainstring") == 0){ if (theCommand.compare("plainstd::string") == 0){
string nextPhrase = getStringTilCommand( tokList); std::string nextPhrase = getStringTilCommand( tokList);
if (noisy) cout << "Parsing plain string :" << nextPhrase << endl; if (noisy) cout << "Parsing plain std::string :" << nextPhrase << endl;
doxyList.push_back(DoxygenEntity("plainstring", nextPhrase )); doxyList.push_back(DoxygenEntity("plainstd::string", nextPhrase ));
return 1; return 1;
} }
int commandNumber = commandBelongs(theCommand); int commandNumber = commandBelongs(theCommand);
@ -721,8 +719,8 @@ int addCommand(string commandString, TokenList &tokList,list <DoxygenEntity> &do
return 0; return 0;
} }
list<DoxygenEntity> parse(list<Token>::iterator endParsingIndex, TokenList &tokList){ std::list<DoxygenEntity> parse(std::list<Token>::iterator endParsingIndex, TokenList &tokList){
list <DoxygenEntity> aNewList; std::list <DoxygenEntity> aNewList;
int currCommand; int currCommand;
while (tokList.current() != endParsingIndex){ while (tokList.current() != endParsingIndex){
Token currToken = tokList.peek(); Token currToken = tokList.peek();
@ -735,22 +733,22 @@ list<DoxygenEntity> parse(list<Token>::iterator endParsingIndex, TokenList &tokL
if (currCommand < 0 ){ if (currCommand < 0 ){
if(noisy) cout << "Unidentified Command " << currToken.tokenString << endl; if(noisy) cout << "Unidentified Command " << currToken.tokenString << endl;
tokList.next(); tokList.next();
addCommand(string("plainstring"), tokList, aNewList);} addCommand(std::string("plainstd::string"), tokList, aNewList);}
//cout << "Command: " << currWord << " " << currCommand << endl; //cout << "Command: " << currWord << " " << currCommand << endl;
else { tokList.next(); else { tokList.next();
addCommand(currToken.tokenString, tokList, aNewList); addCommand(currToken.tokenString, tokList, aNewList);
} }
} }
else if (currToken.tokenType == PLAINSTRING){ else if (currToken.tokenType == PLAINSTRING){
addCommand(string("plainstring"), tokList, aNewList); addCommand(std::string("plainstd::string"), tokList, aNewList);
} }
else break; else break;
} }
return aNewList; return aNewList;
} }
list<DoxygenEntity> parseRoot(list<Token>::iterator endParsingIndex, TokenList &tokList){ std::list<DoxygenEntity> parseRoot(std::list<Token>::iterator endParsingIndex, TokenList &tokList){
list <DoxygenEntity> aNewList; std::list <DoxygenEntity> aNewList;
int currCommand; int currCommand;
while (tokList.current() != endParsingIndex){ while (tokList.current() != endParsingIndex){
Token currToken = tokList.peek(); Token currToken = tokList.peek();
@ -763,26 +761,26 @@ list<DoxygenEntity> parseRoot(list<Token>::iterator endParsingIndex, TokenList &
if (currCommand < 0 ){ if (currCommand < 0 ){
if(noisy) cout << "Unidentified Command " << currToken.tokenString << endl; if(noisy) cout << "Unidentified Command " << currToken.tokenString << endl;
tokList.next(); tokList.next();
addCommand(string("partofdescription"), tokList, aNewList);} addCommand(std::string("partofdescription"), tokList, aNewList);}
//cout << "Command: " << currWord << " " << currCommand << endl; //cout << "Command: " << currWord << " " << currCommand << endl;
else { tokList.next(); else { tokList.next();
addCommand(currToken.tokenString, tokList, aNewList); addCommand(currToken.tokenString, tokList, aNewList);
} }
} }
else if (currToken.tokenType == PLAINSTRING){ else if (currToken.tokenType == PLAINSTRING){
addCommand(string("partofdescription"), tokList, aNewList); addCommand(std::string("partofdescription"), tokList, aNewList);
} }
} }
return aNewList; return aNewList;
} }
list<DoxygenEntity> DoxygenParser::createTree(string doxygenBlob){ std::list<DoxygenEntity> DoxygenParser::createTree(std::string doxygenBlob){
TokenList tokList = TokenList(doxygenBlob); TokenList tokList = TokenList(doxygenBlob);
if(noisy) { if(noisy) {
cout << "---TOKEN LIST---" << endl; cout << "---TOKEN LIST---" << endl;
tokList.printList(); tokList.printList();
} }
list <DoxygenEntity> rootList; std::list <DoxygenEntity> rootList;
rootList = parseRoot( tokList.end(), tokList); rootList = parseRoot( tokList.end(), tokList);
if(noisy) { if(noisy) {
cout << "PARSED LIST" << endl; cout << "PARSED LIST" << endl;

View file

@ -8,7 +8,7 @@ class DoxygenParser
public: public:
DoxygenParser(); DoxygenParser();
virtual ~DoxygenParser(); virtual ~DoxygenParser();
list <DoxygenEntity> createTree(string doxygen); std::list <DoxygenEntity> createTree(std::string doxygen);
}; };
#endif /*DOXYGENPARSER_H_*/ #endif /*DOXYGENPARSER_H_*/

View file

@ -24,69 +24,20 @@ DoxygenTranslator::~DoxygenTranslator(){
char *DoxygenTranslator::convert(Node *n, char* doxygenBlob, char* option){ char *DoxygenTranslator::convert(Node *n, char* doxygenBlob, char* option){
list <DoxygenEntity> rootList = doxyParse.createTree(string(doxygenBlob)); std::list <DoxygenEntity> rootList = doxyParse.createTree(std::string(doxygenBlob));
std::string returnedString;
string returnedString; if(strcmp(option, "JAVADOC") == 0)
if(strcmp(option, "JAVADOC") == 0){
returnedString = jDC.convertToJavaDoc(n, rootList); returnedString = jDC.convertToJavaDoc(n, rootList);
} else if(strcmp(option, "PYDOC") == 0)
else if(strcmp(option, "PYDOC") == 0){
returnedString = pyDC.convertToPyDoc(n, rootList); returnedString = pyDC.convertToPyDoc(n, rootList);
} else
else cout << "Option not current supported.\n"; std::cout << "Option not current supported." << std::endl;
char *nonConstString; char *nonConstString;
nonConstString = (char *)malloc(returnedString.length() + 1); nonConstString = (char *)malloc(returnedString.length() + 1);
strcpy(nonConstString, returnedString.c_str()); strcpy(nonConstString, returnedString.c_str());
return nonConstString; return nonConstString;
} }
int testCommands(){
string exampleArray[] = {
"/**\n * Random Line \n * \\@ \n * Random Line After */",
"/**\n * Random Line Before \n * \n * \\b bold \n * Random Line After */",
"/**\n * Random Line \n * \n *\\copydoc bold \n * Random Line After */",
"/**\n * Random Line \n * \n * \\addindex An Entire Line\n * \\addindex An Entire Line\n * Random Line After */",
"/**\n * Random Line \n * \n * \\return An Entire Paragraph \n * Including This Line \n * \n * Random Line After */",
"/**\n * Random Line \n * \n * \\return An Entire Paragraph \n * Including This Line \n * \\author Shouldn't be part of return */",
"/**\n * Random Line \n * \n * \\code this should continue \n * until here \\endcode \n * Random Line After */",
"/**\n * Random Line \n * \n * \\param singleword then the rest of \n * the description \n * \n * Random Line After */",
"/**\n * Random Line \n * \n * \\page singleword this should go til here \n * but not this */",
"/**\n * Random Line \n * \n * \\page singleword this should go til here \n * but not this */",
"/**\n * Random Line \n * \n * \\category singleword \n * but not this */",
"/**\n * Random Line \n * \n * \\category singleword oneword \n * but not this */",
"/**\n * Random Line \n * \n * \\category singleword oneword twoword \n * but not this */",
"/**\n * Random Line \n * \n * \\dir singleword \n * but not this */",
"/**\n * Random Line \n * \n * \\dir \n * but not this */",
"/**\n * Random Line \n * \n * \\fakecommand details \n * but not this */"
};
//string exampleArrayUniques = {};
DoxygenTranslator dT = DoxygenTranslator();
for (int i = 0; i < 16; i ++ ){
//cout << "---ORIGINAL DOXYGEN--- " << endl << exampleArray[i] << endl;
char *nonConstString = (char *)malloc(exampleArray[i].length()+1);
strcpy(nonConstString, exampleArray[i].c_str());
char * result = dT.convert(NULL, nonConstString, "JAVADOC");
free(nonConstString);
free(result);
}
return 1;
}
//int main(int argc, char *argv[]){
//string doxygenString1 = "//! \\brief a brief description \n\n A normal member taking two arguments and returning an \\b integer value. This is a very long description for the simple purpose of showing off formatting. Let's make it a bit longer just to be sure. \n/*!\n \\param a an \\b integer argument.\n \\return The test results\n \\param s a constant character pointer. Let's also make this a very long description! \n \\bug this command should, for now, be totally ignored\n \\author cheryl foil\n \\sa Test(), ~Test(), testMeToo() and publicVar()\n */";
//cout << "---ORIGINAL DOXYGEN--- " << endl << doxygenString1 << endl;
//char *nonConstString = (char *)malloc(doxygenString1.length()+1);
//strcpy(nonConstString, doxygenString1.c_str());
//DoxygenTranslator dT = DoxygenTranslator();
//char *result = dT.convert("/**\n * \n * Random Line \n * \n * \\name An Entire Line \n * NOT This Line \n * \n * Random Line After */", "JAVADOC");
//result = dT.convert(nonConstString, "JAVADOC");
//cout << "End";
//list <DoxygenEntity> rootList = doxyParse.createTree(doxygenString1);
//JavaDocConverter jDC = JavaDocConverter();
//jDC.convertToJavaDoc(rootList);
//testCommands();
//return 1;
//}

View file

@ -12,93 +12,16 @@ JavaDocConverter::~JavaDocConverter()
{ {
} }
/* Sorts entities by javaDoc standard order for commands void JavaDocConverter::printSortedTree(std::list<DoxygenEntity> &entityList){
* NOTE: will not behave entirely properly until "First level" comments std::list<DoxygenEntity>::iterator p = entityList.begin();
* such as brief descriptions are TAGGED as such
*/
bool compare_DoxygenEntities(DoxygenEntity first, DoxygenEntity second){
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(first.typeOfEntity.compare("partofdescription") == 0) return false;
if(first.typeOfEntity.compare("plainstring") == 0) return true;
if(second.typeOfEntity.compare("plainstring") == 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;
}
void JavaDocConverter::printSortedTree(list <DoxygenEntity> &entityList){
list<DoxygenEntity>::iterator p = entityList.begin();
while (p != entityList.end()){ while (p != entityList.end()){
(*p).printEntity(0); (*p).printEntity(0);
p++; p++;
} }
} }
string formatCommand(string unformattedLine, int indent){
string formattedLines = "\n * "; std::string formatCommand(std::string unformattedLine, int indent){
std::string formattedLines = "\n * ";
int lastPosition = 0; int lastPosition = 0;
int i = 0; int i = 0;
int isFirstLine = 1; int isFirstLine = 1;
@ -133,7 +56,7 @@ string formatCommand(string unformattedLine, int indent){
/* Contains the conversions for tags /* Contains the conversions for tags
* could probably be much more efficient... * could probably be much more efficient...
*/ */
string javaDocFormat(DoxygenEntity &doxygenEntity){ std::string javaDocFormat(DoxygenEntity &doxygenEntity){
if(doxygenEntity.typeOfEntity.compare("partofdescription") == 0){ if(doxygenEntity.typeOfEntity.compare("partofdescription") == 0){
return doxygenEntity.data; return doxygenEntity.data;
} }
@ -174,12 +97,12 @@ string javaDocFormat(DoxygenEntity &doxygenEntity){
} }
string translateSubtree( DoxygenEntity &doxygenEntity){ std::string translateSubtree( DoxygenEntity &doxygenEntity){
string returnedString; std::string returnedString;
if (doxygenEntity.isLeaf){ return javaDocFormat(doxygenEntity) + " ";} if (doxygenEntity.isLeaf){ return javaDocFormat(doxygenEntity) + " ";}
else { else {
returnedString += javaDocFormat(doxygenEntity); returnedString += javaDocFormat(doxygenEntity);
list<DoxygenEntity>::iterator p = doxygenEntity.entityList.begin(); std::list<DoxygenEntity>::iterator p = doxygenEntity.entityList.begin();
while (p != doxygenEntity.entityList.end()){ while (p != doxygenEntity.entityList.end()){
returnedString+= translateSubtree(*p); returnedString+= translateSubtree(*p);
p++; p++;
@ -188,14 +111,14 @@ string translateSubtree( DoxygenEntity &doxygenEntity){
return returnedString; return returnedString;
} }
string translateEntity(DoxygenEntity &doxyEntity){ std::string translateEntity(DoxygenEntity &doxyEntity){
if(doxyEntity.typeOfEntity.compare("partofdescription")== 0) return formatCommand(string(translateSubtree(doxyEntity)), 0); if(doxyEntity.typeOfEntity.compare("partofdescription")== 0) return formatCommand(std::string(translateSubtree(doxyEntity)), 0);
if ((doxyEntity.typeOfEntity.compare("brief") == 0)||(doxyEntity.typeOfEntity.compare("details") == 0)){ if ((doxyEntity.typeOfEntity.compare("brief") == 0)||(doxyEntity.typeOfEntity.compare("details") == 0)){
return formatCommand(string(translateSubtree(doxyEntity)), 0) + "\n * ";} return formatCommand(std::string(translateSubtree(doxyEntity)), 0) + "\n * ";}
else if(doxyEntity.typeOfEntity.compare("plainstring")== 0 || doxyEntity.typeOfEntity.compare("deprecated")== 0 || doxyEntity.typeOfEntity.compare("brief")== 0) else if(doxyEntity.typeOfEntity.compare("plainstring")== 0 || doxyEntity.typeOfEntity.compare("deprecated")== 0 || doxyEntity.typeOfEntity.compare("brief")== 0)
return formatCommand(doxyEntity.data, 0) + "\n * "; return formatCommand(doxyEntity.data, 0) + "\n * ";
else if(doxyEntity.typeOfEntity.compare("see") == 0){ else if(doxyEntity.typeOfEntity.compare("see") == 0){
return formatCommand(string("@" + doxyEntity.typeOfEntity + "\t\t" + translateSubtree(doxyEntity)), 2); return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t\t" + translateSubtree(doxyEntity)), 2);
} }
else if(doxyEntity.typeOfEntity.compare("return")== 0 else if(doxyEntity.typeOfEntity.compare("return")== 0
|| doxyEntity.typeOfEntity.compare("author")== 0 || doxyEntity.typeOfEntity.compare("author")== 0
@ -204,35 +127,37 @@ string translateEntity(DoxygenEntity &doxyEntity){
|| doxyEntity.typeOfEntity.compare("version")== 0 || doxyEntity.typeOfEntity.compare("version")== 0
|| doxyEntity.typeOfEntity.compare("exception") == 0 || doxyEntity.typeOfEntity.compare("exception") == 0
|| doxyEntity.typeOfEntity.compare("deprecated") == 0){ || doxyEntity.typeOfEntity.compare("deprecated") == 0){
return formatCommand(string("@" + doxyEntity.typeOfEntity + "\t" + translateSubtree(doxyEntity)), 2); return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t" + translateSubtree(doxyEntity)), 2);
} }
else if(doxyEntity.typeOfEntity.compare("sa")== 0){ else if(doxyEntity.typeOfEntity.compare("sa")== 0){
return formatCommand(string("@see\t\t" + translateSubtree(doxyEntity)), 2); return formatCommand(std::string("@see\t\t" + translateSubtree(doxyEntity)), 2);
} }
else return formatCommand(javaDocFormat(doxyEntity), 0 ); else return formatCommand(javaDocFormat(doxyEntity), 0 );
return ""; return "";
} }
string JavaDocConverter:: convertToJavaDoc(Node *n, list <DoxygenEntity> entityList){ std::string JavaDocConverter:: convertToJavaDoc(Node *n, std::list <DoxygenEntity> entityList){
#pragma unused(n)
entityList.sort(CompareDoxygenEntities());
entityList.sort(compare_DoxygenEntities);
if(printSortedTree2){ if(printSortedTree2){
cout << "---RESORTED LIST---" << endl; std::cout << "---RESORTED LIST---" << std::endl;
printSortedTree(entityList); printSortedTree(entityList);
} }
string javaDocString = "/**"; std::string javaDocString = "/**";
list<DoxygenEntity>::iterator entityIterator = entityList.begin(); for(std::list<DoxygenEntity>::iterator entityIterator = entityList.begin(); entityIterator != entityList.end();){
while (entityIterator != entityList.end()){
javaDocString += translateEntity(*entityIterator); javaDocString += translateEntity(*entityIterator);
entityIterator++; entityIterator++;
} }
javaDocString += "\n */\n"; javaDocString += "\n */\n";
if(printSortedTree2){ if(printSortedTree2){
cout << "\n---RESULT IN JAVADOC---" << endl; std::cout << "\n---RESULT IN JAVADOC---" << std::endl;
cout << javaDocString; } std::cout << javaDocString;
}
return javaDocString; return javaDocString;
} }

View file

@ -9,11 +9,10 @@
class JavaDocConverter class JavaDocConverter
{ {
public: public:
JavaDocConverter(); JavaDocConverter();
string convertToJavaDoc(Node *n, list <DoxygenEntity> entityList); std::string convertToJavaDoc(Node *n, std::list <DoxygenEntity> entityList);
~JavaDocConverter(); ~JavaDocConverter();
void printSortedTree(list <DoxygenEntity> &entityList); void printSortedTree(std::list <DoxygenEntity> &entityList);
}; };
#endif /*JAVADOCCONVERTER_H_*/ #endif /*JAVADOCCONVERTER_H_*/

View file

@ -15,22 +15,16 @@ PyDocConverter::~PyDocConverter()
{ {
} }
/* Sorts entities by pyDoc standard order for commands void PyDocConverter::printSortedTree(std::list <DoxygenEntity> &entityList){
* NOTE: will not behave entirely properly until "First level" comments std::list<DoxygenEntity>::iterator p = entityList.begin();
* such as brief descriptions are TAGGED as such
*/
bool compare_DoxygenEntities(DoxygenEntity first, DoxygenEntity second);
void PyDocConverter::printSortedTree(list <DoxygenEntity> &entityList){
list<DoxygenEntity>::iterator p = entityList.begin();
while (p != entityList.end()){ while (p != entityList.end()){
(*p).printEntity(0); (*p).printEntity(0);
p++; p++;
} }
} }
string PyDocConverter::formatParam(Node *n, DoxygenEntity &doxygenEntity) { std::string PyDocConverter::formatParam(Node *n, DoxygenEntity &doxygenEntity) {
string result; std::string result;
ParmList *plist = CopyParmList(Getattr(n, "parms")); ParmList *plist = CopyParmList(Getattr(n, "parms"));
Parm *p = NULL; Parm *p = NULL;
@ -44,7 +38,7 @@ string PyDocConverter::formatParam(Node *n, DoxygenEntity &doxygenEntity) {
std::ostringstream parameterDocString; std::ostringstream parameterDocString;
parameterDocString << std::endl << name << " (" << type << "): "; parameterDocString << std::endl << name << " (" << type << ") -- ";
parameterDocString << paramDescriptionEntity.data; parameterDocString << paramDescriptionEntity.data;
result = parameterDocString.str(); result = parameterDocString.str();
@ -57,12 +51,12 @@ string PyDocConverter::formatParam(Node *n, DoxygenEntity &doxygenEntity) {
return result; return result;
} }
string PyDocConverter::formatCommand(string unformattedLine, int indent){ std::string PyDocConverter::formatCommand(std::string unformattedLine, int indent){
string formattedLines = "\n"; std::string formattedLines = "\n";
int lastPosition = 0; int lastPosition = 0;
int i = 0; signed int i = 0;
int isFirstLine = 1; bool isFirstLine = true;
while (i != -1 && i < unformattedLine.length()){ while (i != -1 && i < (int)unformattedLine.length()){
lastPosition = i; lastPosition = i;
if (isFirstLine){ if (isFirstLine){
i+=APPROX_LINE_LENGTH; i+=APPROX_LINE_LENGTH;
@ -70,19 +64,19 @@ string PyDocConverter::formatCommand(string unformattedLine, int indent){
else i+=APPROX_LINE_LENGTH - indent*TAB_SIZE; else i+=APPROX_LINE_LENGTH - indent*TAB_SIZE;
i = unformattedLine.find(" ", i); i = unformattedLine.find(" ", i);
if (i > 0 && i + 1 < unformattedLine.length()){ if (i > 0 && i + 1 < (int)unformattedLine.length()){
if (!isFirstLine) for (int j = 0; j < indent; j++) { if (!isFirstLine) for (int j = 0; j < indent; j++) {
formattedLines.append("\t"); formattedLines.append("\t");
} }
else { else {
isFirstLine = 0; isFirstLine = false;
} }
formattedLines.append(unformattedLine.substr(lastPosition, i - lastPosition + 1)); formattedLines.append(unformattedLine.substr(lastPosition, i - lastPosition + 1));
formattedLines.append("\n"); formattedLines.append("\n");
} }
} }
if (lastPosition < unformattedLine.length()){ if (lastPosition < (int)unformattedLine.length()){
if (!isFirstLine) {for (int j = 0; j < indent; j++) {formattedLines.append("\t");}} if (!isFirstLine) {for (int j = 0; j < indent; j++) {formattedLines.append("\t");}}
formattedLines.append(unformattedLine.substr(lastPosition, unformattedLine.length() - lastPosition)); formattedLines.append(unformattedLine.substr(lastPosition, unformattedLine.length() - lastPosition));
} }
@ -93,11 +87,11 @@ string PyDocConverter::formatCommand(string unformattedLine, int indent){
/* Contains the conversions for tags /* Contains the conversions for tags
* could probably be much more efficient... * could probably be much more efficient...
*/ */
string PyDocConverter::pyDocFormat(DoxygenEntity &doxygenEntity){ std::string PyDocConverter::pyDocFormat(DoxygenEntity &doxygenEntity){
if(doxygenEntity.typeOfEntity.compare("partofdescription") == 0){ if(doxygenEntity.typeOfEntity.compare("partofdescription") == 0){
return doxygenEntity.data; return doxygenEntity.data;
} }
if (doxygenEntity.typeOfEntity.compare("plainstring") == 0){ if (doxygenEntity.typeOfEntity.compare("plainstd::string") == 0){
return doxygenEntity.data; return doxygenEntity.data;
} }
else if (doxygenEntity.typeOfEntity.compare("b") == 0){ else if (doxygenEntity.typeOfEntity.compare("b") == 0){
@ -134,12 +128,12 @@ string PyDocConverter::pyDocFormat(DoxygenEntity &doxygenEntity){
} }
string PyDocConverter::translateSubtree( DoxygenEntity &doxygenEntity){ std::string PyDocConverter::translateSubtree( DoxygenEntity &doxygenEntity){
string returnedString; std::string returnedString;
if (doxygenEntity.isLeaf){ return pyDocFormat(doxygenEntity) + " ";} if (doxygenEntity.isLeaf){ return pyDocFormat(doxygenEntity) + " ";}
else { else {
returnedString += pyDocFormat(doxygenEntity); returnedString += pyDocFormat(doxygenEntity);
list<DoxygenEntity>::iterator p = doxygenEntity.entityList.begin(); std::list<DoxygenEntity>::iterator p = doxygenEntity.entityList.begin();
while (p != doxygenEntity.entityList.end()){ while (p != doxygenEntity.entityList.end()){
returnedString+= translateSubtree(*p); returnedString+= translateSubtree(*p);
p++; p++;
@ -148,48 +142,50 @@ string PyDocConverter::translateSubtree( DoxygenEntity &doxygenEntity){
return returnedString; return returnedString;
} }
string PyDocConverter::translateEntity(Node *n, DoxygenEntity &doxyEntity){ std::string PyDocConverter::translateEntity(Node *n, DoxygenEntity &doxyEntity){
if(doxyEntity.typeOfEntity.compare("partofdescription")== 0) return formatCommand(string(translateSubtree(doxyEntity)), 0); if(doxyEntity.typeOfEntity.compare("partofdescription")== 0)
return formatCommand(std::string(translateSubtree(doxyEntity)), 0);
if ((doxyEntity.typeOfEntity.compare("brief") == 0)||(doxyEntity.typeOfEntity.compare("details") == 0)){ if ((doxyEntity.typeOfEntity.compare("brief") == 0)||(doxyEntity.typeOfEntity.compare("details") == 0)){
return formatCommand(string(translateSubtree(doxyEntity)), 0) + "\n * ";} return formatCommand(std::string(translateSubtree(doxyEntity)), 0) + "\n * ";}
else if(doxyEntity.typeOfEntity.compare("plainstring")== 0
if(doxyEntity.typeOfEntity.compare("plainstd::string")== 0
|| doxyEntity.typeOfEntity.compare("deprecated")== 0 || doxyEntity.typeOfEntity.compare("deprecated")== 0
|| doxyEntity.typeOfEntity.compare("brief")== 0) || doxyEntity.typeOfEntity.compare("brief")== 0)
return formatCommand(doxyEntity.data, 0) + "\n * "; return formatCommand(doxyEntity.data, 0) + "\n * ";
else if(doxyEntity.typeOfEntity.compare("see") == 0){
return formatCommand(string("@" + doxyEntity.typeOfEntity + "\t\t" + translateSubtree(doxyEntity)), 2); if(doxyEntity.typeOfEntity.compare("see") == 0)
} return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t\t" + translateSubtree(doxyEntity)), 2);
else if(doxyEntity.typeOfEntity.compare("param") == 0) {
if(doxyEntity.typeOfEntity.compare("param") == 0)
return formatParam(n, doxyEntity); return formatParam(n, doxyEntity);
}
else if(doxyEntity.typeOfEntity.compare("return")== 0 if(doxyEntity.typeOfEntity.compare("return")== 0
|| doxyEntity.typeOfEntity.compare("author")== 0 || doxyEntity.typeOfEntity.compare("author")== 0
|| doxyEntity.typeOfEntity.compare("param")== 0 || doxyEntity.typeOfEntity.compare("param")== 0
|| doxyEntity.typeOfEntity.compare("since")== 0 || doxyEntity.typeOfEntity.compare("since")== 0
|| doxyEntity.typeOfEntity.compare("version")== 0 || doxyEntity.typeOfEntity.compare("version")== 0
|| doxyEntity.typeOfEntity.compare("exception") == 0 || doxyEntity.typeOfEntity.compare("exception") == 0
|| doxyEntity.typeOfEntity.compare("deprecated") == 0){ || doxyEntity.typeOfEntity.compare("deprecated") == 0)
return formatCommand(string("@" + doxyEntity.typeOfEntity + "\t" + translateSubtree(doxyEntity)), 2); return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t" + translateSubtree(doxyEntity)), 2);
}
else if(doxyEntity.typeOfEntity.compare("sa")== 0){ if(doxyEntity.typeOfEntity.compare("sa")== 0)
return formatCommand(string("@see\t\t" + translateSubtree(doxyEntity)), 2); return formatCommand(std::string("@see\t\t" + translateSubtree(doxyEntity)), 2);
}
else return formatCommand(pyDocFormat(doxyEntity), 0 ); return formatCommand(pyDocFormat(doxyEntity), 0);
return "";
} }
string PyDocConverter::convertToPyDoc(Node *n, list <DoxygenEntity> entityList){ std::string PyDocConverter::convertToPyDoc(Node *n, std::list<DoxygenEntity> entityList){
entityList.sort(compare_DoxygenEntities); entityList.sort(CompareDoxygenEntities());
if(debug){ if(debug){
cout << "---RESORTED LIST---" << endl; std::cout << "---RESORTED LIST---" << std::endl;
printSortedTree(entityList); printSortedTree(entityList);
} }
string pyDocString = "\"\"\""; std::string pyDocString = "\"\"\"";
list<DoxygenEntity>::iterator entityIterator = entityList.begin(); for(std::list<DoxygenEntity>::iterator entityIterator = entityList.begin(); entityIterator != entityList.end();){
while (entityIterator != entityList.end()){
pyDocString += translateEntity(n, *entityIterator); pyDocString += translateEntity(n, *entityIterator);
entityIterator++; entityIterator++;
} }
@ -197,8 +193,8 @@ string PyDocConverter::convertToPyDoc(Node *n, list <DoxygenEntity> entityList){
pyDocString += "\n\"\"\"\n"; pyDocString += "\n\"\"\"\n";
if(debug){ if(debug){
cout << "\n---RESULT IN PYDOC---" << endl; std::cout << "\n---RESULT IN PYDOC---" << std::endl;
cout << pyDocString; std::cout << pyDocString;
} }
return pyDocString; return pyDocString;

View file

@ -9,15 +9,14 @@
class PyDocConverter class PyDocConverter
{ {
public: public:
PyDocConverter(); PyDocConverter();
string convertToPyDoc(Node *n, list <DoxygenEntity> entityList); std::string convertToPyDoc(Node *n, std::list <DoxygenEntity> entityList);
~PyDocConverter(); ~PyDocConverter();
void printSortedTree(list <DoxygenEntity> &entityList); void printSortedTree(std::list <DoxygenEntity> &entityList);
protected: protected:
std::string formatParam(Node *n, DoxygenEntity &doxygenEntity); std::string formatParam(Node *n, DoxygenEntity &doxygenEntity);
std::string formatCommand(string unformattedLine, int indent); std::string formatCommand(std::string unformattedLine, int indent);
std::string pyDocFormat(DoxygenEntity &doxygenEntity); std::string pyDocFormat(DoxygenEntity &doxygenEntity);
std::string translateSubtree( DoxygenEntity &doxygenEntity); std::string translateSubtree( DoxygenEntity &doxygenEntity);
std::string translateEntity(Node *n, DoxygenEntity &doxyEntity); std::string translateEntity(Node *n, DoxygenEntity &doxyEntity);