diff --git a/Source/DoxygenTranslator/src/DoxygenEntity.cpp b/Source/DoxygenTranslator/src/DoxygenEntity.cpp index b2b156b5d..f770dc514 100644 --- a/Source/DoxygenTranslator/src/DoxygenEntity.cpp +++ b/Source/DoxygenTranslator/src/DoxygenEntity.cpp @@ -10,10 +10,10 @@ #include "DoxygenEntity.h" #include -DoxygenEntity::DoxygenEntity(std::string typeEnt){ - typeOfEntity = typeEnt; - data = ""; - isLeaf = true; +DoxygenEntity::DoxygenEntity(std::string typeEnt) { + typeOfEntity = typeEnt; + data = ""; + isLeaf = true; } /* Basic node for commands that have @@ -21,173 +21,171 @@ DoxygenEntity::DoxygenEntity(std::string typeEnt){ * example: \b word * OR holding a std::string */ -DoxygenEntity::DoxygenEntity(std::string typeEnt, std::string param1){ - typeOfEntity = typeEnt; - data = param1; - isLeaf = true; +DoxygenEntity::DoxygenEntity(std::string typeEnt, std::string param1) { + typeOfEntity = typeEnt; + data = param1; + isLeaf = true; } /* Nonterminal node * contains */ -DoxygenEntity::DoxygenEntity(std::string typeEnt, std::list &entList ){ - typeOfEntity = typeEnt; - data = ""; - isLeaf = false; - entityList = entList; +DoxygenEntity::DoxygenEntity(std::string typeEnt, std::list < DoxygenEntity > &entList) { + typeOfEntity = typeEnt; + data = ""; + isLeaf = false; + entityList = entList; } -void DoxygenEntity::printEntity(int level){ - int thisLevel = level; - if (isLeaf) { - for (int i = 0; i < thisLevel; i++) { - std::cout << "\t"; - } - - std::cout << "Node Command: " << typeOfEntity << " "; - - if (data.compare("") != 0) { - std::cout << "Node Data: " << data; - } - std::cout << std::endl; +void DoxygenEntity::printEntity(int level) { + int thisLevel = level; + if (isLeaf) { + for (int i = 0; i < thisLevel; i++) { + std::cout << "\t"; + } - } else { + std::cout << "Node Command: " << typeOfEntity << " "; - for (int i = 0; i < thisLevel; i++) { - std::cout << "\t"; - } + if (data.compare("") != 0) { + std::cout << "Node Data: " << data; + } + std::cout << std::endl; - std::cout << "Node Command : " << typeOfEntity << std::endl; + } else { - std::list::iterator p = entityList.begin(); - thisLevel++; + for (int i = 0; i < thisLevel; i++) { + std::cout << "\t"; + } - while (p != entityList.end()){ - (*p).printEntity(thisLevel); - p++; - } - } + std::cout << "Node Command : " << typeOfEntity << std::endl; + + std::list < DoxygenEntity >::iterator p = entityList.begin(); + thisLevel++; + + while (p != entityList.end()) { + (*p).printEntity(thisLevel); + p++; + } + } } // not used, completely wrong - currently std lib reports 'invalid operator <' -bool CompareDoxygenEntities::operator()(DoxygenEntity& first, DoxygenEntity& second){ +bool CompareDoxygenEntities::operator() (DoxygenEntity & first, DoxygenEntity & second) { - // return first.typeOfEntity < second.typeOfEntity; - if(first.typeOfEntity.compare("brief") == 0) + // return first.typeOfEntity < second.typeOfEntity; + if (first.typeOfEntity.compare("brief") == 0) return true; - if(second.typeOfEntity.compare("brief") == 0) + if (second.typeOfEntity.compare("brief") == 0) return false; - if(first.typeOfEntity.compare("details") == 0) + if (first.typeOfEntity.compare("details") == 0) return true; - if(second.typeOfEntity.compare("details") == 0) + if (second.typeOfEntity.compare("details") == 0) return false; - if(first.typeOfEntity.compare("partofdescription") == 0) + if (first.typeOfEntity.compare("partofdescription") == 0) return true; - if(second.typeOfEntity.compare("partofdescription") == 0) + if (second.typeOfEntity.compare("partofdescription") == 0) return false; - if(first.typeOfEntity.compare("plainstd::string") == 0) + if (first.typeOfEntity.compare("plainstd::string") == 0) return true; - if(second.typeOfEntity.compare("plainstd::string") == 0) + if (second.typeOfEntity.compare("plainstd::string") == 0) return false; - if(first.typeOfEntity.compare("param") == 0){ - if(second.typeOfEntity.compare("param")== 0) + if (first.typeOfEntity.compare("param") == 0) { + if (second.typeOfEntity.compare("param") == 0) return true; - if(second.typeOfEntity.compare("return")== 0) + if (second.typeOfEntity.compare("return") == 0) return true; - if(second.typeOfEntity.compare("exception")== 0) + if (second.typeOfEntity.compare("exception") == 0) return true; - if(second.typeOfEntity.compare("author")== 0) + if (second.typeOfEntity.compare("author") == 0) return true; - if(second.typeOfEntity.compare("version")== 0) + if (second.typeOfEntity.compare("version") == 0) return true; - if(second.typeOfEntity.compare("see")== 0) + if (second.typeOfEntity.compare("see") == 0) return true; - if(second.typeOfEntity.compare("since")== 0) + if (second.typeOfEntity.compare("since") == 0) return true; - if(second.typeOfEntity.compare("deprecated")== 0) + if (second.typeOfEntity.compare("deprecated") == 0) return true; return false; } - if(first.typeOfEntity.compare("return")== 0){ - if(second.typeOfEntity.compare("return")== 0) + if (first.typeOfEntity.compare("return") == 0) { + if (second.typeOfEntity.compare("return") == 0) return true; - if(second.typeOfEntity.compare("exception")== 0) + if (second.typeOfEntity.compare("exception") == 0) return true; - if(second.typeOfEntity.compare("author")== 0) + if (second.typeOfEntity.compare("author") == 0) return true; - if(second.typeOfEntity.compare("version")== 0) + if (second.typeOfEntity.compare("version") == 0) return true; - if(second.typeOfEntity.compare("see")== 0) + if (second.typeOfEntity.compare("see") == 0) return true; - if(second.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("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) + if (second.typeOfEntity.compare("deprecated") == 0) return true; return false; } - if(first.typeOfEntity.compare("author")== 0){ - if(second.typeOfEntity.compare("author")== 0) + if (first.typeOfEntity.compare("exception") == 0) { + if (second.typeOfEntity.compare("exception") == 0) return true; - if(second.typeOfEntity.compare("version")== 0) + if (second.typeOfEntity.compare("author") == 0) return true; - if(second.typeOfEntity.compare("see")== 0) + if (second.typeOfEntity.compare("version") == 0) return true; - if(second.typeOfEntity.compare("since")== 0) + if (second.typeOfEntity.compare("see") == 0) return true; - if(second.typeOfEntity.compare("deprecated")== 0) + 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) + if (first.typeOfEntity.compare("author") == 0) { + if (second.typeOfEntity.compare("author") == 0) return true; - if(second.typeOfEntity.compare("see")== 0) + if (second.typeOfEntity.compare("version") == 0) return true; - if(second.typeOfEntity.compare("since")== 0) + if (second.typeOfEntity.compare("see") == 0) return true; - if(second.typeOfEntity.compare("deprecated")== 0) + 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) + if (first.typeOfEntity.compare("version") == 0) { + if (second.typeOfEntity.compare("version") == 0) return true; - if(second.typeOfEntity.compare("sa")== 0) + if (second.typeOfEntity.compare("see") == 0) return true; - if(second.typeOfEntity.compare("since")== 0) + if (second.typeOfEntity.compare("since") == 0) return true; - if(second.typeOfEntity.compare("deprecated")== 0) + if (second.typeOfEntity.compare("deprecated") == 0) return true; return false; } - if(first.typeOfEntity.compare("since")== 0){ - if(second.typeOfEntity.compare("since")== 0) + if (first.typeOfEntity.compare("see") == 0 || first.typeOfEntity.compare("sa") == 0) { + if (second.typeOfEntity.compare("see") == 0) return true; - if(second.typeOfEntity.compare("deprecated")== 0) + 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("deprecated")== 0){ - if(second.typeOfEntity.compare("deprecated")== 0) + 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 4c1ab7ff9..ca42393db 100644 --- a/Source/DoxygenTranslator/src/DoxygenEntity.h +++ b/Source/DoxygenTranslator/src/DoxygenEntity.h @@ -15,7 +15,7 @@ typedef enum { - SIMPLECOMMAND, + SIMPLECOMMAND, IGNOREDSIMPLECOMMAND, COMMANDWORD, IGNOREDCOMMANDWORD, @@ -39,15 +39,15 @@ typedef enum { /* * Structure to represent a doxygen comment entry */ -struct DoxygenEntity{ +struct DoxygenEntity { std::string typeOfEntity; - std::list entityList; + std::list < DoxygenEntity > entityList; std::string data; bool isLeaf; DoxygenEntity(std::string typeEnt); DoxygenEntity(std::string typeEnt, std::string param1); - DoxygenEntity(std::string typeEnt, std::list &entList ); + DoxygenEntity(std::string typeEnt, std::list < DoxygenEntity > &entList); void printEntity(int level); }; @@ -58,7 +58,7 @@ struct DoxygenEntity{ * such as brief descriptions are TAGGED as such */ struct CompareDoxygenEntities { - bool operator()(DoxygenEntity& first, DoxygenEntity& second); + bool operator() (DoxygenEntity & first, DoxygenEntity & second); }; -#endif /*TOKENLIST_H_*/ +#endif diff --git a/Source/DoxygenTranslator/src/DoxygenParser.cpp b/Source/DoxygenTranslator/src/DoxygenParser.cpp index 78072852d..f4bce5445 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.cpp +++ b/Source/DoxygenTranslator/src/DoxygenParser.cpp @@ -2,88 +2,110 @@ #include "TokenList.h" -DoxygenParser::DoxygenParser() -{ +DoxygenParser::DoxygenParser() { } -DoxygenParser::~DoxygenParser() -{ +DoxygenParser::~DoxygenParser() { } ////////////////////////////////////////// -int noisy = 0; // set this to 1 for extra chatter from the parsing stage. -int addCommand(std::string currCommand, TokenList &tokList, std::list &aNewList); -std::list parse(std::list::iterator endParsingIndex, TokenList &tokList); +int noisy = 0; // set this to 1 for extra chatter from the parsing stage. +int addCommand(std::string currCommand, TokenList & tokList, std::list < DoxygenEntity > &aNewList); +std::list < DoxygenEntity > parse(std::list < Token >::iterator endParsingIndex, TokenList & tokList); ////////////////////////////////////////// -std::string commandArray[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attention", - "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", - "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", - "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", - "else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif", - "endlatexonly", "endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", - "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", - "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", - "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", - "line", "link", "mainpage", "manonly", "msc", "n", "name", "namespace", "nosubgrouping", - "note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre", - "private", "privatesection", "property", "protected", "protectedsection", "protocol", - "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval", - "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", - "subsection", "subsubsection", "test", "throw", "throws", "todo", "tparam", "typedef", "union", "until", - "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", - "$", "@", "\\","&", "~", "<", ">", "#", "%"}; +std::string commandArray[] = { + "a", "addindex", "addtogroup", "anchor", "arg", "attention", + "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", + "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", + "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", + "else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif", + "endlatexonly", "endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", + "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", + "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", + "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", + "line", "link", "mainpage", "manonly", "msc", "n", "name", "namespace", "nosubgrouping", + "note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre", + "private", "privatesection", "property", "protected", "protectedsection", "protocol", + "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval", + "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", + "subsection", "subsubsection", "test", "throw", "throws", "todo", "tparam", "typedef", "union", "until", + "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", "$", "@", "\\", "&", "~", "<", ">", "#", "%"}; -std::string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "date", "deprecated", "details", - "else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param", - "tparam", "post" , "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "throws", "todo", - "version", "warning", "xrefitem" }; +std::string sectionIndicators[] = { + "attention", "author", "brief", "bug", "cond", "date", "deprecated", "details", + "else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param", + "tparam", "post", "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "throws", "todo", "version", "warning", "xrefitem"}; /* All of the doxygen commands divided up by how they are parsed */ -std::string simpleCommands[] = {"n", "$", "@", "\\", "&", "~", "<", ">", "#", "%"}; -std::string ignoredSimpleCommands[] = {"nothing at the moment"}; -std::string commandWords[] = {"a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", - "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno"}; -std::string ignoredCommandWords[] = {"copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"}; -std::string commandLines[] = {"addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property"}; -std::string ignoreCommandLines[] = {"nothing at the moment"}; -std::string commandParagraph[] = {"partofdescription", "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", - "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "author"}; -std::string ignoreCommandParagraphs[] = {"nothing at the moment"}; -std::string commandEndCommands[] = {"code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", - "verbatim", "xmlonly", "cond", "if", "ifnot", "link"}; -std::string commandWordParagraphs[] = {"param", "tparam", "throw", "throws", "retval", "exception"}; -std::string commandWordLines[] = {"page", "subsection", "subsubsection", "section", "paragraph", "defgroup"}; -std::string commandWordOWordOWords [] = {"category", "class", "protocol", "interface", "struct", "union"}; -std::string commandOWords[] = {"dir", "file", "cond"}; -std::string commandErrorThrowings[] = {"annotatedclassstd::list", "classhierarchy", "define", "functionindex", "header", - "headerfilestd::list", "inherit", "l", "postheader", "private", "privatesection", "protected", - "protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly", - "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endcond", - "endif"}; -std::string commandUniques[] = {"xrefitem", "arg", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", -"subpage", "dotfile", "image", "addtogroup", "li"}; +std::string simpleCommands[] = { + "n", "$", "@", "\\", "&", "~", "<", ">", "#", "%"}; + +std::string ignoredSimpleCommands[] = { + "nothing at the moment"}; + +std::string commandWords[] = { + "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", "relates", "namespace", "relatesalso", "anchor", "dontinclude", "include", "includelineno"}; + +std::string ignoredCommandWords[] = { + "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"}; + +std::string commandLines[] = { + "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property"}; + +std::string ignoreCommandLines[] = { + "nothing at the moment"}; + +std::string commandParagraph[] = { + "partofdescription", "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", + "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "author"}; + +std::string ignoreCommandParagraphs[] = { + "nothing at the moment"}; + +std::string commandEndCommands[] = { + "code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", "verbatim", "xmlonly", "cond", "if", "ifnot", "link"}; + +std::string commandWordParagraphs[] = { + "param", "tparam", "throw", "throws", "retval", "exception"}; + +std::string commandWordLines[] = { + "page", "subsection", "subsubsection", "section", "paragraph", "defgroup"}; + +std::string commandWordOWordOWords[] = { + "category", "class", "protocol", "interface", "struct", "union"}; + +std::string commandOWords[] = { + "dir", "file", "cond"}; + +std::string commandErrorThrowings[] = { + "annotatedclassstd::list", "classhierarchy", "define", "functionindex", "header", + "headerfilestd::list", "inherit", "l", "postheader", "private", "privatesection", "protected", + "protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly", + "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endcond", "endif"}; +std::string commandUniques[] = { + "xrefitem", "arg", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", "subpage", "dotfile", "image", "addtogroup", "li"}; /* Changes a std::string to all lower case */ -std::string StringToLower(std::string stringToConvert){ - for(unsigned int i=0;i &rootList){ - std::list::iterator p = rootList.begin(); - while (p != rootList.end()){ +void printTree(std::list < DoxygenEntity > &rootList) { + std::list < DoxygenEntity >::iterator p = rootList.begin(); + while (p != rootList.end()) { (*p).printEntity(0); p++; } @@ -116,190 +138,192 @@ void printTree( std::list &rootList){ /* Determines how a command should be handled (what group it belongs to * for parsing rules */ -int commandBelongs(std::string theCommand){ - std::string smallString = StringToLower(theCommand); - //cout << " Looking for command " << theCommand << endl; +int commandBelongs(std::string theCommand) { + std::string smallString = StringToLower(theCommand); + //cout << " Looking for command " << theCommand << endl; unsigned i = 0; - for (i = 0; i < sizeof(simpleCommands)/sizeof(*simpleCommands); i++){ - if(smallString.compare(simpleCommands[i]) == 0) + for (i = 0; i < sizeof(simpleCommands) / sizeof(*simpleCommands); i++) { + if (smallString.compare(simpleCommands[i]) == 0) return SIMPLECOMMAND; } - for (i = 0; i < sizeof(ignoredSimpleCommands)/sizeof(*ignoredSimpleCommands); i++){ - if(smallString.compare(ignoredSimpleCommands[i]) == 0) + for (i = 0; i < sizeof(ignoredSimpleCommands) / sizeof(*ignoredSimpleCommands); i++) { + if (smallString.compare(ignoredSimpleCommands[i]) == 0) return IGNOREDSIMPLECOMMAND; - } - for (i = 0; i < sizeof(commandWords)/sizeof(*commandWords); i++){ - if(smallString.compare( commandWords[i]) == 0) + } + for (i = 0; i < sizeof(commandWords) / sizeof(*commandWords); i++) { + if (smallString.compare(commandWords[i]) == 0) return COMMANDWORD; - } - for (i = 0; i < sizeof(ignoredCommandWords)/sizeof(*ignoredCommandWords); i++){ - if(smallString.compare( ignoredCommandWords[i]) == 0) + } + for (i = 0; i < sizeof(ignoredCommandWords) / sizeof(*ignoredCommandWords); i++) { + if (smallString.compare(ignoredCommandWords[i]) == 0) return IGNOREDCOMMANDWORD; - } - for (i = 0; i < sizeof(commandLines)/sizeof(*commandLines); i++){ - if(smallString.compare( commandLines[i]) == 0) + } + for (i = 0; i < sizeof(commandLines) / sizeof(*commandLines); i++) { + if (smallString.compare(commandLines[i]) == 0) return COMMANDLINE; - } - for (i = 0; i < sizeof(ignoreCommandLines)/sizeof(*ignoreCommandLines); i++){ - if(smallString.compare( ignoreCommandLines[i]) == 0) + } + for (i = 0; i < sizeof(ignoreCommandLines) / sizeof(*ignoreCommandLines); i++) { + if (smallString.compare(ignoreCommandLines[i]) == 0) return IGNOREDCOMMANDLINE; - } - for (i = 0; i < sizeof(commandParagraph)/sizeof(*commandParagraph); i++){ - if(smallString.compare( commandParagraph[i]) == 0) + } + for (i = 0; i < sizeof(commandParagraph) / sizeof(*commandParagraph); i++) { + if (smallString.compare(commandParagraph[i]) == 0) return COMMANDPARAGRAPH; - } - for (i = 0; i < sizeof(ignoreCommandParagraphs)/sizeof(*ignoreCommandParagraphs); i++){ - if(smallString.compare( ignoreCommandParagraphs[i]) == 0) + } + for (i = 0; i < sizeof(ignoreCommandParagraphs) / sizeof(*ignoreCommandParagraphs); i++) { + if (smallString.compare(ignoreCommandParagraphs[i]) == 0) return IGNORECOMMANDPARAGRAPH; - } - for (i = 0; i < sizeof(commandEndCommands)/sizeof(*commandEndCommands); i++){ - if(smallString.compare( commandEndCommands[i]) == 0) + } + for (i = 0; i < sizeof(commandEndCommands) / sizeof(*commandEndCommands); i++) { + if (smallString.compare(commandEndCommands[i]) == 0) return COMMANDENDCOMMAND; - } - for (i = 0; i < sizeof(commandWordParagraphs)/sizeof(*commandWordParagraphs); i++){ - if(smallString.compare( commandWordParagraphs[i]) == 0) + } + for (i = 0; i < sizeof(commandWordParagraphs) / sizeof(*commandWordParagraphs); i++) { + if (smallString.compare(commandWordParagraphs[i]) == 0) return COMMANDWORDPARAGRAPH; - } - for (i = 0; i < sizeof(commandWordLines)/sizeof(*commandWordLines); i++){ - if(smallString.compare( commandWordLines[i]) == 0) + } + for (i = 0; i < sizeof(commandWordLines) / sizeof(*commandWordLines); i++) { + if (smallString.compare(commandWordLines[i]) == 0) return COMMANDWORDLINE; - } - for (i = 0; i < sizeof(commandWordOWordOWords)/sizeof(*commandWordOWordOWords); i++){ - if(smallString.compare( commandWordOWordOWords[i]) == 0) + } + for (i = 0; i < sizeof(commandWordOWordOWords) / sizeof(*commandWordOWordOWords); i++) { + if (smallString.compare(commandWordOWordOWords[i]) == 0) return COMMANDWORDOWORDWORD; - } - for (i = 0; i < sizeof(commandOWords)/sizeof(*commandOWords); i++){ - if(smallString.compare( commandOWords[i]) == 0) + } + for (i = 0; i < sizeof(commandOWords) / sizeof(*commandOWords); i++) { + if (smallString.compare(commandOWords[i]) == 0) return COMMANDOWORD; - } - for (i = 0; i < sizeof(commandErrorThrowings)/sizeof(*commandErrorThrowings); i++){ - if(smallString.compare( commandErrorThrowings[i]) == 0) + } + for (i = 0; i < sizeof(commandErrorThrowings) / sizeof(*commandErrorThrowings); i++) { + if (smallString.compare(commandErrorThrowings[i]) == 0) return COMMANDERRORTHROW; - } - for (i = 0; i < sizeof(commandUniques)/sizeof(*commandUniques); i++){ - if(smallString.compare( commandUniques[i]) == 0) + } + for (i = 0; i < sizeof(commandUniques) / sizeof(*commandUniques); i++) { + if (smallString.compare(commandUniques[i]) == 0) return COMMANDUNIQUE; } - return 0; + return 0; } /* Returns the next word ON THE CURRENT LINE ONLY * if a new line is encountered, returns a blank std::string. * Updates the index it is given if success. */ -std::string getNextWord(TokenList &tokList){ - Token nextToken = tokList.peek(); - if (nextToken.tokenType == PLAINSTRING ){ - nextToken = tokList.next(); - return nextToken.tokenString; - } +std::string getNextWord(TokenList & tokList) { + Token nextToken = tokList.peek(); + if (nextToken.tokenType == PLAINSTRING) { + nextToken = tokList.next(); + return nextToken.tokenString; + } return ""; } /* Returns the location of the end of the line as * an iterator. */ -std::list::iterator getOneLine(TokenList &tokList){ - std::list::iterator endOfLine = tokList.iteratorCopy(); - while(endOfLine!= tokList.end()){ - if ((* endOfLine).tokenType == END_LINE){ - //cout << "REACHED END" << endl; - //endOfLine++; - return endOfLine; - } - //cout << (* endOfLine).toString(); - endOfLine++; - } - - return tokList.end(); +std::list < Token >::iterator getOneLine(TokenList & tokList) { + std::list < Token >::iterator endOfLine = tokList.iteratorCopy(); + while (endOfLine != tokList.end()) { + if ((*endOfLine).tokenType == END_LINE) { + //cout << "REACHED END" << endl; + //endOfLine++; + return endOfLine; + } + //cout << (* endOfLine).toString(); + endOfLine++; } + return tokList.end(); +} + /* Returns a properly formatted std::string * up til ANY command or end of line is encountered. */ -std::string getStringTilCommand(TokenList &tokList){ - std::string description; - if (tokList.peek().tokenType == 0) return ""; - while(tokList.peek().tokenType == PLAINSTRING){ - Token currentToken = tokList.next(); - if(currentToken.tokenType == PLAINSTRING) { - description = description + currentToken.tokenString + " "; - } - } - return description; +std::string getStringTilCommand(TokenList & tokList) { + std::string description; + if (tokList.peek().tokenType == 0) + return ""; + while (tokList.peek().tokenType == PLAINSTRING) { + Token currentToken = tokList.next(); + if (currentToken.tokenType == PLAINSTRING) { + description = description + currentToken.tokenString + " "; + } } + return description; +} /* Returns a properly formatted std::string * up til the command specified is encountered */ //TODO check that this behaves properly for formulas -std::string getStringTilEndCommand(std::string theCommand, TokenList &tokList){ - std::string description; - if (tokList.peek().tokenType == 0) return ""; - while(tokList.peek().tokenString.compare(theCommand) != 0 ){ - Token currentToken = tokList.next(); - description = description + currentToken.tokenString + " "; - } - return description; +std::string getStringTilEndCommand(std::string theCommand, TokenList & tokList) { + std::string description; + if (tokList.peek().tokenType == 0) + return ""; + while (tokList.peek().tokenString.compare(theCommand) != 0) { + Token currentToken = tokList.next(); + description = description + currentToken.tokenString + " "; } + return description; +} /* Returns the end of a Paragraph as an iterator- * Paragraph is defined in Doxygen to be a paragraph of text * separated by either a structural command or a blank line */ -std::list::iterator getEndOfParagraph(TokenList &tokList){ - std::list::iterator endOfParagraph = tokList.iteratorCopy(); - while(endOfParagraph != tokList.end()){ - if ((* endOfParagraph).tokenType == END_LINE){ - endOfParagraph++; - if (endOfParagraph != tokList.end() && (* endOfParagraph).tokenType == END_LINE) { - endOfParagraph++; - //cout << "ENCOUNTERED END OF PARA" << endl; - return endOfParagraph; - } +std::list < Token >::iterator getEndOfParagraph(TokenList & tokList) { + std::list < Token >::iterator endOfParagraph = tokList.iteratorCopy(); + while (endOfParagraph != tokList.end()) { + if ((*endOfParagraph).tokenType == END_LINE) { + endOfParagraph++; + if (endOfParagraph != tokList.end() && (*endOfParagraph).tokenType == END_LINE) { + endOfParagraph++; + //cout << "ENCOUNTERED END OF PARA" << endl; + return endOfParagraph; + } - } else if ((*endOfParagraph).tokenType == COMMAND) { + } else if ((*endOfParagraph).tokenType == COMMAND) { - if (isSectionIndicator((* endOfParagraph).tokenString)) { - return endOfParagraph; - } - else endOfParagraph++; + if (isSectionIndicator((*endOfParagraph).tokenString)) { + return endOfParagraph; + } else + endOfParagraph++; - } else if ((*endOfParagraph).tokenType == PLAINSTRING) { - endOfParagraph++; - } else { - return tokList.end(); - } + } else if ((*endOfParagraph).tokenType == PLAINSTRING) { + endOfParagraph++; + } else { + return tokList.end(); } + } - return tokList.end(); - } + return tokList.end(); +} /* 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. */ -std::list::iterator getEndOfSection(std::string theCommand, TokenList &tokList){ - std::list::iterator endOfParagraph = tokList.iteratorCopy(); - while(endOfParagraph != tokList.end()){ - if ((* endOfParagraph).tokenType == COMMAND){ - if(theCommand.compare((*endOfParagraph).tokenString) == 0) return endOfParagraph; - else endOfParagraph++; - } - else if((* endOfParagraph).tokenType == PLAINSTRING) { - endOfParagraph++; - } - else if ((* endOfParagraph).tokenType == END_LINE){ - endOfParagraph++; - if ((* endOfParagraph).tokenType == END_LINE){ - endOfParagraph++; - return endOfParagraph; - } - } +std::list < Token >::iterator getEndOfSection(std::string theCommand, TokenList & tokList) { + std::list < Token >::iterator endOfParagraph = tokList.iteratorCopy(); + while (endOfParagraph != tokList.end()) { + if ((*endOfParagraph).tokenType == COMMAND) { + if (theCommand.compare((*endOfParagraph).tokenString) == 0) + return endOfParagraph; + else + endOfParagraph++; + } else if ((*endOfParagraph).tokenType == PLAINSTRING) { + endOfParagraph++; + } else if ((*endOfParagraph).tokenType == END_LINE) { + endOfParagraph++; + if ((*endOfParagraph).tokenType == END_LINE) { + endOfParagraph++; + return endOfParagraph; + } } - return tokList.end(); - } + } + return tokList.end(); +} /* This method is for returning the end of a specific form of doxygen command * that begins with a \command and ends in \endcommand @@ -307,12 +331,12 @@ std::list::iterator getEndOfSection(std::string theCommand, TokenList &to * progressTilEndCommand("endcode", tokenList); * If the end is never encountered, it returns the end of the std::list. */ -std::list::iterator getEndCommand(std::string theCommand, TokenList &tokList){ - std::list::iterator endOfCommand = tokList.iteratorCopy(); - while (endOfCommand!= tokList.end()){ - if ((*endOfCommand).tokenType == COMMAND){ - if (theCommand.compare((* endOfCommand).tokenString) == 0){ - return endOfCommand; +std::list < Token >::iterator getEndCommand(std::string theCommand, TokenList & tokList) { + std::list < Token >::iterator endOfCommand = tokList.iteratorCopy(); + while (endOfCommand != tokList.end()) { + if ((*endOfCommand).tokenType == COMMAND) { + if (theCommand.compare((*endOfCommand).tokenString) == 0) { + return endOfCommand; } endOfCommand++; } @@ -324,9 +348,9 @@ std::list::iterator getEndCommand(std::string theCommand, TokenList &tokL /* A specialty method for commands such as \arg that end at the end of a paragraph OR when another \arg is encountered */ //TODO getTilAnyCommand -std::list::iterator getTilAnyCommand(std::string theCommand, TokenList &tokList){ +std::list < Token >::iterator getTilAnyCommand(std::string theCommand, TokenList & tokList) { #pragma unused(theCommand,tokList) - std::list::iterator anIterator; + std::list < Token >::iterator anIterator; return anIterator; } @@ -338,54 +362,56 @@ std::list::iterator getTilAnyCommand(std::string theCommand, TokenList &t * Plain commands, such as newline etc, they contain no other data * \n \\ \@ \& \$ \# \< \> \% */ -int addSimpleCommand(std::string theCommand, std::list &doxyList){ - if (noisy) cout << "Parsing " << theCommand << endl; +int addSimpleCommand(std::string theCommand, std::list < DoxygenEntity > &doxyList) { + if (noisy) + cout << "Parsing " << theCommand << endl; doxyList.push_back(DoxygenEntity(theCommand)); return 1; } - + /* NOT INCLUDED Simple Commands * Format: @command * Plain commands, such as newline etc, they contain no other data */ -int ignoreSimpleCommand(std::string theCommand, std::list &doxyList){ +int ignoreSimpleCommand(std::string theCommand, std::list < DoxygenEntity > &doxyList) { #pragma unused(doxyList) - if (noisy) cout << "Not Adding " << theCommand << endl; + if (noisy) + cout << "Not Adding " << theCommand << endl; return 1; } - + /* CommandWord * Format: @command * 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" */ -int addCommandWord(std::string theCommand, TokenList &tokList, std::list &doxyList){ - if (noisy) cout << "Parsing " << theCommand << endl; +int addCommandWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { + if (noisy) + cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); - if (!name.empty()){ + if (!name.empty()) { doxyList.push_back(DoxygenEntity(theCommand, name)); return 1; - } - else - cout << "No word followed " << theCommand << " command. Not added" << endl; + } else + cout << "No word followed " << theCommand << " command. Not added" << endl; return 0; } - + /* NOT INCLUDED CommandWord * Format: @command * Commands with a single WORD after then such as @b * "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude" */ -int ignoreCommandWord(std::string theCommand, TokenList &tokList, std::list &doxyList){ +int ignoreCommandWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { #pragma unused(doxyList) - if (noisy) + if (noisy) cout << "Not Adding " << theCommand << endl; std::string name = getNextWord(tokList); if (!name.empty()) return 1; - else - cout << "WARNING: No word followed " << theCommand << " command." << endl; + else + cout << "WARNING: No word followed " << theCommand << " command." << endl; return 0; } @@ -394,12 +420,12 @@ int ignoreCommandWord(std::string theCommand, TokenList &tokList, std::list &doxyList){ - if (noisy) +int addCommandLine(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { + if (noisy) cout << "Parsing " << theCommand << endl; - std::list::iterator endOfLine = getOneLine(tokList); - std::list aNewList = parse(endOfLine, tokList); - doxyList.push_back( DoxygenEntity(theCommand, aNewList)); + std::list < Token >::iterator endOfLine = getOneLine(tokList); + std::list < DoxygenEntity > aNewList = parse(endOfLine, tokList); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; } @@ -408,11 +434,11 @@ int addCommandLine(std::string theCommand, TokenList &tokList, std::list &doxyList){ +int ignoreCommandLine(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { #pragma unused(doxyList) - if (noisy) + if (noisy) cout << "Not Adding " << theCommand << endl; - std::list::iterator endOfLine = getOneLine(tokList); + std::list < Token >::iterator endOfLine = getOneLine(tokList); tokList.setIterator(endOfLine); return 1; } @@ -423,30 +449,30 @@ int ignoreCommandLine(std::string theCommand, TokenList &tokList, std::list &doxyList){ - if (noisy) +int addCommandParagraph(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { + if (noisy) cout << "Parsing " << theCommand << endl; - std::list::iterator endOfParagraph = getEndOfParagraph(tokList); - std::list aNewList; - aNewList = parse(endOfParagraph, tokList); - doxyList.push_back( DoxygenEntity(theCommand, aNewList)); + std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); + std::list < DoxygenEntity > aNewList; + aNewList = parse(endOfParagraph, tokList); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; } - + /* CommandParagraph * Format: @command {paragraph} * Commands with a single LINE after then such as @var * */ -int ignoreCommandParagraph(std::string theCommand, TokenList &tokList, std::list &doxyList){ +int ignoreCommandParagraph(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { #pragma unused(doxyList) - if (noisy) + if (noisy) cout << "Not Adding " << theCommand << endl; - std::list::iterator endOfParagraph = getEndOfParagraph(tokList); + std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); tokList.setIterator(endOfParagraph); return 1; } - + /* Command EndCommand * Format: @command and ends at @endcommand * Commands that take in a block of text such as @code @@ -454,30 +480,30 @@ int ignoreCommandParagraph(std::string theCommand, TokenList &tokList, std::list * "verbatim", "xmlonly", "cond", "if", "ifnot", "link" * Returns 1 if success, 0 if the endcommand is never encountered. */ -int addCommandEndCommand(std::string theCommand, TokenList &tokList, std::list &doxyList){ - if (noisy) +int addCommandEndCommand(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { + if (noisy) cout << "Not Adding " << theCommand << endl; - std::string description = getStringTilEndCommand( "end" + theCommand, tokList); + std::string description = getStringTilEndCommand("end" + theCommand, tokList); doxyList.push_back(DoxygenEntity(theCommand, description)); return 1; } - + /* CommandWordParagraph * Format: @command {paragraph} * Commands such as param * "param", "tparam", "throw", "throws", "retval", "exception" */ -int addCommandWordParagraph(std::string theCommand, TokenList &tokList, std::list &doxyList){ - if (noisy) +int addCommandWordParagraph(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { + if (noisy) cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; + if (name.empty()) { + cout << "No word followed " << theCommand << " command. Not added" << endl; return 0; - } - std::list::iterator endOfParagraph = getEndOfParagraph(tokList); - std::list aNewList; - aNewList = parse(endOfParagraph, tokList); + } + std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); + std::list < DoxygenEntity > aNewList; + aNewList = parse(endOfParagraph, tokList); aNewList.push_front(DoxygenEntity("plainstd::string", name)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; @@ -488,16 +514,17 @@ int addCommandWordParagraph(std::string theCommand, TokenList &tokList, std::lis * Commands such as param * "page", "subsection", "subsubsection", "section", "paragraph", "defgroup" */ -int addCommandWordLine(std::string theCommand, TokenList &tokList, std::list &doxyList){ - if (noisy) cout << "Parsing " << theCommand << endl; - std::string name = getNextWord(tokList); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; +int addCommandWordLine(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { + if (noisy) + cout << "Parsing " << theCommand << endl; + std::string name = getNextWord(tokList); + if (name.empty()) { + cout << "No word followed " << theCommand << " command. Not added" << endl; return 0; - } - std::list::iterator endOfLine = getOneLine(tokList); - std::list aNewList; - aNewList = parse(endOfLine, tokList); + } + std::list < Token >::iterator endOfLine = getOneLine(tokList); + std::list < DoxygenEntity > aNewList; + aNewList = parse(endOfLine, tokList); aNewList.push_front(DoxygenEntity("plainstd::string", name)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; @@ -509,21 +536,21 @@ int addCommandWordLine(std::string theCommand, TokenList &tokList, std::list &doxyList){ - if (noisy) +int addCommandWordOWordOWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { + if (noisy) cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } + if (name.empty()) { + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; + } std::string headerfile = getNextWord(tokList); std::string headername = getNextWord(tokList); - std::list aNewList; + std::list < DoxygenEntity > aNewList; aNewList.push_back(DoxygenEntity("plainstd::string", name)); - if (!headerfile.empty()) + if (!headerfile.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", headerfile)); - if (!headername.empty()) + if (!headername.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", headername)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; @@ -534,241 +561,240 @@ int addCommandWordOWordOWord(std::string theCommand, TokenList &tokList, std::li * Commands such as dir * "dir", "file", "cond" */ -int addCommandOWord(std::string theCommand, TokenList &tokList, std::list &doxyList){ - if (noisy) +int addCommandOWord(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { + if (noisy) cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); doxyList.push_back(DoxygenEntity(theCommand, name)); - return 1; + return 1; } /* Commands that should not be encountered (such as PHP only) * goes til the end of line then returns */ -int addCommandErrorThrow(std::string theCommand, TokenList &tokList, std::list &doxyList){ +int addCommandErrorThrow(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { #pragma unused(doxyList) - if (noisy) { - cout << "Encountered :" << theCommand << endl; - cout << "This command should not have been encountered. Behaviour past this may be unpredictable " << endl; - } - std::list::iterator endOfLine = getOneLine(tokList); - tokList.setIterator(endOfLine); - return 0; - } + if (noisy) { + cout << "Encountered :" << theCommand << endl; + cout << "This command should not have been encountered. Behaviour past this may be unpredictable " << endl; + } + std::list < Token >::iterator endOfLine = getOneLine(tokList); + tokList.setIterator(endOfLine); + return 0; +} /* Adds the unique commands- different process for each unique command */ -int addCommandUnique(std::string theCommand, TokenList &tokList, std::list &doxyList){ - std::list aNewList; - if (theCommand.compare("arg") == 0 || theCommand.compare("li") == 0){ - std::list::iterator endOfSection = getEndOfSection(theCommand, tokList); - std::list aNewList; - aNewList = parse(endOfSection, tokList); - doxyList.push_back( DoxygenEntity(theCommand, aNewList)); +int addCommandUnique(std::string theCommand, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { + std::list < DoxygenEntity > aNewList; + if (theCommand.compare("arg") == 0 || theCommand.compare("li") == 0) { + std::list < Token >::iterator endOfSection = getEndOfSection(theCommand, tokList); + std::list < DoxygenEntity > aNewList; + aNewList = parse(endOfSection, tokList); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); } // \xrefitem "(heading)" "(std::list title)" {text} - else if (theCommand.compare("xrefitem") == 0){ + else if (theCommand.compare("xrefitem") == 0) { //TODO Implement xrefitem - if (noisy) + if (noisy) cout << "Not Adding " << theCommand << endl; - std::list::iterator endOfParagraph = getEndOfParagraph(tokList); + std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); tokList.setIterator(endOfParagraph); return 1; } // \ingroup ( [ ]) - else if (theCommand.compare("ingroup") == 0){ + else if (theCommand.compare("ingroup") == 0) { std::string name = getNextWord(tokList); aNewList.push_back(DoxygenEntity("plainstd::string", name)); name = getNextWord(tokList); - if(!name.empty()) + if (!name.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", name)); name = getNextWord(tokList); - if(!name.empty()) + if (!name.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", name)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; } // \par [(paragraph title)] { paragraph } - else if (theCommand.compare("par") == 0){ - std::list::iterator endOfLine = getOneLine(tokList); - aNewList = parse(endOfLine, tokList); - std::list aNewList2; + else if (theCommand.compare("par") == 0) { + std::list < Token >::iterator endOfLine = getOneLine(tokList); + aNewList = parse(endOfLine, tokList); + std::list < DoxygenEntity > aNewList2; aNewList2 = parse(endOfLine, tokList); aNewList.splice(aNewList.end(), aNewList2); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; + return 1; } // \headerfile [] - else if (theCommand.compare("headerfile") == 0){ - std::list aNewList; + else if (theCommand.compare("headerfile") == 0) { + std::list < DoxygenEntity > aNewList; std::string name = getNextWord(tokList); aNewList.push_back(DoxygenEntity("plainstd::string", name)); name = getNextWord(tokList); - if(!name.empty()) + if (!name.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", name)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); return 1; } // \overload [(function declaration)] - else if (theCommand.compare("overload") == 0){ - std::list::iterator endOfLine = getOneLine(tokList); - if (endOfLine != tokList.current()){ - std::list aNewList; - aNewList = parse(endOfLine, tokList); + else if (theCommand.compare("overload") == 0) { + std::list < Token >::iterator endOfLine = getOneLine(tokList); + if (endOfLine != tokList.current()) { + std::list < DoxygenEntity > aNewList; + aNewList = parse(endOfLine, tokList); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - } - else + } else doxyList.push_back(DoxygenEntity(theCommand)); return 1; } // \weakgroup [(title)] - else if (theCommand.compare("weakgroup") == 0){ - if (noisy) cout << "Parsing " << theCommand << endl; - std::string name = getNextWord(tokList); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; + else if (theCommand.compare("weakgroup") == 0) { + if (noisy) + cout << "Parsing " << theCommand << endl; + std::string name = getNextWord(tokList); + if (name.empty()) { + cout << "No word followed " << theCommand << " command. Not added" << endl; return 0; } - std::list aNewList; - std::list::iterator endOfLine = getOneLine(tokList); + std::list < DoxygenEntity > aNewList; + std::list < Token >::iterator endOfLine = getOneLine(tokList); if (endOfLine != tokList.current()) { - aNewList = parse(endOfLine, tokList); + aNewList = parse(endOfLine, tokList); } aNewList.push_front(DoxygenEntity("plainstd::string", name)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); } // \ref ["(text)"] - else if (theCommand.compare("ref") == 0){ + else if (theCommand.compare("ref") == 0) { //TODO Implement ref - if (noisy) + if (noisy) cout << "Not Adding " << theCommand << endl; - std::list::iterator endOfParagraph = getEndOfParagraph(tokList); + std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); tokList.setIterator(endOfParagraph); } // \subpage ["(text)"] - else if (theCommand.compare("subpage") == 0){ + else if (theCommand.compare("subpage") == 0) { //TODO implement subpage - if (noisy) + if (noisy) cout << "Not Adding " << theCommand << endl; - std::list::iterator endOfParagraph = getEndOfParagraph(tokList); + std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); tokList.setIterator(endOfParagraph); } // \dotfile ["caption"] - else if (theCommand.compare("dotfile") == 0){ + else if (theCommand.compare("dotfile") == 0) { //TODO implement dotfile - if (noisy) + if (noisy) cout << "Not Adding " << theCommand << endl; - std::list::iterator endOfParagraph = getEndOfParagraph(tokList); + std::list < Token >::iterator endOfParagraph = getEndOfParagraph(tokList); tokList.setIterator(endOfParagraph); } // \image ["caption"] [=] - else if (theCommand.compare("image") == 0){ - //todo implement image - } + else if (theCommand.compare("image") == 0) { + //todo implement image + } // \addtogroup [(title)] - else if (theCommand.compare("addtogroup") == 0){ - if (noisy) + else if (theCommand.compare("addtogroup") == 0) { + if (noisy) cout << "Parsing " << theCommand << endl; std::string name = getNextWord(tokList); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; + if (name.empty()) { + cout << "No word followed " << theCommand << " command. Not added" << endl; return 0; } - std::list aNewList; - std::list::iterator endOfLine = getOneLine(tokList); + std::list < DoxygenEntity > aNewList; + std::list < Token >::iterator endOfLine = getOneLine(tokList); if (endOfLine != tokList.current()) { - aNewList = parse(endOfLine, tokList); + aNewList = parse(endOfLine, tokList); } aNewList.push_front(DoxygenEntity("plainstd::string", name)); doxyList.push_back(DoxygenEntity(theCommand, aNewList)); } return 0; } - + /* The actual "meat" of the doxygen parser. This is not yet fully implemented * with my current design- however the skeletal outline is contained in * the file Skeleton */ -int addCommand(std::string commandString, TokenList &tokList,std::list &doxyList){ - std::string theCommand = StringToLower(commandString); - if (theCommand.compare("plainstd::string") == 0){ - std::string nextPhrase = getStringTilCommand( tokList); - if (noisy) cout << "Parsing plain std::string :" << nextPhrase << endl; - doxyList.push_back(DoxygenEntity("plainstd::string", nextPhrase )); - return 1; - } - int commandNumber = commandBelongs(theCommand); - if (commandNumber == SIMPLECOMMAND){ - return addSimpleCommand(theCommand, doxyList); - } - if (commandNumber == IGNOREDSIMPLECOMMAND){ - return ignoreSimpleCommand(theCommand, doxyList); - } - if (commandNumber == COMMANDWORD){ - return addCommandWord(theCommand, tokList, doxyList); - } - if (commandNumber == IGNOREDCOMMANDWORD){ - return ignoreCommandWord(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDLINE ){ - return addCommandLine(theCommand, tokList, doxyList); - } - if (commandNumber == IGNOREDCOMMANDLINE ){ - return ignoreCommandLine(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDPARAGRAPH){ - return addCommandParagraph(theCommand, tokList, doxyList); - } - if (commandNumber == IGNORECOMMANDPARAGRAPH){ - return ignoreCommandParagraph(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDENDCOMMAND){ - return addCommandEndCommand(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDWORDPARAGRAPH){ - return addCommandWordParagraph(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDWORDLINE){ - return addCommandWordLine(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDWORDOWORDWORD){ - return addCommandWordOWordOWord(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDOWORD){ - return addCommandOWord(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDERRORTHROW){ - return addCommandErrorThrow(theCommand, tokList, doxyList); - } - if (commandNumber == COMMANDUNIQUE){ +int addCommand(std::string commandString, TokenList & tokList, std::list < DoxygenEntity > &doxyList) { + std::string theCommand = StringToLower(commandString); + if (theCommand.compare("plainstd::string") == 0) { + std::string nextPhrase = getStringTilCommand(tokList); + if (noisy) + cout << "Parsing plain std::string :" << nextPhrase << endl; + doxyList.push_back(DoxygenEntity("plainstd::string", nextPhrase)); + return 1; + } + int commandNumber = commandBelongs(theCommand); + if (commandNumber == SIMPLECOMMAND) { + return addSimpleCommand(theCommand, doxyList); + } + if (commandNumber == IGNOREDSIMPLECOMMAND) { + return ignoreSimpleCommand(theCommand, doxyList); + } + if (commandNumber == COMMANDWORD) { + return addCommandWord(theCommand, tokList, doxyList); + } + if (commandNumber == IGNOREDCOMMANDWORD) { + return ignoreCommandWord(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDLINE) { + return addCommandLine(theCommand, tokList, doxyList); + } + if (commandNumber == IGNOREDCOMMANDLINE) { + return ignoreCommandLine(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDPARAGRAPH) { + return addCommandParagraph(theCommand, tokList, doxyList); + } + if (commandNumber == IGNORECOMMANDPARAGRAPH) { + return ignoreCommandParagraph(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDENDCOMMAND) { + return addCommandEndCommand(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDWORDPARAGRAPH) { + return addCommandWordParagraph(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDWORDLINE) { + return addCommandWordLine(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDWORDOWORDWORD) { + return addCommandWordOWordOWord(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDOWORD) { + return addCommandOWord(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDERRORTHROW) { + return addCommandErrorThrow(theCommand, tokList, doxyList); + } + if (commandNumber == COMMANDUNIQUE) { return addCommandUnique(theCommand, tokList, doxyList); - } - - return 0; - } + } -std::list parse(std::list::iterator endParsingIndex, TokenList &tokList){ - std::list aNewList; + return 0; +} + +std::list < DoxygenEntity > parse(std::list < Token >::iterator endParsingIndex, TokenList & tokList) { + std::list < DoxygenEntity > aNewList; int currCommand; - while (tokList.current() != endParsingIndex){ + while (tokList.current() != endParsingIndex) { Token currToken = tokList.peek(); - if(noisy) + if (noisy) cout << "Parsing for phrase starting in:" << currToken.toString() << endl; - if(currToken.tokenType == END_LINE ){ + if (currToken.tokenType == END_LINE) { tokList.next(); - } - else if(currToken.tokenType == COMMAND){ + } else if (currToken.tokenType == COMMAND) { currCommand = findCommand(currToken.tokenString); - if (currCommand < 0 ){ - if(noisy) + if (currCommand < 0) { + if (noisy) cout << "Unidentified Command " << currToken.tokenString << endl; tokList.next(); addCommand(std::string("plainstd::string"), tokList, aNewList); + } else { + tokList.next(); + addCommand(currToken.tokenString, tokList, aNewList); } - else { tokList.next(); - addCommand(currToken.tokenString, tokList, aNewList); - } - } - else if (currToken.tokenType == PLAINSTRING){ + } else if (currToken.tokenType == PLAINSTRING) { addCommand(std::string("plainstd::string"), tokList, aNewList); } break; @@ -776,50 +802,48 @@ std::list parse(std::list::iterator endParsingIndex, Token return aNewList; } -std::list parseRoot(std::list::iterator endParsingIndex, TokenList &tokList){ +std::list < DoxygenEntity > parseRoot(std::list < Token >::iterator endParsingIndex, TokenList & tokList) { - std::list aNewList; + std::list < DoxygenEntity > aNewList; int currCommand; - while (tokList.current() != endParsingIndex){ + while (tokList.current() != endParsingIndex) { Token currToken = tokList.peek(); - if(noisy) { + if (noisy) { cout << "Parsing for phrase starting in:" << currToken.toString() << endl; } - if(currToken.tokenType == END_LINE ){ + if (currToken.tokenType == END_LINE) { tokList.next(); - } - else if(currToken.tokenType == COMMAND){ + } else if (currToken.tokenType == COMMAND) { currCommand = findCommand(currToken.tokenString); - if (currCommand < 0 ){ - if(noisy) { + if (currCommand < 0) { + if (noisy) { cout << "Unidentified Command " << currToken.tokenString << endl; } tokList.next(); addCommand(std::string("partofdescription"), tokList, aNewList); - } else { - tokList.next(); - addCommand(currToken.tokenString, tokList, aNewList); + } else { + tokList.next(); + addCommand(currToken.tokenString, tokList, aNewList); } - } - else if (currToken.tokenType == PLAINSTRING){ + } else if (currToken.tokenType == PLAINSTRING) { addCommand(std::string("partofdescription"), tokList, aNewList); } } return aNewList; } -std::list DoxygenParser::createTree(std::string doxygenBlob){ +std::list < DoxygenEntity > DoxygenParser::createTree(std::string doxygenBlob) { TokenList tokList = TokenList(doxygenBlob); - if(noisy) { + if (noisy) { cout << "---TOKEN LIST---" << endl; tokList.printList(); } - std::list rootList; - rootList = parseRoot( tokList.end(), tokList); - if(noisy) { + std::list < DoxygenEntity > rootList; + rootList = parseRoot(tokList.end(), tokList); + if (noisy) { cout << "PARSED LIST" << endl; printTree(rootList); } diff --git a/Source/DoxygenTranslator/src/DoxygenParser.h b/Source/DoxygenTranslator/src/DoxygenParser.h index 2269e6788..c298a92f3 100644 --- a/Source/DoxygenTranslator/src/DoxygenParser.h +++ b/Source/DoxygenTranslator/src/DoxygenParser.h @@ -3,12 +3,11 @@ #include #include #include "DoxygenEntity.h" -class DoxygenParser -{ +class DoxygenParser { public: DoxygenParser(); virtual ~DoxygenParser(); - std::list createTree(std::string doxygen); + std::list < DoxygenEntity > createTree(std::string doxygen); }; -#endif /*DOXYGENPARSER_H_*/ +#endif diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp index 025670796..6fe97d298 100644 --- a/Source/DoxygenTranslator/src/DoxygenTranslator.cpp +++ b/Source/DoxygenTranslator/src/DoxygenTranslator.cpp @@ -12,21 +12,21 @@ #include "JavaDocConverter.h" #include "PyDocConverter.h" -bool DoxygenTranslator::getDocumentation(Node *node, DocumentationFormat format, String *&documentation){ - switch(format){ - case JavaDoc: - return JavaDocConverter().getDocumentation(node, documentation); - case PyDoc: - return PyDocConverter().getDocumentation(node, documentation); - default: - return false; +bool DoxygenTranslator::getDocumentation(Node *node, DocumentationFormat format, String *&documentation) { + switch (format) { + case JavaDoc: + return JavaDocConverter().getDocumentation(node, documentation); + case PyDoc: + return PyDocConverter().getDocumentation(node, documentation); + default: + return false; } } -void DoxygenTranslator::printTree(std::list &entityList){ - std::list::iterator p = entityList.begin(); - while (p != entityList.end()){ +void DoxygenTranslator::printTree(std::list < DoxygenEntity > &entityList) { + std::list < DoxygenEntity >::iterator p = entityList.begin(); + while (p != entityList.end()) { (*p).printEntity(0); p++; } -} \ No newline at end of file +} diff --git a/Source/DoxygenTranslator/src/DoxygenTranslator.h b/Source/DoxygenTranslator/src/DoxygenTranslator.h index 4be1e97e3..566b1551d 100644 --- a/Source/DoxygenTranslator/src/DoxygenTranslator.h +++ b/Source/DoxygenTranslator/src/DoxygenTranslator.h @@ -28,14 +28,13 @@ enum DocumentationFormat { * A class to translate doxygen comments attacted to parser nodes * into alternative formats for use in code generated for target languages. */ -class DoxygenTranslator -{ +class DoxygenTranslator { public: /* * Virtual destructor. */ - virtual ~DoxygenTranslator(){} - + virtual ~ DoxygenTranslator() { + } /* * Return the documentation for a given node formated for the correct * documentation system. @@ -45,7 +44,7 @@ public: * @return A bool to indicate if there was documentation to return for the node. */ static bool getDocumentation(Node *node, DocumentationFormat format, String *&documentation); - + protected: /* * Overridden in subclasses to return the documentation formatted for a given @@ -55,11 +54,11 @@ protected: * @return A bool to indicate if there was documentation to return for the node. */ virtual bool getDocumentation(Node *node, String *&documentation) = 0; - + /* * Prints the details of a parsed entity list to stdout (for debugging). */ - void printTree(std::list &entityList); + void printTree(std::list < DoxygenEntity > &entityList); }; -#endif /*DOXYGENTRANSLATOR_H_*/ +#endif diff --git a/Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.cpp b/Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.cpp index dacb31f77..930141c97 100644 --- a/Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.cpp +++ b/Source/DoxygenTranslator/src/Examples/DoxygenTransWTokenizer.cpp @@ -1,7 +1,5 @@ /* The main class for translating blobs of Doxygen for SWIG * by Cheryl Foil, mentor Olly Betts, for Google's Summer of Code Program - * Currently the spacing/format on this is a bit goofy in places, due to shuffling code - * between 2 editors! Apologies for anyone combing through it :) */ //TODO DOH instead of STL? //TODO Most commands are not fully implemented @@ -40,8 +38,8 @@ to test. */ int testCodeCrawlingFunctions = 0; int demonstrateParsing = 0; int runExamples = 0; -int noisy = 0; // set this to 1 for extra chatter from the parsing stage. -int addCommand(string commandName, int &startInd, list &doxyList, string doxygenString); +int noisy = 0; // set this to 1 for extra chatter from the parsing stage. +int addCommand(string commandName, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString); ////////////////////////////////////////// @@ -51,162 +49,203 @@ int addCommand(string commandName, int &startInd, list &doxyList // An array of all the commands and my generic description tag, plaindescription -string commandArray[] = {"a", "addindex", "addtogroup", "anchor", "arg", "attention", - "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", - "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", - "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", - "else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif", - "endlatexonly", "endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", - "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", - "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", - "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", - "line", "link", "mainpage", "manonly", "msc", "n", "name", "namespace", "nosubgrouping", - "note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre", - "private", "privatesection", "property", "protected", "protectedsection", "protocol", - "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval", - "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", - "subsection", "subsubsection", "test", "throw", "todo", "tparam", "typedef", "union", "until", - "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", - "$", "@", "//","&", "~", "<", ">", "#", "%"}; +string commandArray[] = { "a", "addindex", "addtogroup", "anchor", "arg", "attention", + "author", "b", "brief", "bug", "c", "callgraph", "callergraph", "category", + "class", "code", "cond", "copybrief", "copydetails", "copydoc", "date", "def", + "defgroup", "deprecated", "details", "dir", "dontinclude", "dot", "dotfile", "e", + "else", "elseif", "em", "endcode", "endcond", "enddot", "endhtmlonly", "endif", + "endlatexonly", "endlink", "endmanonly", "endmsc", "endverbatim", "endxmlonly", + "enum", "example", "exception", "f$", "f[", "f]", "f{", "f}", "file", "fn", "headerfile", + "hideinitializer", "htmlinclude", "htmlonly", "if", "ifnot", "image", "include", + "includelineno", "ingroup", "internal", "invariant", "interface", "latexonly", "li", + "line", "link", "mainpage", "manonly", "msc", "n", "name", "namespace", "nosubgrouping", + "note", "overload", "p", "package", "page", "par", "paragraph", "param", "post", "pre", + "private", "privatesection", "property", "protected", "protectedsection", "protocol", + "public", "publicsection", "ref", "relates", "relatesalso", "remarks", "return", "retval", + "sa", "section", "see", "showinitializer", "since", "skip", "skipline", "struct", "subpage", + "subsection", "subsubsection", "test", "throw", "todo", "tparam", "typedef", "union", "until", + "var", "verbatim", "verbinclude", "version", "warning", "weakgroup", "xmlonly", "xrefitem", + "$", "@", "//", "&", "~", "<", ">", "#", "%" +}; string sectionIndicators[] = { "attention", "author", "brief", "bug", "cond", "date", "deprecated", "details", - "else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param", - "tparam", "post" , "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "todo", - "version", "warning", "xrefitem" }; + "else", "elseif", "endcond", "endif", "exception", "if", "ifnot", "invariant", "note", "par", "param", + "tparam", "post", "pre", "remarks", "return", "retval", "sa", "see", "since", "test", "throw", "todo", + "version", "warning", "xrefitem" +}; /* All of the doxygen commands divided up by how they are parsed */ -string simpleCommands[] = {"n", "$", "@", "//", "&", "~", "<", ">", "#", "%"}; -string ignoredSimpleCommands[] = {"nothing at the moment"}; -string commandWords[] = {"a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", - "relates", "namespace", "relatesalso","anchor", "dontinclude", "include", "includelineno"}; -string ignoredCommandWords[] = {"copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude"}; -string commandLines[] = {"addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property"}; -string ignoreCommandLines[] = {"nothing at the moment"}; -string commandParagraph[] = {"return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", - "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "arg", "author"}; -string ignoreCommandParagraphs[] = {"nothing at the moment"}; -string commandEndCommands[] = {"code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", - "verbatim", "xmlonly", "cond", "if", "ifnot", "link"}; -string commandWordParagraphs[] = {"param", "tparam", "throw", "retval", "exception"}; -string commandWordLines[] = {"page", "subsection", "subsubsection", "section", "paragraph", "defgroup"}; -string commandWordOWordOWords [] = {"category", "class", "protocol", "interface", "struct", "union"}; -string commandOWords[] = {"dir", "file", "cond"}; -string commandErrorThrowings[] = {"annotatedclasslist", "classhierarchy", "define", "functionindex", "header", - "headerfilelist", "inherit", "l", "postheader", "private", "privatesection", "protected", - "protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly", - "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endcond", - "endif"}; -string commandUniques[] = {"xrefitem", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", - "subpage", "dotfile", "image", "addtogroup", "li"}; +string simpleCommands[] = { "n", "$", "@", "//", "&", "~", "<", ">", "#", "%" }; +string ignoredSimpleCommands[] = { "nothing at the moment" }; + +string commandWords[] = { "a", "b", "c", "e", "em", "p", "def", "enum", "example", "package", + "relates", "namespace", "relatesalso", "anchor", "dontinclude", "include", "includelineno" +}; +string ignoredCommandWords[] = { "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude" }; +string commandLines[] = { "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property" }; +string ignoreCommandLines[] = { "nothing at the moment" }; + +string commandParagraph[] = { "return", "remarks", "since", "test", "sa", "see", "pre", "post", "details", "invariant", + "deprecated", "date", "note", "warning", "version", "todo", "bug", "attention", "brief", "arg", "author" +}; +string ignoreCommandParagraphs[] = { "nothing at the moment" }; + +string commandEndCommands[] = { "code", "dot", "msc", "f$", "f[", "f{environment}{", "htmlonly", "latexonly", "manonly", + "verbatim", "xmlonly", "cond", "if", "ifnot", "link" +}; +string commandWordParagraphs[] = { "param", "tparam", "throw", "retval", "exception" }; +string commandWordLines[] = { "page", "subsection", "subsubsection", "section", "paragraph", "defgroup" }; +string commandWordOWordOWords[] = { "category", "class", "protocol", "interface", "struct", "union" }; +string commandOWords[] = { "dir", "file", "cond" }; + +string commandErrorThrowings[] = { "annotatedclasslist", "classhierarchy", "define", "functionindex", "header", + "headerfilelist", "inherit", "l", "postheader", "private", "privatesection", "protected", + "protectedsection", "public", "publicsection", "endcode", "enddot", "endmsc", "endhtmlonly", + "endlatexonly", "endmanonly", "endlink", "endverbatim", "endxmlonly", "f]", "f}", "endcond", + "endif" +}; + +string commandUniques[] = { "xrefitem", "ingroup", "par", "headerfile", "overload", "weakgroup", "ref", + "subpage", "dotfile", "image", "addtogroup", "li" +}; //int startIndex = 0; - int isNewLine = 0; - int briefDescExists = 0; +int isNewLine = 0; +int briefDescExists = 0; /* Entity list is the root list. * it is arranged this way to help documentation modules, * such as the javaDoc one, "sort" entities where they need to. */ - list rootList; +list < DoxygenEntity > rootList; /* General (untested) assist methods */ - string StringToLower(string stringToConvert) +string StringToLower(string stringToConvert) +{ + //change each element of the string to lower case - {//change each element of the string to lower case - - for(unsigned int i=0;i= doxygenString.length()) return ""; - int startIndex = startInd; - int endIndex = startInd; - string description; - /* Find the End of the description */ - int keepLooping = 1; - int spareIndex = 0; - int counter; - int finalIndex; - while(keepLooping){ - if(endIndex >= doxygenString.length()){ - finalIndex = endIndex; - keepLooping = 0; - } - else if (doxygenString[endIndex] == '\n'){ - //cout << "1 "; - counter = endIndex; - if ( keepLooping && endIndex < doxygenString.length()-1) { - counter++; - //cout << "Counter :" << counter << endl; - while(keepLooping && endIndex < doxygenString.length() && (doxygenString[counter] == ' ' || - doxygenString[counter] == '*'|| doxygenString[counter] == '\n'|| doxygenString[counter] == '/' - || doxygenString[counter] == '!' || doxygenString[startIndex] == '\t') ){ - if(doxygenString[counter] == '\n') { - //cout << "Blank line found" << endl; - keepLooping = 0; - finalIndex = counter;} - else{ counter++;} - } +string getStringTilCommand(int &startInd, string doxygenString) { + if (startInd >= doxygenString.length()) + return ""; + int startIndex = startInd; + int endIndex = startInd; + string description; + /* Find the End of the description */ + int keepLooping = 1; + int spareIndex = 0; + int counter; + int finalIndex; + while (keepLooping) { + if (endIndex >= doxygenString.length()) { + finalIndex = endIndex; + keepLooping = 0; + } else if (doxygenString[endIndex] == '\n') { + //cout << "1 "; + counter = endIndex; + if (keepLooping && endIndex < doxygenString.length() - 1) { + counter++; + //cout << "Counter :" << counter << endl; + while (keepLooping && endIndex < doxygenString.length() && (doxygenString[counter] == ' ' || + doxygenString[counter] == '*' || doxygenString[counter] == '\n' + || doxygenString[counter] == '/' || doxygenString[counter] == '!' + || doxygenString[startIndex] == '\t')) { + if (doxygenString[counter] == '\n') { + //cout << "Blank line found" << endl; + keepLooping = 0; + finalIndex = counter; + } else { + counter++; + } + } - } - //endIndex = counter; - } - else if (doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@'){ - finalIndex = endIndex; - keepLooping = 0; - } - else if(endIndex < doxygenString.length() -2 - && string("**/").compare(doxygenString.substr(endIndex , endIndex + 2)) == 0){ - finalIndex = endIndex; - //cout << "3 "; - keepLooping = 0; - } - if(keepLooping){ - //cout << "4 "; - endIndex++; - } - } - //cout << "Done with EndIndex" << endl; - while(doxygenString[startIndex] == '!' || doxygenString[startIndex] == ' ' - || doxygenString[startIndex] == '/' || doxygenString[startIndex] == '*' || doxygenString[startIndex] == '\t') startIndex++; + } + //endIndex = counter; + } else if (doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@') { + finalIndex = endIndex; + keepLooping = 0; + } else if (endIndex < doxygenString.length() - 2 && string("**/").compare(doxygenString.substr(endIndex, endIndex + 2)) == 0) { + finalIndex = endIndex; + //cout << "3 "; + keepLooping = 0; + } + if (keepLooping) { + //cout << "4 "; + endIndex++; + } + } + //cout << "Done with EndIndex" << endl; + while (doxygenString[startIndex] == '!' || doxygenString[startIndex] == ' ' + || doxygenString[startIndex] == '/' || doxygenString[startIndex] == '*' || doxygenString[startIndex] == '\t') + startIndex++; - for (int i = startIndex; i < endIndex; i++){ + for (int i = startIndex; i < endIndex; i++) { + + if (doxygenString[i] == '\n') { + + while ((doxygenString[i] == '\n' || doxygenString[startIndex] == '\t' || doxygenString[i] == ' ' + || doxygenString[i] == '*' || doxygenString[i] == '/') && endIndex < doxygenString.length() - 1) { + i++; + } + description.append(" "); + } + description.push_back(doxygenString[i]); + //cout << doxygenString[i]; + } + //if(noisy) cout << "Final Index is: " << finalIndex << endl; + startInd = finalIndex; + return description; +} - if (doxygenString[i] == '\n') { - while ((doxygenString[i] == '\n' || doxygenString[startIndex] == '\t'|| doxygenString[i] == ' ' - || doxygenString[i] == '*' || doxygenString[i] == '/')&& endIndex < doxygenString.length() - 1){ - i++; - } - description.append(" "); - } - description.push_back(doxygenString[i]); - //cout << doxygenString[i]; - } - //if(noisy) cout << "Final Index is: " << finalIndex << endl; - startInd = finalIndex; - return description; - } - - /* Returns a Paragraph- defined in Doxygen to be a paragraph of text * seperate by either a structural command or a blank line * This method is VERY messy currently */ //TODO fix getStringTilEndOfParagraph to be more forgiving, work on ' ' characters - string getStringTilEndOfParagraph(int &startInd, string doxygenString){ - if (startInd >= doxygenString.length()) return ""; - int startIndex = startInd; - int endIndex = startInd; - string description; - /* Find the End of the description */ - int keepLooping = 1; - int spareIndex = 0; - int counter; - int finalIndex; - while(keepLooping){ - if(endIndex >= doxygenString.length()){ - finalIndex = endIndex; - keepLooping = 0; - } - else if (doxygenString[endIndex] == '\n'){ - //cout << "1 "; - counter = endIndex; - if ( keepLooping && endIndex < doxygenString.length()-1) { - counter++; - //cout << "Counter :" << counter << endl; - while(keepLooping && endIndex < doxygenString.length() && (doxygenString[counter] == ' ' || - doxygenString[counter] == '*'|| doxygenString[startIndex] == '\t' || doxygenString[counter] == '\n'|| doxygenString[counter] == '/' - || doxygenString[counter] == '!') ){ - if(doxygenString[counter] == '\n') { - //cout << "Blank line found" << endl; - keepLooping = 0; - finalIndex = counter;} - else{ counter++;} - } +string getStringTilEndOfParagraph(int &startInd, string doxygenString) { + if (startInd >= doxygenString.length()) + return ""; + int startIndex = startInd; + int endIndex = startInd; + string description; + /* Find the End of the description */ + int keepLooping = 1; + int spareIndex = 0; + int counter; + int finalIndex; + while (keepLooping) { + if (endIndex >= doxygenString.length()) { + finalIndex = endIndex; + keepLooping = 0; + } else if (doxygenString[endIndex] == '\n') { + //cout << "1 "; + counter = endIndex; + if (keepLooping && endIndex < doxygenString.length() - 1) { + counter++; + //cout << "Counter :" << counter << endl; + while (keepLooping && endIndex < doxygenString.length() && (doxygenString[counter] == ' ' || + doxygenString[counter] == '*' || doxygenString[startIndex] == '\t' + || doxygenString[counter] == '\n' || doxygenString[counter] == '/' + || doxygenString[counter] == '!')) { + if (doxygenString[counter] == '\n') { + //cout << "Blank line found" << endl; + keepLooping = 0; + finalIndex = counter; + } else { + counter++; + } + } - } - //endIndex = counter; - } - //todo this fix for not immediately exciting while parsing a paragraph seems somewhat cheap - else if (endIndex != startInd && doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@'){ - spareIndex = endIndex +1; - - if (isSectionIndicator(getNextWord(spareIndex, doxygenString))) { - keepLooping = 0; - finalIndex = endIndex;} - } - else if(endIndex < doxygenString.length() - 1 - && string("*/").compare(doxygenString.substr(endIndex , endIndex + 1)) == 0){ - keepLooping = 0; - finalIndex = endIndex; - } - if(keepLooping){ - endIndex++; - } - } - //cout << "Done with EndIndex" << endl; - while(doxygenString[startIndex] == '!' || doxygenString[startIndex] == ' ' || doxygenString[startIndex] == '\t' - || doxygenString[startIndex] == '/' || doxygenString[startIndex] == '*') startIndex++; + } + //endIndex = counter; + } + //todo this fix for not immediately exciting while parsing a paragraph seems somewhat cheap + else if (endIndex != startInd && doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@') { + spareIndex = endIndex + 1; - for (int i = startIndex; i < endIndex; i++){ + if (isSectionIndicator(getNextWord(spareIndex, doxygenString))) { + keepLooping = 0; + finalIndex = endIndex; + } + } else if (endIndex < doxygenString.length() - 1 && string("*/").compare(doxygenString.substr(endIndex, endIndex + 1)) == 0) { + keepLooping = 0; + finalIndex = endIndex; + } + if (keepLooping) { + endIndex++; + } + } + //cout << "Done with EndIndex" << endl; + while (doxygenString[startIndex] == '!' || doxygenString[startIndex] == ' ' || doxygenString[startIndex] == '\t' + || doxygenString[startIndex] == '/' || doxygenString[startIndex] == '*') + startIndex++; - if (doxygenString[i] == '\n') { + for (int i = startIndex; i < endIndex; i++) { - while ((doxygenString[i] == '\n' || doxygenString[startIndex] == '\t' || doxygenString[i] == ' ' ||doxygenString[startIndex] == '!' - || doxygenString[i] == '*' || doxygenString[i] == '/')&& endIndex < doxygenString.length() - 1){ - i++; - } - description.append(" "); - } - description.push_back(doxygenString[i]); - //cout << doxygenString[i]; - } - startInd = finalIndex; - return description; - } + if (doxygenString[i] == '\n') { + + while ((doxygenString[i] == '\n' || doxygenString[startIndex] == '\t' || doxygenString[i] == ' ' || doxygenString[startIndex] == '!' + || doxygenString[i] == '*' || doxygenString[i] == '/') && endIndex < doxygenString.length() - 1) { + i++; + } + description.append(" "); + } + description.push_back(doxygenString[i]); + //cout << doxygenString[i]; + } + startInd = finalIndex; + return description; +} /* This method is for a specific form of doxygen command * that begins with a \command and ends in \endcommand @@ -440,263 +488,280 @@ string getStringTilCommand(int &startInd, string doxygenString){ * currently this method does NOT process what is in between the two commands */ //TODO Make progressTilCommand return a formatted string - int progressTilEndCommand(string theCommand, int &startInd, string doxygenString){ - int endIndex = startInd; - while (endIndex < doxygenString.length()){ - if (doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@'){ - //cout << doxygenString.substr(endIndex + 1 , theCommand.length())<< endl; - if (theCommand.compare(doxygenString.substr(endIndex + 1 , theCommand.length())) == 0){ - startInd = endIndex + theCommand.length() + 1; - return 1; - } - } - endIndex++; - } - //End command not found - return 0; - } +int progressTilEndCommand(string theCommand, int &startInd, string doxygenString) { + int endIndex = startInd; + while (endIndex < doxygenString.length()) { + if (doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@') { + //cout << doxygenString.substr(endIndex + 1 , theCommand.length())<< endl; + if (theCommand.compare(doxygenString.substr(endIndex + 1, theCommand.length())) == 0) { + startInd = endIndex + theCommand.length() + 1; + return 1; + } + } + endIndex++; + } + //End command not found + return 0; +} /* A specialty method for commands such as \arg that end at the end of a paragraph OR when another \arg is encountered */ - - string getStringTilAnyCommand(string theCommand, int &startInd, string doxygenString){ - if (startInd >= doxygenString.length()) return ""; - int startIndex = startInd; - int endIndex = startInd; - string description; - /* Find the End of the description */ - int keepLooping = 1; - int spareIndex = 0; - int counter; - int finalIndex; - while(keepLooping){ - if(endIndex >= theCommand.length()){ - finalIndex = endIndex; - keepLooping = 0; - } - else if (doxygenString[endIndex] == '\n'){ - //cout << "1 "; - counter = endIndex; - if ( keepLooping && endIndex < doxygenString.length()-1) { - counter++; - //cout << "Counter :" << counter << endl; - while(keepLooping && endIndex < doxygenString.length() && (doxygenString[counter] == ' ' || - doxygenString[counter] == '*'|| doxygenString[counter] == '\n'|| doxygenString[counter] == '/' - || doxygenString[counter] == '!' || doxygenString[startIndex] == '\t') ){ - if(doxygenString[counter] == '\n') { - //cout << "Blank line found" << endl; - keepLooping = 0; - finalIndex = counter;} - else{ counter++;} - } - } - //endIndex = counter; - } - else if (doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@'){ - //cout << "2 "; - spareIndex = endIndex; - if (endIndex + theCommand.length() < theCommand.length() - && theCommand.compare(doxygenString.substr(endIndex, theCommand.length())) == 0) keepLooping = 0; - } - else if(endIndex < doxygenString.length() - 1 - && string("*/").compare(doxygenString.substr(endIndex , endIndex + 1)) == 0){ - //cout << "3 "; - keepLooping = 0; - } - if(keepLooping){ - //cout << "4 "; - endIndex++; - } - } - //cout << "Done with EndIndex" << endl; - while(doxygenString[startIndex] == '!' || doxygenString[startIndex] == ' ' - || doxygenString[startIndex] == '/' || doxygenString[startIndex] == '*' || doxygenString[startIndex] == '\t') startIndex++; +string getStringTilAnyCommand(string theCommand, int &startInd, string doxygenString) { + if (startInd >= doxygenString.length()) + return ""; + int startIndex = startInd; + int endIndex = startInd; + string description; + /* Find the End of the description */ + int keepLooping = 1; + int spareIndex = 0; + int counter; + int finalIndex; + while (keepLooping) { + if (endIndex >= theCommand.length()) { + finalIndex = endIndex; + keepLooping = 0; + } else if (doxygenString[endIndex] == '\n') { + //cout << "1 "; + counter = endIndex; + if (keepLooping && endIndex < doxygenString.length() - 1) { + counter++; + //cout << "Counter :" << counter << endl; + while (keepLooping && endIndex < doxygenString.length() && (doxygenString[counter] == ' ' || + doxygenString[counter] == '*' || doxygenString[counter] == '\n' + || doxygenString[counter] == '/' || doxygenString[counter] == '!' + || doxygenString[startIndex] == '\t')) { + if (doxygenString[counter] == '\n') { + //cout << "Blank line found" << endl; + keepLooping = 0; + finalIndex = counter; + } else { + counter++; + } + } - for (int i = startIndex; i < endIndex; i++){ + } + //endIndex = counter; + } else if (doxygenString[endIndex] == '\\' || doxygenString[endIndex] == '@') { + //cout << "2 "; + spareIndex = endIndex; + if (endIndex + theCommand.length() < theCommand.length() + && theCommand.compare(doxygenString.substr(endIndex, theCommand.length())) == 0) + keepLooping = 0; + } else if (endIndex < doxygenString.length() - 1 && string("*/").compare(doxygenString.substr(endIndex, endIndex + 1)) == 0) { + //cout << "3 "; + keepLooping = 0; + } + if (keepLooping) { + //cout << "4 "; + endIndex++; + } + } + //cout << "Done with EndIndex" << endl; + while (doxygenString[startIndex] == '!' || doxygenString[startIndex] == ' ' + || doxygenString[startIndex] == '/' || doxygenString[startIndex] == '*' || doxygenString[startIndex] == '\t') + startIndex++; - if (doxygenString[i] == '\n') { + for (int i = startIndex; i < endIndex; i++) { - while ((doxygenString[i] == '\n' || doxygenString[i] == ' ' || doxygenString[startIndex] == '\t' - || doxygenString[i] == '*' || doxygenString[i] == '/')&& endIndex < doxygenString.length() - 1){ - i++; - } - description.append(" "); - } - description.push_back(doxygenString[i]); - //cout << doxygenString[i]; - } - startInd = finalIndex; - return description; - } + if (doxygenString[i] == '\n') { + + while ((doxygenString[i] == '\n' || doxygenString[i] == ' ' || doxygenString[startIndex] == '\t' + || doxygenString[i] == '*' || doxygenString[i] == '/') && endIndex < doxygenString.length() - 1) { + i++; + } + description.append(" "); + } + description.push_back(doxygenString[i]); + //cout << doxygenString[i]; + } + startInd = finalIndex; + return description; +} /* prints the parse tree * */ - void printTree(){ +void printTree() { - list::iterator p = rootList.begin(); - while (p != rootList.end()){ - (*p).printEntity(0); - p++; - } + list < DoxygenEntity >::iterator p = rootList.begin(); + while (p != rootList.end()) { + (*p).printEntity(0); + p++; + } - } - - - - list parse(int startInd, string doxygenString){ - string currWord; - int startIndex = startInd; - int savedIndex; - list aNewList; - int endIndex = doxygenString.length(); - int currCommand; - while (startIndex < endIndex){ - savedIndex = startIndex; - currWord = getNextWord(startIndex, doxygenString); - if(noisy) cout << "Parsing for phrase starting in:" << currWord << endl; - if(currWord == ""){ - if (startIndex < endIndex) startIndex++; - } - else if(currWord[0] == '\\' || currWord[0] == '@'){ - currWord = currWord.substr(1, currWord.length() - 1); - currCommand = findCommand(currWord); - if (currCommand < 0 ){ if(noisy) cout << "BAD COMMAND: " << currWord << endl;} - //cout << "Command: " << currWord << " " << currCommand << endl; - else addCommand(currWord, startIndex, aNewList, doxygenString); - } - else{ - startIndex = savedIndex; - addCommand(string("plainstd::string"), startIndex, aNewList, doxygenString); +} - } - } - return aNewList; - } - + +list < DoxygenEntity > parse(int startInd, string doxygenString) { + string currWord; + int startIndex = startInd; + int savedIndex; + list < DoxygenEntity > aNewList; + int endIndex = doxygenString.length(); + int currCommand; + while (startIndex < endIndex) { + savedIndex = startIndex; + currWord = getNextWord(startIndex, doxygenString); + if (noisy) + cout << "Parsing for phrase starting in:" << currWord << endl; + if (currWord == "") { + if (startIndex < endIndex) + startIndex++; + } else if (currWord[0] == '\\' || currWord[0] == '@') { + currWord = currWord.substr(1, currWord.length() - 1); + currCommand = findCommand(currWord); + if (currCommand < 0) { + if (noisy) + cout << "BAD COMMAND: " << currWord << endl; + } + //cout << "Command: " << currWord << " " << currCommand << endl; + else + addCommand(currWord, startIndex, aNewList, doxygenString); + } else { + startIndex = savedIndex; + addCommand(string("plainstd::string"), startIndex, aNewList, doxygenString); + + } + } + + return aNewList; +} + /* Method for Adding a Simple Command * Format: @command * Plain commands, such as newline etc, they contain no other data * \n \\ \@ \& \$ \# \< \> \% */ - int addSimpleCommand(string theCommand, int &startInd, list &doxyList, string doxygenString){ - - if (noisy) cout << "Parsing " << theCommand << endl; - doxyList.push_back(DoxygenEntity(theCommand)); - return 1; - } - +int addSimpleCommand(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { + + if (noisy) + cout << "Parsing " << theCommand << endl; + doxyList.push_back(DoxygenEntity(theCommand)); + return 1; +} + /* NOT INCLUDED Simple Commands * Format: @command * Plain commands, such as newline etc, they contain no other data */ - int ignoreSimpleCommand(string theCommand, int &startInd, list &doxyList, string doxygenString){ - - if (noisy) cout << "Not Adding " << theCommand << endl; - return 1; - } - +int ignoreSimpleCommand(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { + + if (noisy) + cout << "Not Adding " << theCommand << endl; + return 1; +} + /* CommandWord * Format: @command * 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" */ - int addCommandWord(string theCommand, int &startInd, list &doxyList, string doxygenString){ - if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(startInd, doxygenString); - if (!name.empty()){ - doxyList.push_back(DoxygenEntity(theCommand, name)); - return 1; - } - else cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } +int addCommandWord(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { + if (noisy) + cout << "Parsing " << theCommand << endl; + string name = getNextWord(startInd, doxygenString); + if (!name.empty()) { + doxyList.push_back(DoxygenEntity(theCommand, name)); + return 1; + } else + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; +} + /* NOT INCLUDED CommandWord * Format: @command * Commands with a single WORD after then such as @b * "copydoc", "copybrief", "copydetails", "verbinclude", "htmlinclude" */ - int ignoreCommandWord(string theCommand, int &startInd, list &doxyList, string doxygenString){ - if (noisy) cout << "Not Adding " << theCommand << endl; - string name = getNextWord(startInd, doxygenString); - if (!name.empty()){ - return 1; - } - else cout << "WARNING: No word followed " << theCommand << " command." << endl; - return 0; - } - +int ignoreCommandWord(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { + if (noisy) + cout << "Not Adding " << theCommand << endl; + string name = getNextWord(startInd, doxygenString); + if (!name.empty()) { + return 1; + } else + cout << "WARNING: No word followed " << theCommand << " command." << endl; + return 0; +} + /* CommandLine * Format: @command (line) * Commands with a single LINE after then such as @var * "addindex", "fn", "name", "line", "var", "skipline", "typedef", "skip", "until", "property" */ - int addCommandLine(string theCommand, int &startInd, list &doxyList, string doxygenString){ - if (noisy) cout << "Parsing " << theCommand << endl; - string line = getOneLine(startInd, doxygenString); - if(!line.empty()){ - int placement = 0; - list aNewList; - aNewList = parse(placement, line); - doxyList.push_back( DoxygenEntity(theCommand, aNewList)); - return 1; - } - else cout << "No line followed " << theCommand << " command. Not added" << endl; - return 0; - } - +int addCommandLine(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { + if (noisy) + cout << "Parsing " << theCommand << endl; + string line = getOneLine(startInd, doxygenString); + if (!line.empty()) { + int placement = 0; + list < DoxygenEntity > aNewList; + aNewList = parse(placement, line); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + } else + cout << "No line followed " << theCommand << " command. Not added" << endl; + return 0; +} + /* NOT INCLUDED CommandLine * Format: @command (line) * Commands with a single LINE after then such as @var * */ - int ignoreCommandLine(string theCommand, int &startInd, list &doxyList, string doxygenString){ - if (noisy) cout << "Not Adding " << theCommand << endl; - string line = getOneLine(startInd, doxygenString); - if(!line.empty()){ - return 1; - } - else cout << "WARNING: No line followed " << theCommand << " command." << endl; - return 0; - } - +int ignoreCommandLine(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { + if (noisy) + cout << "Not Adding " << theCommand << endl; + string line = getOneLine(startInd, doxygenString); + if (!line.empty()) { + return 1; + } else + cout << "WARNING: No line followed " << theCommand << " command." << endl; + return 0; +} + /* 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" */ - int addCommandParagraph(string theCommand, int &startInd, list &doxyList, string doxygenString){ - if (noisy) cout << "Parsing " << theCommand << endl; - string restOfParagraph = getStringTilEndOfParagraph(startInd, doxygenString); - if(!restOfParagraph.empty()){ - int placement = 0; - list aNewList; - aNewList = parse(placement, restOfParagraph); - doxyList.push_back( DoxygenEntity(theCommand, aNewList)); - return 1; - } - else cout << "No line followed " << theCommand << " command. Not added" << endl; - return 0; - } +int addCommandParagraph(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { + if (noisy) + cout << "Parsing " << theCommand << endl; + string restOfParagraph = getStringTilEndOfParagraph(startInd, doxygenString); + if (!restOfParagraph.empty()) { + int placement = 0; + list < DoxygenEntity > aNewList; + aNewList = parse(placement, restOfParagraph); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + } else + cout << "No line followed " << theCommand << " command. Not added" << endl; + return 0; +} + /* CommandParagraph * Format: @command {paragraph} * Commands with a single LINE after then such as @var * */ - int ignoreCommandParagraph(string theCommand, int &startInd, list &doxyList, string doxygenString){ - if (noisy) cout << "Not Adding " << theCommand << endl; - string restOfParagraph = getStringTilEndOfParagraph(startInd, doxygenString); - if(!restOfParagraph.empty()){ - return 1; - } - else cout << "WARNING: No line followed " << theCommand << " command." << endl; - return 0; - } +int ignoreCommandParagraph(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { + if (noisy) + cout << "Not Adding " << theCommand << endl; + string restOfParagraph = getStringTilEndOfParagraph(startInd, doxygenString); + if (!restOfParagraph.empty()) { + return 1; + } else + cout << "WARNING: No line followed " << theCommand << " command." << endl; + return 0; +} + /* Command EndCommand * Format: @command and ends at @endcommand * Commands that take in a block of text such as @code @@ -704,221 +769,235 @@ string getStringTilCommand(int &startInd, string doxygenString){ * "verbatim", "xmlonly", "cond", "if", "ifnot", "link" * Returns 1 if success, 0 if the endcommand is never encountered. */ - - int ignoreCommandEndCommand(string theCommand, int &startInd, list &doxyList, string doxygenString){ - if (noisy) cout << "Not Adding " << theCommand << endl; - return progressTilEndCommand( "end" + theCommand, startInd, doxygenString); - - } - + +int ignoreCommandEndCommand(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { + if (noisy) + cout << "Not Adding " << theCommand << endl; + return progressTilEndCommand("end" + theCommand, startInd, doxygenString); + +} + /* CommandWordParagraph * Format: @command {paragraph} * Commands such as param * "param", "tparam", "throw", "retval", "exception" */ - int addCommandWordParagraph(string theCommand, int &startInd, list &doxyList, string doxygenString){ - if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(startInd, doxygenString); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - string restOfParagraph = getStringTilEndOfParagraph(startInd, doxygenString); - int placement = 0; - if(!restOfParagraph.empty()){ - list aNewList; - aNewList = parse(placement, restOfParagraph); - aNewList.push_front(DoxygenEntity("plainstd::string", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - } - else cout << "No paragraph followed " << theCommand << " command. Not added" << endl; - return 0; +int addCommandWordParagraph(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { + if (noisy) + cout << "Parsing " << theCommand << endl; + string name = getNextWord(startInd, doxygenString); + if (name.empty()) { + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; } + string restOfParagraph = getStringTilEndOfParagraph(startInd, doxygenString); + int placement = 0; + if (!restOfParagraph.empty()) { + list < DoxygenEntity > aNewList; + aNewList = parse(placement, restOfParagraph); + aNewList.push_front(DoxygenEntity("plainstd::string", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + } else + cout << "No paragraph followed " << theCommand << " command. Not added" << endl; + return 0; +} + /* CommandWordLine * Format: @command (line) * Commands such as param * "page", "subsection", "subsubsection", "section", "paragraph", "defgroup" */ - int addCommandWordLine(string theCommand, int &startInd, list &doxyList, string doxygenString){ - if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(startInd, doxygenString); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - string restOfLine = getStringTilEndOfParagraph(startInd, doxygenString); - int placement = 0; - if(!restOfLine.empty()){ - list aNewList; - aNewList = parse(placement, restOfLine); - aNewList.push_front(DoxygenEntity("plainstd::string", name)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; - } - else cout << "No line followed " << theCommand << " command. Not added" << endl; - return 0; +int addCommandWordLine(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { + if (noisy) + cout << "Parsing " << theCommand << endl; + string name = getNextWord(startInd, doxygenString); + if (name.empty()) { + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; } - + string restOfLine = getStringTilEndOfParagraph(startInd, doxygenString); + int placement = 0; + if (!restOfLine.empty()) { + list < DoxygenEntity > aNewList; + aNewList = parse(placement, restOfLine); + aNewList.push_front(DoxygenEntity("plainstd::string", name)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; + } else + cout << "No line followed " << theCommand << " command. Not added" << endl; + return 0; +} + /* Command Word Optional Word Optional Word * Format: @command [] [] * Commands such as class * "category", "class", "protocol", "interface", "struct", "union" */ - int addCommandWordOWordOWord(string theCommand, int &startInd, list &doxyList, string doxygenString){ - if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(startInd, doxygenString); - if (name.empty()){ - cout << "No word followed " << theCommand << " command. Not added" << endl; - return 0; - } - string headerfile = getNextWord(startInd, doxygenString); - string headername = getNextWord(startInd, doxygenString); - list aNewList; - aNewList.push_back(DoxygenEntity("plainstd::string", name)); - if (!headerfile.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", headerfile)); - if (!headername.empty()) aNewList.push_back(DoxygenEntity("plainstd::string", headername)); - doxyList.push_back(DoxygenEntity(theCommand, aNewList)); - return 1; +int addCommandWordOWordOWord(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { + if (noisy) + cout << "Parsing " << theCommand << endl; + string name = getNextWord(startInd, doxygenString); + if (name.empty()) { + cout << "No word followed " << theCommand << " command. Not added" << endl; + return 0; } - + string headerfile = getNextWord(startInd, doxygenString); + string headername = getNextWord(startInd, doxygenString); + list < DoxygenEntity > aNewList; + aNewList.push_back(DoxygenEntity("plainstd::string", name)); + if (!headerfile.empty()) + aNewList.push_back(DoxygenEntity("plainstd::string", headerfile)); + if (!headername.empty()) + aNewList.push_back(DoxygenEntity("plainstd::string", headername)); + doxyList.push_back(DoxygenEntity(theCommand, aNewList)); + return 1; +} + /* Command Optional Word * Format: @command [] * Commands such as dir * "dir", "file", "cond" */ - int addCommandOWord(string theCommand, int &startInd, list &doxyList, string doxygenString){ - if (noisy) cout << "Parsing " << theCommand << endl; - string name = getNextWord(startInd, doxygenString); - doxyList.push_back(DoxygenEntity(theCommand, name)); - return 1; - } - +int addCommandOWord(string theCommand, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { + if (noisy) + cout << "Parsing " << theCommand << endl; + string name = getNextWord(startInd, doxygenString); + doxyList.push_back(DoxygenEntity(theCommand, name)); + return 1; +} + /* The actual "meat" of the doxygen parser. This is not yet fully implemented * with my current design- however the skeletal outline is contained in * the file Skeleton */ - int addCommand(string commandString, int &startInd, list &doxyList, string doxygenString){ - string theCommand = StringToLower(commandString); - string voidArray[] = {""}; - /* @command */ +int addCommand(string commandString, int &startInd, list < DoxygenEntity > &doxyList, string doxygenString) { + string theCommand = StringToLower(commandString); + string voidArray[] = { "" }; + /* @command */ - - if (theCommand.compare("plainstd::string") == 0){ - string nextPhrase = getStringTilCommand(startInd, doxygenString); - if (noisy) cout << "Parsing plain string :" << nextPhrase << endl; - doxyList.push_back(DoxygenEntity("plainstd::string", nextPhrase )); - return 1; - } - int commandNumber = commandBelongs(theCommand); - if (commandNumber == SIMPLECOMMAND){ - return addSimpleCommand(theCommand, startInd,doxyList, doxygenString); - } - if (commandNumber == IGNOREDSIMPLECOMMAND){ - return ignoreSimpleCommand(theCommand, startInd,doxyList, doxygenString); - } - if (commandNumber == COMMANDWORD){ - return addCommandWord(theCommand, startInd,doxyList, doxygenString); - } - if (commandNumber == IGNOREDCOMMANDWORD){ - return ignoreCommandWord(theCommand, startInd,doxyList, doxygenString); - } - if (commandNumber == COMMANDLINE ){ - return addCommandLine(theCommand, startInd,doxyList, doxygenString); - } - if (commandNumber == IGNOREDCOMMANDLINE ){ - return ignoreCommandLine(theCommand, startInd,doxyList, doxygenString); - } - if (commandNumber == COMMANDPARAGRAPH){ - return addCommandParagraph(theCommand, startInd,doxyList, doxygenString); - } - if (commandNumber == IGNORECOMMANDPARAGRAPH){ - return ignoreCommandParagraph(theCommand, startInd,doxyList, doxygenString); - } - if (commandNumber == COMMANDENDCOMMAND){ - return ignoreCommandEndCommand(theCommand, startInd,doxyList, doxygenString); - } - if (commandNumber == COMMANDWORDPARAGRAPH){ - return addCommandWordParagraph(theCommand, startInd,doxyList, doxygenString); - } - if (commandNumber == COMMANDWORDLINE){ - return addCommandWordLine(theCommand, startInd,doxyList, doxygenString); - } - if (commandNumber == COMMANDWORDOWORDWORD){ - return addCommandWordOWordOWord(theCommand, startInd,doxyList, doxygenString); - } - if (commandNumber == COMMANDOWORD){ - return addCommandOWord(theCommand, startInd,doxyList, doxygenString); - } - if (commandNumber == COMMANDERRORTHROW){ - return 0; - } - if (commandNumber == COMMANDUNIQUE){ - return 0; - } - - return 0; - } - - int weirdTest(){ - string doxygenString = "this is a test."; - string restOfParagraph; - int startIndex = 0; - restOfParagraph = getStringTilEndOfParagraph(startIndex , doxygenString); - cout << restOfParagraph<< " " << startIndex << endl; - - startIndex = 0; - restOfParagraph = getStringTilCommand(startIndex, doxygenString); - cout << restOfParagraph<< " " << startIndex << endl; - } - + if (theCommand.compare("plainstd::string") == 0) { + string nextPhrase = getStringTilCommand(startInd, doxygenString); + if (noisy) + cout << "Parsing plain string :" << nextPhrase << endl; + doxyList.push_back(DoxygenEntity("plainstd::string", nextPhrase)); + return 1; + } + int commandNumber = commandBelongs(theCommand); + if (commandNumber == SIMPLECOMMAND) { + return addSimpleCommand(theCommand, startInd, doxyList, doxygenString); + } + if (commandNumber == IGNOREDSIMPLECOMMAND) { + return ignoreSimpleCommand(theCommand, startInd, doxyList, doxygenString); + } + if (commandNumber == COMMANDWORD) { + return addCommandWord(theCommand, startInd, doxyList, doxygenString); + } + if (commandNumber == IGNOREDCOMMANDWORD) { + return ignoreCommandWord(theCommand, startInd, doxyList, doxygenString); + } + if (commandNumber == COMMANDLINE) { + return addCommandLine(theCommand, startInd, doxyList, doxygenString); + } + if (commandNumber == IGNOREDCOMMANDLINE) { + return ignoreCommandLine(theCommand, startInd, doxyList, doxygenString); + } + if (commandNumber == COMMANDPARAGRAPH) { + return addCommandParagraph(theCommand, startInd, doxyList, doxygenString); + } + if (commandNumber == IGNORECOMMANDPARAGRAPH) { + return ignoreCommandParagraph(theCommand, startInd, doxyList, doxygenString); + } + if (commandNumber == COMMANDENDCOMMAND) { + return ignoreCommandEndCommand(theCommand, startInd, doxyList, doxygenString); + } + if (commandNumber == COMMANDWORDPARAGRAPH) { + return addCommandWordParagraph(theCommand, startInd, doxyList, doxygenString); + } + if (commandNumber == COMMANDWORDLINE) { + return addCommandWordLine(theCommand, startInd, doxyList, doxygenString); + } + if (commandNumber == COMMANDWORDOWORDWORD) { + return addCommandWordOWordOWord(theCommand, startInd, doxyList, doxygenString); + } + if (commandNumber == COMMANDOWORD) { + return addCommandOWord(theCommand, startInd, doxyList, doxygenString); + } + if (commandNumber == COMMANDERRORTHROW) { + return 0; + } + if (commandNumber == COMMANDUNIQUE) { + return 0; + } + + return 0; +} + +int weirdTest() { + string doxygenString = "this is a test."; + string restOfParagraph; + int startIndex = 0; + restOfParagraph = getStringTilEndOfParagraph(startIndex, doxygenString); + cout << restOfParagraph << " " << startIndex << endl; + + startIndex = 0; + restOfParagraph = getStringTilCommand(startIndex, doxygenString); + cout << restOfParagraph << " " << startIndex << endl; +} + + + +int doRunExamples() { + string line; + string filename; + string exampleNames[] = { "Examples/Example1", "Examples/Example2", "Examples/Example3", "Examples/Example4", "Examples/Example5" }; + int placement; + string doxygenString; + ifstream doxCommentFile; + for (int i = 0; i < 5; i++) { + doxCommentFile.open(exampleNames[i].c_str()); + doxCommentFile >> doxygenString; + while (getline(doxCommentFile, line)) { + doxygenString += line + "\n"; + } + doxCommentFile.close(); + placement = 0; + cout << "---RAW CODE---" << endl << doxygenString << endl << endl; + //clearFluff(placement, doxygenString); + //rootList = parse(placement, doxygenString); + TokenList tokList = TokenList(doxygenString); + tokList.printList(); + cout << "---THE TREE---" << endl; + printTree(); + } + return 1; +} + - int doRunExamples(){ - string line; - string filename; - string exampleNames[] = {"Examples/Example1","Examples/Example2", "Examples/Example3", "Examples/Example4", "Examples/Example5"}; - int placement; - string doxygenString; - ifstream doxCommentFile; - for (int i = 0; i < 5; i++){ - doxCommentFile.open(exampleNames[i].c_str()); - doxCommentFile >> doxygenString; - while(getline(doxCommentFile, line)){ - doxygenString += line + "\n";} - doxCommentFile.close(); - placement = 0; - cout << "---RAW CODE---" << endl << doxygenString << endl< */ -#define POUND_COMMAND 236 /* \# */ -#define PERCENT_COMMAND 237 /* \% */ +#define PROTOCOL 194 /* \protocol */ +#define PUBLIC 195 /* \public (PHP only) */ +#define PUBLICSECTION 196 /* \publicsection (PHP only) */ +#define REF 197 /* \ref */ +#define RELATES 198 /* \relates */ +#define RELATESALSO 199 /* \relatesalso */ +#define REMARKS 200 /* \remarks */ +#define RETURN_COMMAND 201 /* \return */ +#define RETVAL 202 /* \retval */ +#define SA 203 /* \sa */ +#define SECTION 204 /* \section */ +#define SEE 205 /* \see */ +#define SHOWINITIALIZER 206 /* \showinitializer */ +#define SINCE 207 /* \since */ +#define SKIP 208 /* \skip */ +#define SKIPLINE 209 /* \skipline */ +#define STRUCT 210 /* \struct */ +#define SUBPAGE 211 /* \subpage */ +#define SUBSECTION 212 /* \subsection */ +#define SUBSUBSECTION 213 /* \subsubsection */ +#define TEST 214 /* \test */ +#define THROW_COMMAND 215 /* \throw */ +#define TODO_COMMAND 216 /* \todo */ +#define TPARAM_COMMAND 217 /* \tparam */ +#define TYPEDEF_COMMAND 218 /* \typedef */ +#define UNION_COMMAND 219 /* \union */ +#define UNTIL_COMMAND 220 /* \until */ +#define VAR_COMMAND 221 /* \var */ +#define VERBATIM 222 /* \verbatim */ +#define VERBININCLUDE 223 /* \verbinclude */ +#define VERSION 224 /* \version */ +#define WARNING 225 /* \warning */ +#define WEAKGROUP 226 /* \weakgroup */ +#define XMLONLY 227 /* \xmlonly */ +#define XREFITEM 228 /* \xrefitem */ +#define DOLLAR_COMMAND 229 /* \$ */ +#define AT_COMMAND 230 /* \@ */ +#define SLASH_COMMAND 231 /* \\ */ +#define AND_COMMAND 232 /* \& */ +#define TILDE_COMMAND 233 /* \~ */ +#define LEFTANGLEBRACKET 234 /* \< */ +#define RIGHTANGLEBRACKET 235 /* \> */ +#define POUND_COMMAND 236 /* \# */ +#define PERCENT_COMMAND 237 /* \% */ -#endif /*TRANSLATOR_H_*/ +#endif diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.cpp b/Source/DoxygenTranslator/src/JavaDocConverter.cpp index 33a62ff77..9de2f99f3 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.cpp +++ b/Source/DoxygenTranslator/src/JavaDocConverter.cpp @@ -1,42 +1,43 @@ #include "JavaDocConverter.h" #include "DoxygenParser.h" #include -#define APPROX_LINE_LENGTH 64//characters per line allowed -#define TAB_SIZE 8//characters per line allowed +#define APPROX_LINE_LENGTH 64 //characters per line allowed +#define TAB_SIZE 8 //characters per line allowed int printSortedTree2 = 0; //TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a javadoc tag -std::string JavaDocConverter::formatCommand(std::string unformattedLine, int indent){ +std::string JavaDocConverter::formatCommand(std::string unformattedLine, int indent) { std::string formattedLines = "\n * "; int lastPosition = 0; int i = 0; - int isFirstLine = 1; - while (i != -1 && i < (int)unformattedLine.length()){ + int isFirstLine = 1; + while (i != -1 && i < (int) unformattedLine.length()) { lastPosition = i; - if (isFirstLine){ - i+=APPROX_LINE_LENGTH; + if (isFirstLine) { + i += APPROX_LINE_LENGTH; } else { - i+=APPROX_LINE_LENGTH - indent*TAB_SIZE; + i += APPROX_LINE_LENGTH - indent * TAB_SIZE; } i = unformattedLine.find(" ", i); - if (i > 0 && i + 1 < (int)unformattedLine.length()){ - if (!isFirstLine) for (int j = 0; j < indent; j++) { - formattedLines.append("\t"); + if (i > 0 && i + 1 < (int) unformattedLine.length()) { + if (!isFirstLine) + for (int j = 0; j < indent; j++) { + formattedLines.append("\t"); } else { - isFirstLine = 0; + isFirstLine = 0; } formattedLines.append(unformattedLine.substr(lastPosition, i - lastPosition + 1)); formattedLines.append("\n *"); } } - if (lastPosition < (int)unformattedLine.length()){ + if (lastPosition < (int) unformattedLine.length()) { if (!isFirstLine) { - for (int j = 0; j < indent; j++) { - formattedLines.append("\t"); - } + for (int j = 0; j < indent; j++) { + formattedLines.append("\t"); + } } formattedLines.append(unformattedLine.substr(lastPosition, unformattedLine.length() - lastPosition)); } @@ -47,57 +48,47 @@ std::string JavaDocConverter::formatCommand(std::string unformattedLine, int ind /* Contains the conversions for tags * could probably be much more efficient... */ -std::string JavaDocConverter::javaDocFormat(DoxygenEntity &doxygenEntity){ - if(doxygenEntity.typeOfEntity.compare("partofdescription") == 0){ - return doxygenEntity.data; - } - if (doxygenEntity.typeOfEntity.compare("plainstd::string") == 0){ - return doxygenEntity.data; +std::string JavaDocConverter::javaDocFormat(DoxygenEntity & doxygenEntity) { + if (doxygenEntity.typeOfEntity.compare("partofdescription") == 0) { + return doxygenEntity.data; } - else if (doxygenEntity.typeOfEntity.compare("b") == 0){ + if (doxygenEntity.typeOfEntity.compare("plainstd::string") == 0) { + return doxygenEntity.data; + } else if (doxygenEntity.typeOfEntity.compare("b") == 0) { return "" + doxygenEntity.data + ""; - } - else if (doxygenEntity.typeOfEntity.compare("c") == 0){ + } else if (doxygenEntity.typeOfEntity.compare("c") == 0) { return "" + doxygenEntity.data + ""; - } - else if (doxygenEntity.typeOfEntity.compare("@") == 0){ + } else if (doxygenEntity.typeOfEntity.compare("@") == 0) { return "@"; - } - else if (doxygenEntity.typeOfEntity.compare("\\") == 0){ + } else if (doxygenEntity.typeOfEntity.compare("\\") == 0) { return "\\"; - } - else if (doxygenEntity.typeOfEntity.compare("<") == 0){ + } else if (doxygenEntity.typeOfEntity.compare("<") == 0) { return "<"; - } - else if (doxygenEntity.typeOfEntity.compare(">") == 0){ + } else if (doxygenEntity.typeOfEntity.compare(">") == 0) { return ">"; - } - else if (doxygenEntity.typeOfEntity.compare("&") == 0){ + } else if (doxygenEntity.typeOfEntity.compare("&") == 0) { return "&"; - } - else if (doxygenEntity.typeOfEntity.compare("#") == 0){ + } else if (doxygenEntity.typeOfEntity.compare("#") == 0) { return "#"; - } - else if (doxygenEntity.typeOfEntity.compare("%") == 0){ + } else if (doxygenEntity.typeOfEntity.compare("%") == 0) { return "%"; - } - else if (doxygenEntity.typeOfEntity.compare("~") == 0){ + } else if (doxygenEntity.typeOfEntity.compare("~") == 0) { return "~"; } return ""; } -std::string JavaDocConverter::translateSubtree( DoxygenEntity &doxygenEntity){ +std::string JavaDocConverter::translateSubtree(DoxygenEntity & doxygenEntity) { std::string returnedString; - if (doxygenEntity.isLeaf) { + if (doxygenEntity.isLeaf) { return javaDocFormat(doxygenEntity) + " "; } else { returnedString += javaDocFormat(doxygenEntity); - std::list::iterator p = doxygenEntity.entityList.begin(); + std::list < DoxygenEntity >::iterator p = doxygenEntity.entityList.begin(); - while (p != doxygenEntity.entityList.end()){ - returnedString+= translateSubtree(*p); + while (p != doxygenEntity.entityList.end()) { + returnedString += translateSubtree(*p); p++; } } @@ -105,45 +96,43 @@ std::string JavaDocConverter::translateSubtree( DoxygenEntity &doxygenEntity){ } -std::string JavaDocConverter::translateEntity(DoxygenEntity &doxyEntity){ +std::string JavaDocConverter::translateEntity(DoxygenEntity & doxyEntity) { 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(std::string(translateSubtree(doxyEntity)), 0) + "\n * "; - } else if(doxyEntity.typeOfEntity.compare("plainstd::string")== 0 || - doxyEntity.typeOfEntity.compare("deprecated")== 0 || - doxyEntity.typeOfEntity.compare("brief")== 0) { + } else if (doxyEntity.typeOfEntity.compare("plainstd::string") == 0 || + doxyEntity.typeOfEntity.compare("deprecated") == 0 || + doxyEntity.typeOfEntity.compare("brief") == 0) { return formatCommand(doxyEntity.data, 0) + "\n * "; - } else if(doxyEntity.typeOfEntity.compare("see") == 0) { - return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t\t" + - translateSubtree(doxyEntity)), 2); + } else if (doxyEntity.typeOfEntity.compare("see") == 0) { + return formatCommand(std::string("@" + doxyEntity.typeOfEntity + "\t\t" + translateSubtree(doxyEntity)), 2); - } else if(doxyEntity.typeOfEntity.compare("return")== 0 - || doxyEntity.typeOfEntity.compare("author")== 0 - || doxyEntity.typeOfEntity.compare("param")== 0 - || doxyEntity.typeOfEntity.compare("throw")== 0 - || doxyEntity.typeOfEntity.compare("throws")== 0 - || doxyEntity.typeOfEntity.compare("since")== 0 - || doxyEntity.typeOfEntity.compare("version")== 0 - || doxyEntity.typeOfEntity.compare("exception") == 0 - || doxyEntity.typeOfEntity.compare("deprecated") == 0){ + } else if (doxyEntity.typeOfEntity.compare("return") == 0 + || doxyEntity.typeOfEntity.compare("author") == 0 + || doxyEntity.typeOfEntity.compare("param") == 0 + || doxyEntity.typeOfEntity.compare("throw") == 0 + || doxyEntity.typeOfEntity.compare("throws") == 0 + || doxyEntity.typeOfEntity.compare("since") == 0 + || doxyEntity.typeOfEntity.compare("version") == 0 + || doxyEntity.typeOfEntity.compare("exception") == 0 + || doxyEntity.typeOfEntity.compare("deprecated") == 0) { // this 'if' is a hack - convert doxyEntity.typeOfEntity at the time of parsing - if (doxyEntity.typeOfEntity.compare("throw")== 0) { + if (doxyEntity.typeOfEntity.compare("throw") == 0) { doxyEntity.typeOfEntity = "throws"; } 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(std::string("@see\t\t" + translateSubtree(doxyEntity)), 2); } else { - return formatCommand(javaDocFormat(doxyEntity), 0 ); + return formatCommand(javaDocFormat(doxyEntity), 0); } return ""; @@ -157,31 +146,31 @@ bool JavaDocConverter::getDocumentation(Node *node, String *&documentation) { if (documentation == NULL) { return false; } - - std::list entityList = DoxygenParser().createTree(Char(documentation)); - // entityList.sort(CompareDoxygenEntities()); sorting currently not used, - // see CompareDoxygenEntities::operator() in DoxygenEntity.cpp - - if(debug){ + std::list < DoxygenEntity > entityList = DoxygenParser().createTree(Char(documentation)); + + // entityList.sort(CompareDoxygenEntities()); sorting currently not used, + // see CompareDoxygenEntities::operator() in DoxygenEntity.cpp + + if (debug) { std::cout << "---RESORTED LIST---" << std::endl; printTree(entityList); } std::string javaDocString = "/**"; - - for(std::list::iterator entityIterator = entityList.begin(); entityIterator != entityList.end();){ + + for (std::list < DoxygenEntity >::iterator entityIterator = entityList.begin(); entityIterator != entityList.end();) { javaDocString += translateEntity(*entityIterator); entityIterator++; } javaDocString += "\n */\n"; - - if(debug){ + + if (debug) { std::cout << "\n---RESULT IN JAVADOC---" << std::endl; - std::cout << javaDocString; + std::cout << javaDocString; } - + documentation = NewString(javaDocString.c_str()); return true; } diff --git a/Source/DoxygenTranslator/src/JavaDocConverter.h b/Source/DoxygenTranslator/src/JavaDocConverter.h index 8651bb1cf..d898265ba 100644 --- a/Source/DoxygenTranslator/src/JavaDocConverter.h +++ b/Source/DoxygenTranslator/src/JavaDocConverter.h @@ -15,20 +15,20 @@ /* * A class to translate doxygen comments into JavaDoc style comments. */ -class JavaDocConverter : public DoxygenTranslator -{ +class JavaDocConverter : public DoxygenTranslator { public: - JavaDocConverter() : debug( false ){} + JavaDocConverter() : debug(false) { + } virtual bool getDocumentation(Node *node, String *&documentation); - + protected: std::string formatCommand(std::string unformattedLine, int indent); - std::string translateEntity(DoxygenEntity &doxyEntity); - std::string javaDocFormat(DoxygenEntity &doxygenEntity); - std::string translateSubtree( DoxygenEntity &doxygenEntity); - + std::string translateEntity(DoxygenEntity & doxyEntity); + std::string javaDocFormat(DoxygenEntity & doxygenEntity); + std::string translateSubtree(DoxygenEntity & doxygenEntity); + private: bool debug; }; -#endif /*JAVADOCCONVERTER_H_*/ +#endif diff --git a/Source/DoxygenTranslator/src/PyDocConverter.cpp b/Source/DoxygenTranslator/src/PyDocConverter.cpp index 6418ee73c..44dec4cbf 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.cpp +++ b/Source/DoxygenTranslator/src/PyDocConverter.cpp @@ -14,25 +14,25 @@ #include //TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a pydoc tag -PyDocConverter::PyDocConverter(){ - debug = 1; +PyDocConverter::PyDocConverter() { + debug = 1; } -std::string PyDocConverter::formatParam(Node *n, DoxygenEntity &doxygenEntity) { +std::string PyDocConverter::formatParam(Node *n, DoxygenEntity & doxygenEntity) { ParmList *plist = CopyParmList(Getattr(n, "parms")); Parm *p = NULL; - - DoxygenEntity& paramNameEntity = *doxygenEntity.entityList.begin(); - DoxygenEntity& paramDescriptionEntity = *(++doxygenEntity.entityList.begin()); - + + DoxygenEntity & paramNameEntity = *doxygenEntity.entityList.begin(); + DoxygenEntity & paramDescriptionEntity = *(++doxygenEntity.entityList.begin()); + std::string result; std::string paramDescription = justifyString(paramDescriptionEntity.data, DOC_PARAM_STRING_LENGTH); - + for (p = plist; p;) { - if(Char(Getattr(p, "name")) == paramNameEntity.data) { + if (Char(Getattr(p, "name")) == paramNameEntity.data) { std::string name = Char(Swig_name_make(n, 0, Getattr(p, "name"), 0, 0)); std::string type = Char(Swig_name_make(n, 0, Getattr(p, "type"), 0, 0)); - + result = name + " (" + type + ") "; result.resize(DOC_PARAM_STRING_LENGTH - 3, ' '); result += "-- " + paramDescription.substr(DOC_PARAM_STRING_LENGTH); @@ -45,162 +45,158 @@ std::string PyDocConverter::formatParam(Node *n, DoxygenEntity &doxygenEntity) { return result; } -std::string PyDocConverter::formatReturnDescription(Node *node, DoxygenEntity &doxygenEntity){ +std::string PyDocConverter::formatReturnDescription(Node *node, DoxygenEntity & doxygenEntity) { #pragma unused(node) return "\nResult:\n" + justifyString(translateSubtree(doxygenEntity)); } -std::string PyDocConverter::justifyString(std::string documentString, int indent, int maxWidth){ +std::string PyDocConverter::justifyString(std::string documentString, int indent, int maxWidth) { std::ostringstream formattedString; std::string currentLine; - - for(std::string::iterator stringPosition = documentString.begin(); stringPosition != documentString.end(); ++stringPosition) - { - if(currentLine.length() == 0) + + for (std::string::iterator stringPosition = documentString.begin(); stringPosition != documentString.end(); ++stringPosition) { + if (currentLine.length() == 0) currentLine.resize(indent, ' '); - + currentLine += *stringPosition; - - if(*stringPosition == ' ' && (int)currentLine.size() >= maxWidth || (stringPosition + 1) == documentString.end()) - { + + if (*stringPosition == ' ' && (int) currentLine.size() >= maxWidth || (stringPosition + 1) == documentString.end()) { formattedString << currentLine << std::endl; currentLine = ""; } } - + return formattedString.str(); } -std::string PyDocConverter::translateSubtree( DoxygenEntity &doxygenEntity){ +std::string PyDocConverter::translateSubtree(DoxygenEntity & doxygenEntity) { std::string returnedString; if (doxygenEntity.isLeaf) return doxygenEntity.data + " "; else { returnedString += doxygenEntity.data; - std::list::iterator p = doxygenEntity.entityList.begin(); - while (p != doxygenEntity.entityList.end()){ - returnedString+= translateSubtree(*p); + std::list < DoxygenEntity >::iterator p = doxygenEntity.entityList.begin(); + while (p != doxygenEntity.entityList.end()) { + returnedString += translateSubtree(*p); p++; } } return returnedString; } -std::string PyDocConverter::translateEntity(Node *n, DoxygenEntity &doxyEntity){ - if(doxyEntity.typeOfEntity.compare("partofdescription") == 0) +std::string PyDocConverter::translateEntity(Node *n, DoxygenEntity & doxyEntity) { + if (doxyEntity.typeOfEntity.compare("partofdescription") == 0) return justifyString(std::string(translateSubtree(doxyEntity)), 0); - + if ((doxyEntity.typeOfEntity.compare("brief") == 0) - ||(doxyEntity.typeOfEntity.compare("details") == 0)) + || (doxyEntity.typeOfEntity.compare("details") == 0)) return justifyString(std::string(translateSubtree(doxyEntity)), 0) + "\n"; - - if(doxyEntity.typeOfEntity.compare("plainstd::string") == 0 - || doxyEntity.typeOfEntity.compare("deprecated") == 0 - || doxyEntity.typeOfEntity.compare("brief") == 0) + + if (doxyEntity.typeOfEntity.compare("plainstd::string") == 0 + || doxyEntity.typeOfEntity.compare("deprecated") == 0 + || doxyEntity.typeOfEntity.compare("brief") == 0) return justifyString(doxyEntity.data, 0) + "\n"; - - if(doxyEntity.typeOfEntity.compare("param") == 0) + + if (doxyEntity.typeOfEntity.compare("param") == 0) return formatParam(n, doxyEntity); - - if(doxyEntity.typeOfEntity.compare("return") == 0) + + if (doxyEntity.typeOfEntity.compare("return") == 0) return formatReturnDescription(n, doxyEntity); - if(doxyEntity.typeOfEntity.compare("author") == 0 - || doxyEntity.typeOfEntity.compare("param") == 0 - || doxyEntity.typeOfEntity.compare("since") == 0 - || doxyEntity.typeOfEntity.compare("version") == 0 - || doxyEntity.typeOfEntity.compare("exception") == 0 - || doxyEntity.typeOfEntity.compare("deprecated") == 0 - || doxyEntity.typeOfEntity.compare("sa") == 0) + if (doxyEntity.typeOfEntity.compare("author") == 0 + || doxyEntity.typeOfEntity.compare("param") == 0 + || doxyEntity.typeOfEntity.compare("since") == 0 + || doxyEntity.typeOfEntity.compare("version") == 0 + || doxyEntity.typeOfEntity.compare("exception") == 0 + || doxyEntity.typeOfEntity.compare("deprecated") == 0 + || doxyEntity.typeOfEntity.compare("sa") == 0) return ""; return justifyString(doxyEntity.data); } -std::string PyDocConverter::processEntityList(Node *n, std::list& entityList){ +std::string PyDocConverter::processEntityList(Node *n, std::list < DoxygenEntity > &entityList) { std::string result; bool inParamsSection = false; - - for(std::list::iterator entityIterator = entityList.begin(); entityIterator != entityList.end();){ - if(entityIterator->typeOfEntity.compare("param") == 0 && !inParamsSection){ + + for (std::list < DoxygenEntity >::iterator entityIterator = entityList.begin(); entityIterator != entityList.end();) { + if (entityIterator->typeOfEntity.compare("param") == 0 && !inParamsSection) { inParamsSection = true; result += "\nArguments:\n"; - } - else if(entityIterator->typeOfEntity.compare("param") != 0 && inParamsSection) + } else if (entityIterator->typeOfEntity.compare("param") != 0 && inParamsSection) inParamsSection = false; - + result += translateEntity(n, *entityIterator); entityIterator++; - } - + } + return result; } -bool PyDocConverter::getDocumentation(Node *n, String *&documentation){ +bool PyDocConverter::getDocumentation(Node *n, String *&documentation) { std::string pyDocString, result; - + // for overloaded functions we must concat documentation for underlying overloads - if(Checkattr(n, "kind", "function") && Getattr(n, "sym:overloaded")){ + if (Checkattr(n, "kind", "function") && Getattr(n, "sym:overloaded")) { // rewind to the first overload while (Getattr(n, "sym:previousSibling")) n = Getattr(n, "sym:previousSibling"); - - std::vector allDocumentation; - + + std::vector < std::string > allDocumentation; + // for each real method (not a generated overload) append the documentation - while(n){ - documentation = Getattr(n,"DoxygenComment"); - if(!Swig_is_generated_overload(n) && documentation){ - std::list entityList = DoxygenParser().createTree(Char(documentation)); + while (n) { + documentation = Getattr(n, "DoxygenComment"); + if (!Swig_is_generated_overload(n) && documentation) { + std::list < DoxygenEntity > entityList = DoxygenParser().createTree(Char(documentation)); allDocumentation.push_back(processEntityList(n, entityList)); } n = Getattr(n, "sym:nextSibling"); } - + // construct final documentation string - if(allDocumentation.size() > 1){ + if (allDocumentation.size() > 1) { std::ostringstream concatDocString; - for(int realOverloadCount = 0; realOverloadCount < (int)allDocumentation.size(); realOverloadCount++){ + for (int realOverloadCount = 0; realOverloadCount < (int) allDocumentation.size(); realOverloadCount++) { concatDocString << generateDivider(); concatDocString << "Overload " << (realOverloadCount + 1) << ":" << std::endl; concatDocString << generateDivider(); concatDocString << allDocumentation[realOverloadCount] << std::endl; } pyDocString = concatDocString.str(); - } - else if (allDocumentation.size() == 1) { + } else if (allDocumentation.size() == 1) { pyDocString = *(allDocumentation.begin()); } - } + } // for other nodes just process as normal else { - documentation = Getattr(n,"DoxygenComment"); - if(documentation != NULL){ - std::list entityList = DoxygenParser().createTree(Char(documentation)); + documentation = Getattr(n, "DoxygenComment"); + if (documentation != NULL) { + std::list < DoxygenEntity > entityList = DoxygenParser().createTree(Char(documentation)); pyDocString = processEntityList(n, entityList); } } - + // if we got something log the result and construct DOH string to return - if(pyDocString.length()) { + if (pyDocString.length()) { result = "\"\"\"\n" + pyDocString + "\"\"\"\n"; - - if(debug){ + + if (debug) { std::cout << "\n---RESULT IN PYDOC---" << std::endl; std::cout << result; std::cout << std::endl; } - + documentation = NewString(result.c_str()); return true; } - + return false; } -std::string PyDocConverter::generateDivider(){ +std::string PyDocConverter::generateDivider() { std::ostringstream dividerString; - for(int i = 0; i < DOC_STRING_LENGTH; i++) + for (int i = 0; i < DOC_STRING_LENGTH; i++) dividerString << '-'; dividerString << std::endl; return dividerString.str(); diff --git a/Source/DoxygenTranslator/src/PyDocConverter.h b/Source/DoxygenTranslator/src/PyDocConverter.h index 500e39fe8..5680480fc 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.h +++ b/Source/DoxygenTranslator/src/PyDocConverter.h @@ -16,38 +16,37 @@ #include "DoxygenEntity.h" #include "DoxygenTranslator.h" -#define DOC_STRING_LENGTH 64 // characters per line allowed -#define DOC_PARAM_STRING_LENGTH 30 // characters reserved for param name / type +#define DOC_STRING_LENGTH 64 // characters per line allowed +#define DOC_PARAM_STRING_LENGTH 30 // characters reserved for param name / type -class PyDocConverter : public DoxygenTranslator -{ +class PyDocConverter : public DoxygenTranslator { public: PyDocConverter(); bool getDocumentation(Node *node, String *&documentation); - + protected: - + /* * Process the contents of the entity list producing a documentation string. * @param node The parse tree node that the entity list relates to. * @param entityList The entity list to process */ - std::string processEntityList(Node *node, std::list& entityList); - + std::string processEntityList(Node *node, std::list < DoxygenEntity > &entityList); + /* * Format the doxygen comment relating to a function or method parameter * @param node The parse tree node that the parameter relates to. * @param doxygenEntity The doxygen entity relating to the parameter docstring. */ - std::string formatParam(Node *node, DoxygenEntity &doxygenEntity); - + std::string formatParam(Node *node, DoxygenEntity & doxygenEntity); + /* * Format the doxygen comment relating to the return value for a method or function. * @param node The parse tree node that the parameter relates to. * @param doxygenEntity The doxygen entity relating to the parameter docstring. */ - std::string formatReturnDescription(Node *node, DoxygenEntity &doxygenEntity); - + std::string formatReturnDescription(Node *node, DoxygenEntity & doxygenEntity); + /* * Format a string so it is justified and split over several lines * not exeeding a given length. @@ -56,17 +55,17 @@ protected: * @param maxWidth The approximate maximum line width. */ std::string justifyString(std::string unformattedLine, int indent = 0, int maxWidth = DOC_STRING_LENGTH); - - std::string translateSubtree( DoxygenEntity &doxygenEntity); - std::string translateEntity(Node *n, DoxygenEntity &doxyEntity); - + + std::string translateSubtree(DoxygenEntity & doxygenEntity); + std::string translateEntity(Node *n, DoxygenEntity & doxyEntity); + /* * Utility method to generate a diving line for a documentation string. */ std::string generateDivider(); - + private: bool debug; }; -#endif /*PYDOCCONVERTER_H_*/ +#endif diff --git a/Source/DoxygenTranslator/src/Token.cpp b/Source/DoxygenTranslator/src/Token.cpp index 2ac03afe5..f7c02b021 100644 --- a/Source/DoxygenTranslator/src/Token.cpp +++ b/Source/DoxygenTranslator/src/Token.cpp @@ -3,27 +3,26 @@ using namespace std; -Token::Token(int tType, string tString) -{ - tokenType = tType; - tokenString = tString; +Token::Token(int tType, string tString) { + tokenType = tType; + tokenString = tString; } -string Token::toString() -{ - if (tokenType == END_LINE){ - return "{END OF LINE}"; - } - if (tokenType == PARAGRAPH_END){ - return "{END OF PARAGRAPH}"; - } - if (tokenType == PLAINSTRING){ - return "{PLAINSTRING :" + tokenString + "}"; - } - if (tokenType == COMMAND){ - return "{COMMAND : " + tokenString+ "}"; - } - return ""; +string Token::toString() { + if (tokenType == END_LINE) { + return "{END OF LINE}"; + } + if (tokenType == PARAGRAPH_END) { + return "{END OF PARAGRAPH}"; + } + if (tokenType == PLAINSTRING) { + return "{PLAINSTRING :" + tokenString + "}"; + } + if (tokenType == COMMAND) { + return "{COMMAND : " + tokenString + "}"; + } + return ""; } -Token:: ~Token(){} +Token::~Token() { +} diff --git a/Source/DoxygenTranslator/src/Token.h b/Source/DoxygenTranslator/src/Token.h index cf28c90b7..4ae44b65f 100644 --- a/Source/DoxygenTranslator/src/Token.h +++ b/Source/DoxygenTranslator/src/Token.h @@ -4,15 +4,14 @@ using namespace std; -class Token -{ +class Token { public: - Token(int tType, string tString); - ~Token(); + Token(int tType, string tString); + ~Token(); - int tokenType; /* currently can be END_LINE, PLAINSTRING, or COMMAND */ - string tokenString; /* the data , such as param for @param*/ - string toString(); + int tokenType; /* currently can be END_LINE, PLAINSTRING, or COMMAND */ + string tokenString; /* the data , such as param for @param */ + string toString(); }; -#endif /*TOKEN_H_*/ +#endif diff --git a/Source/DoxygenTranslator/src/TokenList.cpp b/Source/DoxygenTranslator/src/TokenList.cpp index 9efd7e9ef..8eeef97b2 100644 --- a/Source/DoxygenTranslator/src/TokenList.cpp +++ b/Source/DoxygenTranslator/src/TokenList.cpp @@ -5,165 +5,161 @@ #include #include "Token.h" #include "DoxygenEntity.h" -#define TOKENSPERLINE 8; //change this to change the printing behaviour of the token list +#define TOKENSPERLINE 8; //change this to change the printing behaviour of the token list using namespace std; int noisy2 = 0; /* The tokenizer*/ -TokenList::TokenList(const std::string &doxygenStringConst){ - size_t commentPos; - string doxygenString = doxygenStringConst; +TokenList::TokenList(const std::string & doxygenStringConst) { + size_t commentPos; + string doxygenString = doxygenStringConst; - /* Comment start tokens are replaced in parser.y, see doxygen_comment and - doxygen_post_comment_item - do { - commentPos = doxygenString.find("///<"); - if (commentPos != string::npos) { - doxygenString.replace(commentPos, 4, " "); - continue; - } - commentPos = doxygenString.find("/**<"); - if (commentPos != string::npos) { - doxygenString.replace(commentPos, 4, " "); - continue; - } - commentPos = doxygenString.find("/*!<"); - if (commentPos != string::npos) { - doxygenString.replace(commentPos, 4, " "); - continue; - } - commentPos = doxygenString.find("//!<"); - if (commentPos != string::npos) { - doxygenString.replace(commentPos, 4, " "); - continue; - } - break; - } while (true); */ + /* Comment start tokens are replaced in parser.y, see doxygen_comment and + doxygen_post_comment_item + do { + commentPos = doxygenString.find("///<"); + if (commentPos != string::npos) { + doxygenString.replace(commentPos, 4, " "); + continue; + } + commentPos = doxygenString.find("/**<"); + if (commentPos != string::npos) { + doxygenString.replace(commentPos, 4, " "); + continue; + } + commentPos = doxygenString.find("/*!<"); + if (commentPos != string::npos) { + doxygenString.replace(commentPos, 4, " "); + continue; + } + commentPos = doxygenString.find("//!<"); + if (commentPos != string::npos) { + doxygenString.replace(commentPos, 4, " "); + continue; + } + break; + } while (true); + */ - size_t currentIndex = 0; - size_t nextIndex = 0; + size_t currentIndex = 0; + size_t nextIndex = 0; - string currentWord; + string currentWord; - while (currentIndex < doxygenString.length()){ + while (currentIndex < doxygenString.length()) { - if(doxygenString[currentIndex] == '\n'){ - m_tokenList.push_back(Token(END_LINE, currentWord)); - currentIndex++; - } + if (doxygenString[currentIndex] == '\n') { + m_tokenList.push_back(Token(END_LINE, currentWord)); + currentIndex++; + } + // skip WS, except \n + while (currentIndex < doxygenString.length() && (doxygenString[currentIndex] == ' ' || doxygenString[currentIndex] == '\t')) + currentIndex++; - // skip WS, except \n - while(currentIndex < doxygenString.length() && (doxygenString[currentIndex] == ' ' - || doxygenString[currentIndex]== '\t')) currentIndex ++; + if (currentIndex < doxygenString.length()) { - if (currentIndex < doxygenString.length()) { + nextIndex = currentIndex; - nextIndex = currentIndex; + // skip non WS + while (nextIndex < doxygenString.length() && (doxygenString[nextIndex] != ' ' && doxygenString[nextIndex] != '\t' && doxygenString[nextIndex] != '\n')) + nextIndex++; - // skip non WS - while (nextIndex < doxygenString.length() && (doxygenString[nextIndex] != ' ' - && doxygenString[nextIndex] != '\t' && doxygenString[nextIndex]!= '\n')) - nextIndex++; + // now we have a token + currentWord = doxygenString.substr(currentIndex, nextIndex - currentIndex); - // now we have a token - currentWord = doxygenString.substr(currentIndex, nextIndex-currentIndex); + if (noisy2) + cout << "Current Word: " << currentWord << endl; - if(noisy2) - cout << "Current Word: " << currentWord << endl; + if (currentWord[0] == '@' || currentWord[0] == '\\') { + // it is doxygen command + currentWord = currentWord.substr(1, currentWord.length() - 1); + m_tokenList.push_back(Token(COMMAND, currentWord)); - if (currentWord[0] == '@' || currentWord[0] == '\\'){ - // it is doxygen command - currentWord = currentWord.substr(1, currentWord.length()-1); - m_tokenList.push_back(Token(COMMAND, currentWord)); + } else if (currentWord[0] == '\n') { - } else if (currentWord[0] == '\n'){ + m_tokenList.push_back(Token(END_LINE, currentWord)); - m_tokenList.push_back(Token(END_LINE, currentWord)); - - } - else if (currentWord[0] == '*' || currentWord[0] == '/' ||currentWord[0] == '!'){ - - bool isPlainString = false; + } else if (currentWord[0] == '*' || currentWord[0] == '/' || currentWord[0] == '!') { - if (currentWord.length() > 1) { + bool isPlainString = false; - for(size_t i = 1; i < currentWord.length(); i++){ - if (currentWord[i] != '*' && currentWord[i] != '/' && - currentWord[i] != '!') { - isPlainString = true; - break; - } - } - } - - if(isPlainString) - m_tokenList.push_back(Token(PLAINSTRING, currentWord)); + if (currentWord.length() > 1) { - } else if (!currentWord.empty()) { - m_tokenList.push_back(Token(PLAINSTRING, currentWord)); - } - currentIndex = nextIndex; - } + for (size_t i = 1; i < currentWord.length(); i++) { + if (currentWord[i] != '*' && currentWord[i] != '/' && currentWord[i] != '!') { + isPlainString = true; + break; + } + } } - m_tokenListIter = m_tokenList.begin(); + if (isPlainString) + m_tokenList.push_back(Token(PLAINSTRING, currentWord)); + + } else if (!currentWord.empty()) { + m_tokenList.push_back(Token(PLAINSTRING, currentWord)); + } + currentIndex = nextIndex; + } + } + + m_tokenListIter = m_tokenList.begin(); } -TokenList:: ~TokenList(){ +TokenList::~TokenList() { } -Token TokenList::peek(){ - if(m_tokenListIter!= m_tokenList.end()){ - Token returnedToken = (*m_tokenListIter); - return returnedToken; - } - else - return Token(0, ""); -} - - -Token TokenList::next(){ - if(m_tokenListIter != m_tokenList.end()){ - Token returnedToken = (*m_tokenListIter); - m_tokenListIter++; - return (returnedToken); - } - else - return Token(0, ""); -} - - -list::iterator TokenList::end(){ - return m_tokenList.end(); +Token TokenList::peek() { + if (m_tokenListIter != m_tokenList.end()) { + Token returnedToken = (*m_tokenListIter); + return returnedToken; + } else + return Token(0, ""); } -list::iterator TokenList::current(){ +Token TokenList::next() { + if (m_tokenListIter != m_tokenList.end()) { + Token returnedToken = (*m_tokenListIter); + m_tokenListIter++; + return (returnedToken); + } else + return Token(0, ""); +} + + +list < Token >::iterator TokenList::end() { + return m_tokenList.end(); +} + + +list < Token >::iterator TokenList::current() { return m_tokenListIter; } -list::iterator TokenList::iteratorCopy(){ +list < Token >::iterator TokenList::iteratorCopy() { return m_tokenListIter; } -void TokenList::setIterator(list::iterator newPosition){ +void TokenList::setIterator(list < Token >::iterator newPosition) { m_tokenListIter = newPosition; } -void TokenList::printList(){ - list::iterator p = m_tokenList.begin(); - int i = 1; - int b = 0; - while (p != m_tokenList.end()){ - cout << (*p).toString() << " "; - b = i%TOKENSPERLINE; - if (b == 0) cout << endl; - p++; i++; - } +void TokenList::printList() { + list < Token >::iterator p = m_tokenList.begin(); + int i = 1; + int b = 0; + while (p != m_tokenList.end()) { + cout << (*p).toString() << " "; + b = i % TOKENSPERLINE; + if (b == 0) + cout << endl; + p++; + i++; + } } - diff --git a/Source/DoxygenTranslator/src/TokenList.h b/Source/DoxygenTranslator/src/TokenList.h index 0f5710e0f..841d66e1a 100644 --- a/Source/DoxygenTranslator/src/TokenList.h +++ b/Source/DoxygenTranslator/src/TokenList.h @@ -10,25 +10,25 @@ * that can be derived from a formatted doxygen string */ -class TokenList{ +class TokenList { private: - std::list m_tokenList; - std::list::iterator m_tokenListIter; + std::list < Token > m_tokenList; + std::list < Token >::iterator m_tokenListIter; public: - TokenList(const std::string &doxygenString); /* constructor takes a blob of Doxygen comment */ - ~TokenList(); + TokenList(const std::string & doxygenString); /* constructor takes a blob of Doxygen comment */ + ~TokenList(); - Token peek(); /* returns next token without advancing */ - Token next(); /* returns next token and advances */ + Token peek(); /* returns next token without advancing */ + Token next(); /* returns next token and advances */ - std::list::iterator end(); /* returns an end iterator */ - std::list::iterator current(); /* returns the current iterator */ + std::list < Token >::iterator end(); /* returns an end iterator */ + std::list < Token >::iterator current(); /* returns the current iterator */ - std::list::iterator iteratorCopy(); /* returns a copy of the current iterator */ - void setIterator(list::iterator newPosition); /*moves up the iterator*/ + std::list < Token >::iterator iteratorCopy(); /* returns a copy of the current iterator */ + void setIterator(list < Token >::iterator newPosition); /*moves up the iterator */ - void printList(); /* prints out the sequence of tokens */ + void printList(); /* prints out the sequence of tokens */ }; -#endif /*TOKENLIST_H_*/ +#endif