diff options
Diffstat (limited to 'src')
133 files changed, 3297 insertions, 4053 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b99bef5..aaf1978 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -166,7 +166,6 @@ add_library(doxycfg STATIC ${GENERATED_SRC}/settings.h portable.cpp portable_c.c - ftextstream.cpp message.cpp debug.cpp ) diff --git a/src/cite.cpp b/src/cite.cpp index 13465a5..1773831 100644 --- a/src/cite.cpp +++ b/src/cite.cpp @@ -16,7 +16,6 @@ #include "cite.h" #include "config.h" -#include "ftextstream.h" #include "language.h" #include "message.h" #include "portable.h" @@ -26,10 +25,9 @@ #include "fileinfo.h" #include "dir.h" -#include <qfile.h> - #include <map> #include <string> +#include <fstream> const char *bibTmpFile = "bibTmpFile_"; const char *bibTmpDir = "bibTmpDir/"; @@ -118,71 +116,40 @@ void CitationManager::insertCrossReferencesForBibFile(const QCString &bibFile) err("bib file %s not found!\n",bibFile.data()); return; } - QFile f(bibFile); - if (!f.open(IO_ReadOnly)) + std::ifstream f(bibFile.str(), std::ifstream::in); + if (!f.is_open()) { err("could not open file %s for reading\n",bibFile.data()); return; } - // convert file to string - QCString doc; - QCString input(fi.size()+1); - f.readBlock(input.rawData(),fi.size()); - f.close(); - input.at(fi.size())='\0'; - - int pos=0; - int s; - - // helper lambda function to get the next line of input and update pos accordingly - auto get_next_line = [&input,&pos,&s]() - { - uint prevPos = (uint)pos; - pos=s+1; - return input.mid(prevPos,(uint)(s-prevPos)); - }; - - // helper lambda function to return if the end of the input has reached - auto end_of_input = [&s]() - { - return s==-1; - }; - - // helper lambda function to proceed to the next line in the input, and update s - // to point to the start of the line. Return true as long as there is a new line. - auto has_next_line = [&input,&pos,&s]() - { - s=input.find('\n',pos); - return s!=-1; - }; - // search for citation cross references QCString citeName; - while (has_next_line()) - { - QCString line = get_next_line(); + std::string lineStr; + while (getline(f,lineStr)) + { int i; + QCString line = lineStr; if (line.stripWhiteSpace().startsWith("@")) { // assumption entry like: "@book { name," or "@book { name" (spaces optional) int j = line.find('{'); // when no {, go hunting for it - while (j==-1 && has_next_line()) + while (j==-1 && getline(f,lineStr)) { - line = get_next_line(); + line = lineStr; j = line.find('{'); } // search for the name citeName = ""; - if (!end_of_input() && j!=-1) // to prevent something like "@manual ," and no { found + if (!f.eof() && j!=-1) // to prevent something like "@manual ," and no { found { int k = line.find(',',j); j++; // found a line "@....{.....,...." or "@.....{....." // ^=j ^=k ^=j k=-1 - while (!end_of_input() && citeName.isEmpty()) + while (!f.eof() && citeName.isEmpty()) { if (k!=-1) { @@ -194,9 +161,9 @@ void CitationManager::insertCrossReferencesForBibFile(const QCString &bibFile) } citeName = citeName.stripWhiteSpace(); j = 0; - if (citeName.isEmpty() && has_next_line()) + if (citeName.isEmpty() && getline(f,lineStr)) { - line = get_next_line(); + line = lineStr; k = line.find(','); } } @@ -232,7 +199,6 @@ void CitationManager::generatePage() bool citeDebug = Debug::isFlagSet(Debug::Cite); // 0. add cross references from the bib files to the cite dictionary - QFile f; const StringVector &citeDataList = Config_getList(CITE_BIB_FILES); for (const auto &bibdata : citeDataList) { @@ -244,23 +210,24 @@ void CitationManager::generatePage() // 1. generate file with markers and citations to OUTPUT_DIRECTORY QCString outputDir = Config_getString(OUTPUT_DIRECTORY); QCString citeListFile = outputDir+"/citelist.doc"; - f.setName(citeListFile); - if (!f.open(IO_WriteOnly)) { - err("could not open file %s for writing\n",citeListFile.data()); - } - FTextStream t(&f); - t << "<!-- BEGIN CITATIONS -->" << endl; - t << "<!--" << endl; - for (const auto &it : p->entries) - { - t << "\\citation{" << it.second->label() << "}" << endl; + std::ofstream t(citeListFile.str(),std::ofstream::out | std::ofstream::binary); + if (!t.is_open()) + { + err("could not open file %s for writing\n",citeListFile.data()); + } + t << "<!-- BEGIN CITATIONS -->\n"; + t << "<!--\n"; + for (const auto &it : p->entries) + { + t << "\\citation{" << it.second->label() << "}\n"; + } + t << "-->\n"; + t << "<!-- END CITATIONS -->\n"; + t << "<!-- BEGIN BIBLIOGRAPHY -->\n"; + t << "<!-- END BIBLIOGRAPHY -->\n"; + t.close(); } - t << "-->" << endl; - t << "<!-- END CITATIONS -->" << endl; - t << "<!-- BEGIN BIBLIOGRAPHY -->" << endl; - t << "<!-- END BIBLIOGRAPHY -->" << endl; - f.close(); // 2. generate bib2xhtml QCString bib2xhtmlFile = outputDir+"/bib2xhtml.pl"; @@ -319,26 +286,19 @@ void CitationManager::generatePage() // 6. read back the file QCString doc; { - f.setName(citeListFile); - if (!f.open(IO_ReadOnly)) + std::ifstream f(citeListFile.str(),std::ifstream::in); + if (!f.is_open()) { err("could not open file %s for reading\n",citeListFile.data()); } - FileInfo fi(citeListFile.str()); - QCString input(fi.size()+1); - f.readBlock(input.rawData(),fi.size()); - f.close(); - input.at(fi.size())='\0'; - bool insideBib=FALSE; - int pos=0,s; //printf("input=[%s]\n",input.data()); - while ((s=input.find('\n',pos))!=-1) + std::string lineStr; + while (getline(f,lineStr)) { - QCString line = input.mid((uint)pos,(uint)(s-pos)); + QCString line = lineStr; //printf("pos=%d s=%d line=[%s]\n",pos,s,line.data()); - pos=s+1; if (line.find("<!-- BEGIN BIBLIOGRAPHY")!=-1) insideBib=TRUE; else if (line.find("<!-- END BIBLIOGRAPH")!=-1) insideBib=FALSE; @@ -21,8 +21,6 @@ #include <qcstring.h> -class FTextStream; - /// Citation-related data. struct CiteInfo { diff --git a/src/classdef.cpp b/src/classdef.cpp index c01d51f..f1d9c60 100644 --- a/src/classdef.cpp +++ b/src/classdef.cpp @@ -18,7 +18,6 @@ #include <cstdio> #include <algorithm> -#include <qfile.h> #include "classdef.h" #include "classlist.h" #include "entry.h" @@ -300,7 +299,7 @@ class ClassDefImpl : public DefinitionMixin<ClassDefMutable> virtual void addGroupedInheritedMembers(OutputList &ol,MemberListType lt, const ClassDef *inheritedFrom,const QCString &inheritId) const; - virtual void writeTagFile(FTextStream &); + virtual void writeTagFile(std::ostream &); virtual int countMembersIncludingGrouped(MemberListType lt,const ClassDef *inheritedFrom,bool additional) const; virtual int countInheritanceNodes() const; @@ -2047,7 +2046,7 @@ void ClassDefImpl::writeSummaryLinks(OutputList &ol) const ol.popGeneratorState(); } -void ClassDefImpl::writeTagFile(FTextStream &tagFile) +void ClassDefImpl::writeTagFile(std::ostream &tagFile) { if (!isLinkableInProject() || isArtificial()) return; tagFile << " <compound kind=\""; @@ -2057,17 +2056,17 @@ void ClassDefImpl::writeTagFile(FTextStream &tagFile) tagFile << compoundTypeString(); tagFile << "\""; if (isObjectiveC()) { tagFile << " objc=\"yes\""; } - tagFile << ">" << endl; - tagFile << " <name>" << convertToXML(name()) << "</name>" << endl; - tagFile << " <filename>" << convertToXML(getOutputFileBase()) << Doxygen::htmlFileExtension << "</filename>" << endl; + tagFile << ">\n"; + tagFile << " <name>" << convertToXML(name()) << "</name>\n"; + tagFile << " <filename>" << convertToXML(getOutputFileBase()) << Doxygen::htmlFileExtension << "</filename>\n"; if (!anchor().isEmpty()) { - tagFile << " <anchor>" << convertToXML(anchor()) << "</anchor>" << endl; + tagFile << " <anchor>" << convertToXML(anchor()) << "</anchor>\n"; } QCString idStr = id(); if (!idStr.isEmpty()) { - tagFile << " <clangid>" << convertToXML(idStr) << "</clangid>" << endl; + tagFile << " <clangid>" << convertToXML(idStr) << "</clangid>\n"; } for (const Argument &a : m_impl->tempArgs) { @@ -2076,7 +2075,7 @@ void ClassDefImpl::writeTagFile(FTextStream &tagFile) { tagFile << " " << convertToXML(a.name); } - tagFile << "</templarg>" << endl; + tagFile << "</templarg>\n"; } for (const auto &ibcd : m_impl->inherits) { @@ -2098,7 +2097,7 @@ void ClassDefImpl::writeTagFile(FTextStream &tagFile) { tagFile << " virtualness=\"virtual\""; } - tagFile << ">" << convertToXML(cd->name()) << "</base>" << endl; + tagFile << ">" << convertToXML(cd->name()) << "</base>\n"; } } } @@ -2116,7 +2115,7 @@ void ClassDefImpl::writeTagFile(FTextStream &tagFile) ) { tagFile << " <class kind=\"" << innerCd->compoundTypeString() << - "\">" << convertToXML(innerCd->name()) << "</class>" << endl; + "\">" << convertToXML(innerCd->name()) << "</class>\n"; } } } @@ -2144,7 +2143,7 @@ void ClassDefImpl::writeTagFile(FTextStream &tagFile) } } writeDocAnchorsToTagFile(tagFile); - tagFile << " </compound>" << endl; + tagFile << " </compound>\n"; } /** Write class documentation inside another container (i.e. a group) */ diff --git a/src/classdef.h b/src/classdef.h index ea14675..b1582be 100644 --- a/src/classdef.h +++ b/src/classdef.h @@ -43,7 +43,6 @@ class PackageDef; class GroupDef; struct IncludeInfo; class ClassDefImpl; -class FTextStream; class ClassDef; class ClassDefMutable; class UsesClassList; @@ -449,7 +448,7 @@ class ClassDefMutable : public DefinitionMutable, public ClassDef virtual void writeQuickMemberLinks(OutputList &ol,const MemberDef *md) const = 0; virtual void writeSummaryLinks(OutputList &ol) const = 0; virtual void writeInlineDocumentation(OutputList &ol) const = 0; - virtual void writeTagFile(FTextStream &) = 0; + virtual void writeTagFile(std::ostream &) = 0; virtual void writeMemberDeclarations(OutputList &ol,ClassDefSet &visitedClasses, MemberListType lt,const QCString &title, const char *subTitle=0,bool showInline=FALSE,const ClassDef *inheritedFrom=0, diff --git a/src/config.h b/src/config.h index 31be3a1..f3fd278 100644 --- a/src/config.h +++ b/src/config.h @@ -16,7 +16,7 @@ #ifndef CONFIG_H #define CONFIG_H -class FTextStream; +#include <ostream> // note: this header file is generated from config.xml #include "configvalues.h" @@ -54,12 +54,12 @@ namespace Config * is \c TRUE the description of each configuration option will * be omitted. */ - void writeTemplate(FTextStream &t,bool shortList,bool updateOnly=FALSE); + void writeTemplate(std::ostream &t,bool shortList,bool updateOnly=FALSE); /*! Writes a the differences between the current configuration and the * template configuration to stream \a t. */ - void compareDoxyfile(FTextStream &t); + void compareDoxyfile(std::ostream &t); /*! Parses a configuration file with name \a fn. * \returns TRUE if successful, FALSE if the file could not be diff --git a/src/configimpl.h b/src/configimpl.h index a34c45b..3d91b2d 100644 --- a/src/configimpl.h +++ b/src/configimpl.h @@ -23,9 +23,10 @@ #include <unordered_map> #include <string> #include <memory> +#include <iostream> -#include "ftextstream.h" #include "containers.h" +#include <qcstring.h> /** Abstract base class for any configuration option. @@ -74,17 +75,17 @@ class ConfigOption void setUserComment(const QCString &u) { m_userComment += u; } protected: - virtual void writeTemplate(FTextStream &t,bool sl,bool upd) = 0; - virtual void compareDoxyfile(FTextStream &t) = 0; + virtual void writeTemplate(std::ostream &t,bool sl,bool upd) = 0; + virtual void compareDoxyfile(std::ostream &t) = 0; virtual void convertStrToVal() {} virtual void emptyValueToDefault() {} virtual void substEnvVars() = 0; virtual void init() {} - void writeBoolValue(FTextStream &t,bool v); - void writeIntValue(FTextStream &t,int i); - void writeStringValue(FTextStream &t,const QCString &s); - void writeStringList(FTextStream &t,const StringVector &l); + void writeBoolValue(std::ostream &t,bool v); + void writeIntValue(std::ostream &t,int i); + void writeStringValue(std::ostream &t,const QCString &s); + void writeStringList(std::ostream &t,const StringVector &l); QCString m_spaces; QCString m_name; @@ -106,8 +107,8 @@ class ConfigInfo : public ConfigOption m_name = name; m_doc = doc; } - void writeTemplate(FTextStream &t, bool sl,bool); - void compareDoxyfile(FTextStream &){}; + void writeTemplate(std::ostream &t, bool sl,bool); + void compareDoxyfile(std::ostream &){}; void substEnvVars() {} }; @@ -129,8 +130,8 @@ class ConfigList : public ConfigOption WidgetType widgetType() const { return m_widgetType; } StringVector *valueRef() { return &m_value; } StringVector getDefault() { return m_defaultValue; } - void writeTemplate(FTextStream &t,bool sl,bool); - void compareDoxyfile(FTextStream &t); + void writeTemplate(std::ostream &t,bool sl,bool); + void compareDoxyfile(std::ostream &t); void substEnvVars(); void init() { m_value = m_defaultValue; } private: @@ -156,9 +157,9 @@ class ConfigEnum : public ConfigOption const std::vector<QCString> &values() const { return m_valueRange; } QCString *valueRef() { return &m_value; } void substEnvVars(); - void writeTemplate(FTextStream &t,bool sl,bool); + void writeTemplate(std::ostream &t,bool sl,bool); void convertStrToVal(); - void compareDoxyfile(FTextStream &t); + void compareDoxyfile(std::ostream &t); void init() { m_value = m_defValue.copy(); } private: @@ -187,8 +188,8 @@ class ConfigString : public ConfigOption WidgetType widgetType() const { return m_widgetType; } void setDefaultValue(const char *v) { m_defValue = v; } QCString *valueRef() { return &m_value; } - void writeTemplate(FTextStream &t,bool sl,bool); - void compareDoxyfile(FTextStream &t); + void writeTemplate(std::ostream &t,bool sl,bool); + void compareDoxyfile(std::ostream &t); void substEnvVars(); void init() { m_value = m_defValue.copy(); } void emptyValueToDefault() { if(m_value.isEmpty()) m_value=m_defValue; }; @@ -220,8 +221,8 @@ class ConfigInt : public ConfigOption int maxVal() const { return m_maxVal; } void convertStrToVal(); void substEnvVars(); - void writeTemplate(FTextStream &t,bool sl,bool upd); - void compareDoxyfile(FTextStream &t); + void writeTemplate(std::ostream &t,bool sl,bool upd); + void compareDoxyfile(std::ostream &t); void init() { m_value = m_defValue; } private: int m_value; @@ -249,8 +250,8 @@ class ConfigBool : public ConfigOption void convertStrToVal(); void substEnvVars(); void setValueString(const QCString &v) { m_valueString = v; } - void writeTemplate(FTextStream &t,bool sl,bool upd); - void compareDoxyfile(FTextStream &t); + void writeTemplate(std::ostream &t,bool sl,bool upd); + void compareDoxyfile(std::ostream &t); void init() { m_value = m_defValue; } private: bool m_value; @@ -265,8 +266,8 @@ class ConfigObsolete : public ConfigOption public: ConfigObsolete(const char *name) : ConfigOption(O_Obsolete) { m_name = name; } - void writeTemplate(FTextStream &,bool,bool); - void compareDoxyfile(FTextStream &) {} + void writeTemplate(std::ostream &,bool,bool); + void compareDoxyfile(std::ostream &) {} void substEnvVars() {} }; @@ -277,8 +278,8 @@ class ConfigDisabled : public ConfigOption public: ConfigDisabled(const char *name) : ConfigOption(O_Disabled) { m_name = name; } - void writeTemplate(FTextStream &,bool,bool); - void compareDoxyfile(FTextStream &) {} + void writeTemplate(std::ostream &,bool,bool); + void compareDoxyfile(std::ostream &) {} void substEnvVars() {} }; @@ -472,12 +473,12 @@ class ConfigImpl * is \c TRUE the description of each configuration option will * be omitted. */ - void writeTemplate(FTextStream &t,bool shortIndex,bool updateOnly); + void writeTemplate(std::ostream &t,bool shortIndex,bool updateOnly); /*! Writes a the differences between the current configuration and the * template configuration to stream \a t. */ - void compareDoxyfile(FTextStream &t); + void compareDoxyfile(std::ostream &t); void setHeader(const char *header) { m_header = header; } diff --git a/src/configimpl.l b/src/configimpl.l index 2f1aefc..99f15a4 100644 --- a/src/configimpl.l +++ b/src/configimpl.l @@ -26,11 +26,10 @@ #include <ctype.h> #include <stdarg.h> #include <errno.h> - #include <thread> #include <algorithm> - -#include <qfile.h> +#include <fstream> +#include <iostream> #include "regex.h" #include "configimpl.h" @@ -129,18 +128,18 @@ static QCString convertToComment(const QCString &s, const QCString &u) return result; } -void ConfigOption::writeBoolValue(FTextStream &t,bool v) +void ConfigOption::writeBoolValue(std::ostream &t,bool v) { t << " "; if (v) t << "YES"; else t << "NO"; } -void ConfigOption::writeIntValue(FTextStream &t,int i) +void ConfigOption::writeIntValue(std::ostream &t,int i) { t << " " << i; } -void ConfigOption::writeStringValue(FTextStream &t,const QCString &s) +void ConfigOption::writeStringValue(std::ostream &t,const QCString &s) { char c; bool needsEscaping=FALSE; @@ -171,12 +170,12 @@ void ConfigOption::writeStringValue(FTextStream &t,const QCString &s) } } -void ConfigOption::writeStringList(FTextStream &t,const StringVector &l) +void ConfigOption::writeStringList(std::ostream &t,const StringVector &l) { bool first=TRUE; for (const auto &p : l) { - if (!first) t << " \\" << endl; + if (!first) t << " \\\n"; QCString s=p.c_str(); if (!first) t << " "; @@ -323,24 +322,24 @@ bool &ConfigImpl::getBool(const char *fileName,int num,const char *name) const /* ------------------------------------------ */ -void ConfigInfo::writeTemplate(FTextStream &t, bool sl,bool) +void ConfigInfo::writeTemplate(std::ostream &t, bool sl,bool) { if (!sl) { t << "\n"; } t << "#---------------------------------------------------------------------------\n"; - t << "# " << m_doc << endl; + t << "# " << m_doc << "\n"; t << "#---------------------------------------------------------------------------\n"; } -void ConfigList::writeTemplate(FTextStream &t,bool sl,bool) +void ConfigList::writeTemplate(std::ostream &t,bool sl,bool) { if (!sl) { - t << endl; + t << "\n"; t << convertToComment(m_doc, m_userComment); - t << endl; + t << "\n"; } else if (!m_userComment.isEmpty()) { @@ -351,7 +350,7 @@ void ConfigList::writeTemplate(FTextStream &t,bool sl,bool) t << "\n"; } -void ConfigList::compareDoxyfile(FTextStream &t) +void ConfigList::compareDoxyfile(std::ostream &t) { auto get_stripped = [](std::string s) { return QCString(s.c_str()).stripWhiteSpace(); }; auto is_not_empty = [get_stripped](std::string s) { return !get_stripped(s).isEmpty(); }; @@ -384,13 +383,13 @@ void ConfigList::compareDoxyfile(FTextStream &t) } } -void ConfigEnum::writeTemplate(FTextStream &t,bool sl,bool) +void ConfigEnum::writeTemplate(std::ostream &t,bool sl,bool) { if (!sl) { - t << endl; + t << "\n"; t << convertToComment(m_doc, m_userComment); - t << endl; + t << "\n"; } else if (!m_userComment.isEmpty()) { @@ -401,18 +400,18 @@ void ConfigEnum::writeTemplate(FTextStream &t,bool sl,bool) t << "\n"; } -void ConfigEnum::compareDoxyfile(FTextStream &t) +void ConfigEnum::compareDoxyfile(std::ostream &t) { if (m_value != m_defValue) writeTemplate(t,TRUE,TRUE); } -void ConfigString::writeTemplate(FTextStream &t,bool sl,bool) +void ConfigString::writeTemplate(std::ostream &t,bool sl,bool) { if (!sl) { - t << endl; + t << "\n"; t << convertToComment(m_doc, m_userComment); - t << endl; + t << "\n"; } else if (!m_userComment.isEmpty()) { @@ -423,18 +422,18 @@ void ConfigString::writeTemplate(FTextStream &t,bool sl,bool) t << "\n"; } -void ConfigString::compareDoxyfile(FTextStream &t) +void ConfigString::compareDoxyfile(std::ostream &t) { if (m_value.stripWhiteSpace() != m_defValue.stripWhiteSpace()) writeTemplate(t,TRUE,TRUE); } -void ConfigInt::writeTemplate(FTextStream &t,bool sl,bool upd) +void ConfigInt::writeTemplate(std::ostream &t,bool sl,bool upd) { if (!sl) { - t << endl; + t << "\n"; t << convertToComment(m_doc, m_userComment); - t << endl; + t << "\n"; } else if (!m_userComment.isEmpty()) { @@ -452,24 +451,25 @@ void ConfigInt::writeTemplate(FTextStream &t,bool sl,bool upd) t << "\n"; } -void ConfigInt::compareDoxyfile(FTextStream &t) +void ConfigInt::compareDoxyfile(std::ostream &t) { if (m_value != m_defValue) writeTemplate(t,TRUE,TRUE); } -void ConfigBool::writeTemplate(FTextStream &t,bool sl,bool upd) +void ConfigBool::writeTemplate(std::ostream &t,bool sl,bool upd) { if (!sl) { - t << endl; + t << "\n"; t << convertToComment(m_doc, m_userComment); - t << endl; + t << "\n"; } else if (!m_userComment.isEmpty()) { t << convertToComment("", m_userComment); } - t << m_name << m_spaces.left(MAX_OPTION_LENGTH-m_name.length()) << "="; + QCString spaces = m_spaces.left(MAX_OPTION_LENGTH-m_name.length()); + t << m_name << spaces << "="; if (upd && !m_valueString.isEmpty()) { writeStringValue(t,m_valueString); @@ -481,13 +481,13 @@ void ConfigBool::writeTemplate(FTextStream &t,bool sl,bool upd) t << "\n"; } -void ConfigBool::compareDoxyfile(FTextStream &t) +void ConfigBool::compareDoxyfile(std::ostream &t) { if (m_value != m_defValue) writeTemplate(t,TRUE,TRUE); } -void ConfigObsolete::writeTemplate(FTextStream &,bool,bool) {} -void ConfigDisabled::writeTemplate(FTextStream &,bool,bool) {} +void ConfigObsolete::writeTemplate(std::ostream &,bool,bool) {} +void ConfigDisabled::writeTemplate(std::ostream &,bool,bool) {} /* ----------------------------------------------------------------- * @@ -1083,14 +1083,14 @@ static void readIncludeFile(const char *incName) /*@ ---------------------------------------------------------------------------- */ -void ConfigImpl::writeTemplate(FTextStream &t,bool sl,bool upd) +void ConfigImpl::writeTemplate(std::ostream &t,bool sl,bool upd) { /* print first lines of user comment that were at the beginning of the file, might have special meaning for editors */ if (m_startComment) { - t << takeStartComment() << endl; + t << takeStartComment() << "\n"; } - t << "# Doxyfile " << getDoxygenVersion() << endl << endl; + t << "# Doxyfile " << getDoxygenVersion() << "\n\n"; if (!sl) { t << convertToComment(m_header,""); @@ -1107,10 +1107,10 @@ void ConfigImpl::writeTemplate(FTextStream &t,bool sl,bool upd) } } -void ConfigImpl::compareDoxyfile(FTextStream &t) +void ConfigImpl::compareDoxyfile(std::ostream &t) { t << "# Difference with default Doxyfile " << getFullVersion(); - t << endl; + t << "\n"; for (const auto &option : m_options) { option->m_userComment = ""; @@ -1302,53 +1302,32 @@ void ConfigImpl::create() static QCString configFileToString(const char *name) { if (name==0 || name[0]==0) return 0; - QFile f; + + auto stream2string = [](std::istream &in) -> std::string + { + std::string ret; + char buffer[4096]; + while (in.read(buffer, sizeof(buffer))) ret.append(buffer, sizeof(buffer)); + ret.append(buffer, in.gcount()); + if (!ret.empty() && ret[ret.length()-1]!='\n') ret+='\n'; // to help the scanner + return ret; + }; bool fileOpened=FALSE; if (name[0]=='-' && name[1]==0) // read from stdin { - fileOpened=f.open(IO_ReadOnly,stdin); - if (fileOpened) - { - const int bSize=4096; - QCString contents(bSize+1); - int totalSize=0; - int size; - while ((size=f.readBlock(contents.rawData()+totalSize,bSize))==bSize) - { - totalSize+=bSize; - contents.resize(totalSize+bSize+1); - } - totalSize+=size+2; - contents.resize(totalSize); - contents.at(totalSize-2)='\n'; // to help the scanner - contents.at(totalSize-1)='\0'; - return contents; - } + // read contents from stdin into contents string + return stream2string(std::cin); } else // read from file { - FileInfo fi(name); - if (!fi.exists() || !fi.isFile()) + std::ifstream f(name,std::istream::in); + if (!f.is_open()) { config_err("file '%s' not found\n",name); return ""; } - f.setName(name); - fileOpened=f.open(IO_ReadOnly); - if (fileOpened) - { - int fsize=f.size(); - QCString contents(fsize+2); - f.readBlock(contents.rawData(),fsize); - f.close(); - if (fsize==0 || contents[fsize-1]=='\n') - contents[fsize]='\0'; - else - contents[fsize]='\n'; // to help the scanner - contents[fsize+1]='\0'; - return contents; - } + return stream2string(f); } if (!fileOpened) { @@ -2090,12 +2069,12 @@ void Config::checkAndCorrect() } -void Config::writeTemplate(FTextStream &t,bool shortList,bool update) +void Config::writeTemplate(std::ostream &t,bool shortList,bool update) { ConfigImpl::instance()->writeTemplate(t,shortList,update); } -void Config::compareDoxyfile(FTextStream &t) +void Config::compareDoxyfile(std::ostream &t) { postProcess(FALSE, TRUE); ConfigImpl::instance()->compareDoxyfile(t); diff --git a/src/context.cpp b/src/context.cpp index dc7c31f..0064051 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -14,6 +14,7 @@ */ #include <assert.h> +#include <sstream> #include "context.h" #include "config.h" @@ -1258,31 +1259,29 @@ static TemplateVariant parseDoc(const Definition *def,const QCString &file,int l TemplateVariant result; DocRoot *root = validatingParseDoc(file,line,def,0,docStr,TRUE,FALSE, 0,isBrief,FALSE,Config_getBool(MARKDOWN_SUPPORT)); - QGString docs; + std::stringstream ts; + switch (g_globals.outputFormat) { - FTextStream ts(&docs); - switch (g_globals.outputFormat) - { - case ContextOutputFormat_Html: - { - HtmlCodeGenerator codeGen(ts,relPath); - HtmlDocVisitor visitor(ts,codeGen,def); - root->accept(&visitor); - } - break; - case ContextOutputFormat_Latex: - { - LatexCodeGenerator codeGen(ts,relPath,file); - LatexDocVisitor visitor(ts,codeGen,def->getDefFileExtension(),FALSE); - root->accept(&visitor); - } - break; - // TODO: support other generators - default: - err("context.cpp: output format not yet supported"); - break; - } + case ContextOutputFormat_Html: + { + HtmlCodeGenerator codeGen(ts,relPath); + HtmlDocVisitor visitor(ts,codeGen,def); + root->accept(&visitor); + } + break; + case ContextOutputFormat_Latex: + { + LatexCodeGenerator codeGen(ts,relPath,file); + LatexDocVisitor visitor(ts,codeGen,def->getDefFileExtension(),FALSE); + root->accept(&visitor); + } + break; + // TODO: support other generators + default: + err("context.cpp: output format not yet supported"); + break; } + QCString docs = ts.str().c_str(); bool isEmpty = root->isEmpty(); if (isEmpty) result = ""; @@ -1297,8 +1296,7 @@ static TemplateVariant parseCode(MemberDef *md,const QCString &scopeName,const Q { auto intf = Doxygen::parserManager->getCodeParser(md->getDefFileExtension()); intf->resetCodeParserState(); - QGString s; - FTextStream t(&s); + std::stringstream t; switch (g_globals.outputFormat) { case ContextOutputFormat_Html: @@ -1320,6 +1318,7 @@ static TemplateVariant parseCode(MemberDef *md,const QCString &scopeName,const Q err("context.cpp: output format not yet supported"); break; } + QCString s = t.str(); return TemplateVariant(s.data(),TRUE); } @@ -1328,8 +1327,7 @@ static TemplateVariant parseCode(const FileDef *fd,const QCString &relPath) static bool filterSourceFiles = Config_getBool(FILTER_SOURCE_FILES); auto intf = Doxygen::parserManager->getCodeParser(fd->getDefFileExtension()); intf->resetCodeParserState(); - QGString s; - FTextStream t(&s); + std::stringstream t; switch (g_globals.outputFormat) { case ContextOutputFormat_Html: @@ -1375,6 +1373,7 @@ static TemplateVariant parseCode(const FileDef *fd,const QCString &relPath) err("context.cpp: output format not yet supported"); break; } + QCString s = t.str(); return TemplateVariant(s.data(),TRUE); } @@ -1950,14 +1949,13 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private> } TemplateVariant inheritanceDiagram() const { - QGString result; + std::stringstream t; static bool haveDot = Config_getBool(HAVE_DOT); static bool classDiagrams = Config_getBool(CLASS_DIAGRAMS); static bool classGraph = Config_getBool(CLASS_GRAPH); if (haveDot && (classDiagrams || classGraph)) { DotClassGraph *cg = getClassGraph(); - FTextStream t(&result); switch (g_globals.outputFormat) { case ContextOutputFormat_Html: @@ -1988,34 +1986,33 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private> else if (classDiagrams) { ClassDiagram d(m_classDef); - FTextStream t(&result); switch (g_globals.outputFormat) { case ContextOutputFormat_Html: { - FTextStream tt(&result); + std::stringstream tt; QCString name = convertToHtml(m_classDef->displayName()); d.writeImage(tt,g_globals.outputDir, relPathAsString(), m_classDef->getOutputFileBase()); - if (!result.isEmpty()) + if (tt.tellg()>0) { - t << "<div class=\"center\">" << endl; + t << "<div class=\"center\">\n"; t << " <img src=\""; t << relPathAsString() << m_classDef->getOutputFileBase(); - t << ".png\" usemap=\"#" << convertToId(name) << "_map\" alt=\"\"/>" << endl; - t << " <map id=\"" << convertToId(name) << "_map\" name=\"" << convertToId(name) << "_map\">" << endl; - t << result; - t << " </map>" << endl; + t << ".png\" usemap=\"#" << convertToId(name) << "_map\" alt=\"\"/>\n"; + t << " <map id=\"" << convertToId(name) << "_map\" name=\"" << convertToId(name) << "_map\">\n"; + t << tt.str(); + t << " </map>\n"; t << "</div>"; } else { - t << "<div class=\"center\">" << endl; + t << "<div class=\"center\">\n"; t << " <img src=\""; t << relPathAsString() << m_classDef->getOutputFileBase(); - t << ".png\" alt=\"\"/>" << endl; + t << ".png\" alt=\"\"/>\n"; t << "</div>"; } } @@ -2032,6 +2029,7 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private> } g_globals.dynSectionId++; } + QCString result = t.str(); return TemplateVariant(result.data(),TRUE); } DotClassGraph *getCollaborationGraph() const @@ -2051,11 +2049,10 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private> TemplateVariant collaborationDiagram() const { static bool haveDot = Config_getBool(HAVE_DOT); - QGString result; + std::stringstream t; if (haveDot) { DotClassGraph *cg = getCollaborationGraph(); - FTextStream t(&result); switch (g_globals.outputFormat) { case ContextOutputFormat_Html: @@ -2083,6 +2080,7 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private> } g_globals.dynSectionId++; } + QCString result = t.str(); return TemplateVariant(result.data(),TRUE); } @@ -3056,11 +3054,10 @@ class FileContext::Private : public DefinitionContext<FileContext::Private> TemplateVariant includeGraph() const { static bool haveDot = Config_getBool(HAVE_DOT); - QGString result; + std::stringstream t; if (haveDot) { DotInclDepGraph *cg = getIncludeGraph(); - FTextStream t(&result); switch (g_globals.outputFormat) { case ContextOutputFormat_Html: @@ -3088,6 +3085,7 @@ class FileContext::Private : public DefinitionContext<FileContext::Private> } g_globals.dynSectionId++; } + QCString result = t.str(); return TemplateVariant(result.data(),TRUE); } DotInclDepGraph *getIncludedByGraph() const @@ -3108,11 +3106,10 @@ class FileContext::Private : public DefinitionContext<FileContext::Private> TemplateVariant includedByGraph() const { static bool haveDot = Config_getBool(HAVE_DOT); - QGString result; + std::stringstream t; if (haveDot) { DotInclDepGraph *cg = getIncludedByGraph(); - FTextStream t(&result); switch (g_globals.outputFormat) { case ContextOutputFormat_Html: @@ -3140,6 +3137,7 @@ class FileContext::Private : public DefinitionContext<FileContext::Private> } g_globals.dynSectionId++; } + QCString result = t.str(); return TemplateVariant(result.data(),TRUE); } TemplateVariant hasDetails() const @@ -3514,13 +3512,12 @@ class DirContext::Private : public DefinitionContext<DirContext::Private> } TemplateVariant dirGraph() const { - QGString result; + std::stringstream t; static bool haveDot = Config_getBool(HAVE_DOT); static bool dirGraph = Config_getBool(DIRECTORY_GRAPH); if (haveDot && dirGraph) { DotDirDeps *graph = getDirDepsGraph(); - FTextStream t(&result); switch (g_globals.outputFormat) { case ContextOutputFormat_Html: @@ -3554,6 +3551,7 @@ class DirContext::Private : public DefinitionContext<DirContext::Private> } g_globals.dynSectionId++; } + QCString result = t.str(); return TemplateVariant(result.data(),TRUE); } @@ -3731,7 +3729,7 @@ TemplateVariant PageContext::get(const char *n) const class TextGeneratorHtml : public TextGeneratorIntf { public: - TextGeneratorHtml(FTextStream &ts,const QCString &relPath) + TextGeneratorHtml(std::ostream &ts,const QCString &relPath) : m_ts(ts), m_relPath(relPath) {} void writeString(const char *s,bool keepSpaces) const { @@ -3805,7 +3803,7 @@ class TextGeneratorHtml : public TextGeneratorIntf } private: - FTextStream &m_ts; + std::ostream &m_ts; QCString m_relPath; }; @@ -3814,7 +3812,7 @@ class TextGeneratorHtml : public TextGeneratorIntf class TextGeneratorLatex : public TextGeneratorIntf { public: - TextGeneratorLatex(FTextStream &ts) : m_ts(ts) {} + TextGeneratorLatex(std::ostream &ts) : m_ts(ts) {} void writeString(const char *s,bool keepSpaces) const { if (s==0) return; @@ -3864,7 +3862,7 @@ class TextGeneratorLatex : public TextGeneratorIntf } private: - FTextStream &m_ts; + std::ostream &m_ts; }; //------------------------------------------------------------------------ @@ -3878,7 +3876,7 @@ class TextGeneratorFactory if (instance==0) instance = new TextGeneratorFactory; return instance; } - TextGeneratorIntf *create(FTextStream &ts,const QCString &relPath) + TextGeneratorIntf *create(std::ostream &ts,const QCString &relPath) { switch (g_globals.outputFormat) { @@ -3898,14 +3896,13 @@ class TextGeneratorFactory TemplateVariant createLinkedText(const Definition *def,const QCString &relPath,const QCString &text) { - QGString s; - FTextStream ts(&s); + std::stringstream ts; TextGeneratorIntf *tg = TextGeneratorFactory::instance()->create(ts,relPath); if (tg) { linkifyText(*tg,def->getOuterScope(),def->getBodyDef(),def,text); delete tg; - return TemplateVariant(s.data(),TRUE); + return TemplateVariant(ts.str().c_str(),true); } else { @@ -4940,8 +4937,7 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private> if (hasCallGraph().toBool()) { DotCallGraph *cg = getCallGraph(); - QGString result; - FTextStream t(&result); + std::stringstream t; switch (g_globals.outputFormat) { case ContextOutputFormat_Html: @@ -4968,6 +4964,7 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private> break; } g_globals.dynSectionId++; + QCString result = t.str(); return TemplateVariant(result.data(),TRUE); } else @@ -5012,8 +5009,7 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private> if (hasCallerGraph().toBool()) { DotCallGraph *cg = getCallerGraph(); - QGString result; - FTextStream t(&result); + std::stringstream t; switch (g_globals.outputFormat) { case ContextOutputFormat_Html: @@ -5040,6 +5036,7 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private> break; } g_globals.dynSectionId++; + QCString result = t.str(); return TemplateVariant(result.data(),TRUE); } else @@ -5276,13 +5273,12 @@ class ModuleContext::Private : public DefinitionContext<ModuleContext::Private> } TemplateVariant groupGraph() const { - QGString result; + std::stringstream t; static bool haveDot = Config_getBool(HAVE_DOT); static bool groupGraphs = Config_getBool(GROUP_GRAPHS); if (haveDot && groupGraphs) { DotGroupCollaboration *graph = getGroupGraph(); - FTextStream t(&result); switch (g_globals.outputFormat) { case ContextOutputFormat_Html: @@ -5314,6 +5310,7 @@ class ModuleContext::Private : public DefinitionContext<ModuleContext::Private> } g_globals.dynSectionId++; } + QCString result = t.str(); return TemplateVariant(result.data(),TRUE); } TemplateVariant hasDetails() const @@ -8294,12 +8291,11 @@ class InheritanceGraphContext::Private } TemplateVariant graph() const { - QGString result; + std::stringstream t; static bool haveDot = Config_getBool(HAVE_DOT); static bool graphicalHierarchy = Config_getBool(GRAPHICAL_HIERARCHY); if (haveDot && graphicalHierarchy) { - FTextStream t(&result); m_hierarchy->createGraph(m_node,t, /*GOF_BITMAP, EOF_Html,*/ @@ -8307,6 +8303,7 @@ class InheritanceGraphContext::Private g_globals.outputDir+Portable::pathSeparator()+"inherits"+Doxygen::htmlFileExtension, m_id); } + QCString result = t.str(); return TemplateVariant(result.data(),TRUE); } private: @@ -10120,7 +10117,7 @@ void generateOutputViaTemplate() HtmlSpaceless spl; ctx->setSpacelessIntf(&spl); ctx->setOutputDirectory(g_globals.outputDir); - FTextStream ts; + std::stringstream ts; tpl->render(ts,ctx); e.unload(tpl); } @@ -10145,7 +10142,7 @@ void generateOutputViaTemplate() LatexSpaceless spl; ctx->setSpacelessIntf(&spl); ctx->setOutputDirectory(g_globals.outputDir); - FTextStream ts; + std::stringstream ts; tpl->render(ts,ctx); e.unload(tpl); } diff --git a/src/defgen.cpp b/src/defgen.cpp index 4ad2d41..3012e91 100644 --- a/src/defgen.cpp +++ b/src/defgen.cpp @@ -18,6 +18,8 @@ #include <stdlib.h> +#include <fstream> + #include "defgen.h" #include "doxygen.h" #include "message.h" @@ -35,11 +37,9 @@ #include "filename.h" #include "dir.h" -#include <qfile.h> - #define DEF_DB(x) -static inline void writeDEFString(FTextStream &t,const char *s) +static inline void writeDEFString(std::ofstream &t,const char *s) { const char* p=s; char c; @@ -55,7 +55,7 @@ static inline void writeDEFString(FTextStream &t,const char *s) } static void generateDEFForMember(const MemberDef *md, - FTextStream &t, + std::ofstream &t, const Definition *def, const char* Prefix) { @@ -80,7 +80,7 @@ static void generateDEFForMember(const MemberDef *md, else if (md->getNamespaceDef()) scopeName=md->getNamespaceDef()->name(); - t << " " << Prefix << "-member = {" << endl; + t << " " << Prefix << "-member = {\n"; memPrefix = " "; memPrefix.append( Prefix ); memPrefix.append( "-mem-" ); @@ -107,27 +107,27 @@ static void generateDEFForMember(const MemberDef *md, case MemberType_Slot: memType="slot"; isFunc=TRUE; break; } - t << memPrefix << "kind = '" << memType << "';" << endl; + t << memPrefix << "kind = '" << memType << "';\n"; t << memPrefix << "id = '" << md->getOutputFileBase() << "_1" << md->anchor() - << "';" << endl; + << "';\n"; t << memPrefix << "virt = "; switch (md->virtualness()) { - case Normal: t << "normal;" << endl; break; - case Virtual: t << "virtual;" << endl; break; - case Pure: t << "pure-virtual;" << endl; break; + case Normal: t << "normal;\n"; break; + case Virtual: t << "virtual;\n"; break; + case Pure: t << "pure-virtual;\n"; break; default: ASSERT(0); } t << memPrefix << "prot = "; switch(md->protection()) { - case Public: t << "public;" << endl; break; - case Protected: t << "protected;" << endl; break; - case Private: t << "private;" << endl; break; - case Package: t << "package;" << endl; break; + case Public: t << "public;\n"; break; + case Protected: t << "protected;\n"; break; + case Private: t << "private;\n"; break; + case Package: t << "package;\n"; break; } if (md->memberType()!=MemberType_Define && @@ -135,11 +135,11 @@ static void generateDEFForMember(const MemberDef *md, ) { QCString typeStr = replaceAnonymousScopes(md->typeString()); - t << memPrefix << "type = <<_EnD_oF_dEf_TeXt_" << endl << typeStr << endl - << "_EnD_oF_dEf_TeXt_;" << endl; + t << memPrefix << "type = <<_EnD_oF_dEf_TeXt_\n" << typeStr << "\n" + << "_EnD_oF_dEf_TeXt_;\n"; } - t << memPrefix << "name = '" << md->name() << "';" << endl; + t << memPrefix << "name = '" << md->name() << "';\n"; if (isFunc) //function { @@ -156,42 +156,42 @@ static void generateDEFForMember(const MemberDef *md, defArg = &(*defIt); ++defIt; } - t << memPrefix << "param = {" << endl; + t << memPrefix << "param = {\n"; if (!a.attrib.isEmpty()) { t << fcnPrefix << "attributes = "; writeDEFString(t,a.attrib); - t << ';' << endl; + t << ";\n"; } if (!a.type.isEmpty()) { - t << fcnPrefix << "type = <<_EnD_oF_dEf_TeXt_" << endl - << a.type << endl << "_EnD_oF_dEf_TeXt_;" << endl; + t << fcnPrefix << "type = <<_EnD_oF_dEf_TeXt_\n" + << a.type << "\n_EnD_oF_dEf_TeXt_;\n"; } if (!a.name.isEmpty()) { t << fcnPrefix << "declname = "; writeDEFString(t,a.name); - t << ';' << endl; + t << ";\n"; } if (defArg && !defArg->name.isEmpty() && defArg->name!=a.name) { t << fcnPrefix << "defname = "; writeDEFString(t,defArg->name); - t << ';' << endl; + t << ";\n"; } if (!a.array.isEmpty()) { t << fcnPrefix << "array = "; writeDEFString(t,a.array); - t << ';' << endl; + t << ";\n"; } if (!a.defval.isEmpty()) { - t << fcnPrefix << "defval = <<_EnD_oF_dEf_TeXt_" << endl - << a.defval << endl << "_EnD_oF_dEf_TeXt_;" << endl; + t << fcnPrefix << "defval = <<_EnD_oF_dEf_TeXt_\n" + << a.defval << "\n_EnD_oF_dEf_TeXt_;\n"; } - t << " }; /*" << fcnPrefix << "-param */" << endl; + t << " }; /*" << fcnPrefix << "-param */\n"; } } else if ( md->memberType()==MemberType_Define @@ -200,16 +200,16 @@ static void generateDEFForMember(const MemberDef *md, QCString defPrefix = " " + memPrefix + "def-"; for (const Argument &a : md->argumentList()) { - t << memPrefix << "param = {" << endl; - t << defPrefix << "name = '" << a.type << "';" << endl; - t << " }; /*" << defPrefix << "-param */" << endl; + t << memPrefix << "param = {\n"; + t << defPrefix << "name = '" << a.type << "';\n"; + t << " }; /*" << defPrefix << "-param */\n"; } } if (!md->initializer().isEmpty()) { - t << memPrefix << "initializer = <<_EnD_oF_dEf_TeXt_" << endl - << md->initializer() << endl << "_EnD_oF_dEf_TeXt_;" << endl; + t << memPrefix << "initializer = <<_EnD_oF_dEf_TeXt_\n" + << md->initializer() << "\n_EnD_oF_dEf_TeXt_;\n"; } // TODO: exceptions, const volatile if (md->memberType()==MemberType_Enumeration) // enum @@ -223,16 +223,16 @@ static void generateDEFForMember(const MemberDef *md, writeDEFString(t,emd->initializer()); t << ';'; } - t << " };" << endl; + t << " };\n"; } } - t << memPrefix << "desc-file = '" << md->getDefFileName() << "';" << endl; - t << memPrefix << "desc-line = '" << md->getDefLine() << "';" << endl; - t << memPrefix << "briefdesc = <<_EnD_oF_dEf_TeXt_" << endl - << md->briefDescription() << endl << "_EnD_oF_dEf_TeXt_;" << endl; - t << memPrefix << "documentation = <<_EnD_oF_dEf_TeXt_" << endl - << md->documentation() << endl << "_EnD_oF_dEf_TeXt_;" << endl; + t << memPrefix << "desc-file = '" << md->getDefFileName() << "';\n"; + t << memPrefix << "desc-line = '" << md->getDefLine() << "';\n"; + t << memPrefix << "briefdesc = <<_EnD_oF_dEf_TeXt_\n" + << md->briefDescription() << "\n_EnD_oF_dEf_TeXt_;\n"; + t << memPrefix << "documentation = <<_EnD_oF_dEf_TeXt_\n" + << md->documentation() << "\n_EnD_oF_dEf_TeXt_;\n"; //printf("md->getReferencesMembers()=%p\n",md->getReferencesMembers()); @@ -242,14 +242,14 @@ static void generateDEFForMember(const MemberDef *md, { if (rmd->getStartBodyLine()!=-1 && rmd->getBodyDef()) { - t << memPrefix << "referenceto = {" << endl; + t << memPrefix << "referenceto = {\n"; t << refPrefix << "id = '" << rmd->getBodyDef()->getOutputFileBase() << "_1" // encoded ':' character (see util.cpp:convertNameToFile) - << rmd->anchor() << "';" << endl; + << rmd->anchor() << "';\n"; t << refPrefix << "line = '" - << rmd->getStartBodyLine() << "';" << endl; + << rmd->getStartBodyLine() << "';\n"; QCString scope = rmd->getScopeString(); QCString name = rmd->name(); @@ -260,7 +260,7 @@ static void generateDEFForMember(const MemberDef *md, t << refPrefix << "name = "; writeDEFString(t,name); - t << ';' << endl << " };" << endl; + t << ';' << "\n };\n"; } } auto refByList = md->getReferencedByMembers(); @@ -268,14 +268,14 @@ static void generateDEFForMember(const MemberDef *md, { if (rmd->getStartBodyLine()!=-1 && rmd->getBodyDef()) { - t << memPrefix << "referencedby = {" << endl; + t << memPrefix << "referencedby = {\n"; t << refPrefix << "id = '" << rmd->getBodyDef()->getOutputFileBase() << "_1" // encoded ':' character (see util.cpp:convertNameToFile) - << rmd->anchor() << "';" << endl; + << rmd->anchor() << "';\n"; t << refPrefix << "line = '" - << rmd->getStartBodyLine() << "';" << endl; + << rmd->getStartBodyLine() << "';\n"; QCString scope = rmd->getScopeString(); QCString name = rmd->name(); @@ -286,33 +286,33 @@ static void generateDEFForMember(const MemberDef *md, t << refPrefix << "name = "; writeDEFString(t,name); - t << ';' << endl << " };" << endl; + t << ';' << "\n };\n"; } } - t << " }; /* " << Prefix << "-member */" << endl; + t << " }; /* " << Prefix << "-member */\n"; } static void generateDEFClassSection(const ClassDef *cd, - FTextStream &t, + std::ofstream &t, const MemberList *ml, const char *kind) { if (cd && ml && !ml->empty()) { - t << " cp-section = {" << endl; - t << " sec-kind = '" << kind << "';" << endl; + t << " cp-section = {\n"; + t << " sec-kind = '" << kind << "';\n"; for (const auto &md : *ml) { generateDEFForMember(md,t,cd,"sec"); } - t << " }; /* cp-section */" << endl; + t << " }; /* cp-section */\n"; } } -static void generateDEFForClass(const ClassDef *cd,FTextStream &t) +static void generateDEFForClass(const ClassDef *cd,std::ofstream &t) { // + brief description // + detailed description @@ -332,22 +332,22 @@ static void generateDEFForClass(const ClassDef *cd,FTextStream &t) if (cd->name().find('@')!=-1) return; // skip anonymous compounds. if (cd->templateMaster()!=0) return; // skip generated template instances. - t << cd->compoundTypeString() << " = {" << endl; - t << " cp-id = '" << cd->getOutputFileBase() << "';" << endl; - t << " cp-name = '" << cd->name() << "';" << endl; + t << cd->compoundTypeString() << " = {\n"; + t << " cp-id = '" << cd->getOutputFileBase() << "';\n"; + t << " cp-name = '" << cd->name() << "';\n"; for (const auto &bcd : cd->baseClasses()) { - t << " cp-ref = {" << endl << " ref-type = base;" << endl; + t << " cp-ref = {\n" << " ref-type = base;\n"; t << " ref-id = '" - << bcd.classDef->getOutputFileBase() << "';" << endl; + << bcd.classDef->getOutputFileBase() << "';\n"; t << " ref-prot = "; switch (bcd.prot) { - case Public: t << "public;" << endl; break; + case Public: t << "public;\n"; break; case Package: // package scope is not possible - case Protected: t << "protected;" << endl; break; - case Private: t << "private;" << endl; break; + case Protected: t << "protected;\n"; break; + case Private: t << "private;\n"; break; } t << " ref-virt = "; switch(bcd.virt) @@ -356,21 +356,21 @@ static void generateDEFForClass(const ClassDef *cd,FTextStream &t) case Virtual: t << "virtual;"; break; case Pure: t << "pure-virtual;"; break; } - t << endl << " };" << endl; + t << "\n };\n"; } for (const auto &bcd : cd->subClasses()) { - t << " cp-ref = {" << endl << " ref-type = derived;" << endl; + t << " cp-ref = {\n" << " ref-type = derived;\n"; t << " ref-id = '" - << bcd.classDef->getOutputFileBase() << "';" << endl; + << bcd.classDef->getOutputFileBase() << "';\n"; t << " ref-prot = "; switch (bcd.prot) { - case Public: t << "public;" << endl; break; + case Public: t << "public;\n"; break; case Package: // packet scope is not possible! - case Protected: t << "protected;" << endl; break; - case Private: t << "private;" << endl; break; + case Protected: t << "protected;\n"; break; + case Private: t << "private;\n"; break; } t << " ref-virt = "; switch (bcd.virt) @@ -379,7 +379,7 @@ static void generateDEFForClass(const ClassDef *cd,FTextStream &t) case Virtual: t << "virtual;"; break; case Pure: t << "pure-virtual;"; break; } - t << endl << " };" << endl; + t << "\n };\n"; } size_t numMembers = 0; @@ -419,55 +419,55 @@ static void generateDEFForClass(const ClassDef *cd,FTextStream &t) generateDEFClassSection(cd,t,cd->getMemberList(MemberListType_related),"related"); } - t << " cp-filename = '" << cd->getDefFileName() << "';" << endl; - t << " cp-fileline = '" << cd->getDefLine() << "';" << endl; - t << " cp-briefdesc = <<_EnD_oF_dEf_TeXt_" << endl - << cd->briefDescription() << endl << "_EnD_oF_dEf_TeXt_;" << endl; + t << " cp-filename = '" << cd->getDefFileName() << "';\n"; + t << " cp-fileline = '" << cd->getDefLine() << "';\n"; + t << " cp-briefdesc = <<_EnD_oF_dEf_TeXt_\n" + << cd->briefDescription() << "\n_EnD_oF_dEf_TeXt_;\n"; - t << " cp-documentation = <<_EnD_oF_dEf_TeXt_" << endl - << cd->documentation() << endl << "_EnD_oF_dEf_TeXt_;" << endl; + t << " cp-documentation = <<_EnD_oF_dEf_TeXt_\n" + << cd->documentation() << "\n_EnD_oF_dEf_TeXt_;\n"; DotClassGraph inheritanceGraph(cd,Inheritance); if (!inheritanceGraph.isTrivial()) { - t << " cp-inheritancegraph = <<_EnD_oF_dEf_TeXt_" << endl; + t << " cp-inheritancegraph = <<_EnD_oF_dEf_TeXt_\n"; inheritanceGraph.writeDEF(t); - t << endl << "_EnD_oF_dEf_TeXt_;" << endl; + t << "\n_EnD_oF_dEf_TeXt_;\n"; } DotClassGraph collaborationGraph(cd,Collaboration); if (!collaborationGraph.isTrivial()) { - t << " cp-collaborationgraph = <<_EnD_oF_dEf_TeXt_" << endl; + t << " cp-collaborationgraph = <<_EnD_oF_dEf_TeXt_\n"; collaborationGraph.writeDEF(t); - t << endl << "_EnD_oF_dEf_TeXt_;" << endl; + t << "\n_EnD_oF_dEf_TeXt_;\n"; } - t << "}; /* " << cd->compoundTypeString() << " */" << endl; + t << "}; /* " << cd->compoundTypeString() << " */\n"; } static void generateDEFSection(const Definition *d, - FTextStream &t, + std::ofstream &t, const MemberList *ml, const char *kind) { if (ml && !ml->empty()) { - t << " " << kind << " = {" << endl; + t << " " << kind << " = {\n"; for (const auto &md : *ml) { generateDEFForMember(md,t,d,kind); } - t << " };" << endl; + t << " };\n"; } } -static void generateDEFForNamespace(const NamespaceDef *nd,FTextStream &t) +static void generateDEFForNamespace(const NamespaceDef *nd,std::ofstream &t) { if (nd->isReference()) return; // skip external references - t << " namespace = {" << endl; - t << " ns-id = '" << nd->getOutputFileBase() << "';" << endl; + t << " namespace = {\n"; + t << " ns-id = '" << nd->getOutputFileBase() << "';\n"; t << " ns-name = "; writeDEFString(t,nd->name()); - t << ';' << endl; + t << ";\n"; generateDEFSection(nd,t,nd->getMemberList(MemberListType_decDefineMembers),"define"); generateDEFSection(nd,t,nd->getMemberList(MemberListType_decProtoMembers),"prototype"); @@ -478,25 +478,25 @@ static void generateDEFForNamespace(const NamespaceDef *nd,FTextStream &t) generateDEFSection(nd,t,nd->getMemberList(MemberListType_decFuncMembers),"func"); generateDEFSection(nd,t,nd->getMemberList(MemberListType_decVarMembers),"var"); - t << " ns-filename = '" << nd->getDefFileName() << "';" << endl; - t << " ns-fileline = '" << nd->getDefLine() << "';" << endl; - t << " ns-briefdesc = <<_EnD_oF_dEf_TeXt_" << endl - << nd->briefDescription() << endl << "_EnD_oF_dEf_TeXt_;" << endl; + t << " ns-filename = '" << nd->getDefFileName() << "';\n"; + t << " ns-fileline = '" << nd->getDefLine() << "';\n"; + t << " ns-briefdesc = <<_EnD_oF_dEf_TeXt_\n" + << nd->briefDescription() << "\n_EnD_oF_dEf_TeXt_;\n"; - t << " ns-documentation = <<_EnD_oF_dEf_TeXt_" << endl - << nd->documentation() << endl << "_EnD_oF_dEf_TeXt_;" << endl; - t << " };" << endl; + t << " ns-documentation = <<_EnD_oF_dEf_TeXt_\n" + << nd->documentation() << "\n_EnD_oF_dEf_TeXt_;\n"; + t << " };\n"; } -static void generateDEFForFile(const FileDef *fd,FTextStream &t) +static void generateDEFForFile(const FileDef *fd,std::ofstream &t) { if (fd->isReference()) return; // skip external references - t << "file = {" << endl; - t << " file-id = '" << fd->getOutputFileBase() << "';" << endl; + t << "file = {\n"; + t << " file-id = '" << fd->getOutputFileBase() << "';\n"; t << " file-name = "; writeDEFString(t,fd->name()); - t << ';' << endl; + t << ";\n"; generateDEFSection(fd,t,fd->getMemberList(MemberListType_decDefineMembers),"define"); generateDEFSection(fd,t,fd->getMemberList(MemberListType_decProtoMembers),"prototype"); @@ -507,16 +507,16 @@ static void generateDEFForFile(const FileDef *fd,FTextStream &t) generateDEFSection(fd,t,fd->getMemberList(MemberListType_decFuncMembers),"func"); generateDEFSection(fd,t,fd->getMemberList(MemberListType_decVarMembers),"var"); - t << " file-full-name = '" << fd->getDefFileName() << "';" << endl; - t << " file-first-line = '" << fd->getDefLine() << "';" << endl; + t << " file-full-name = '" << fd->getDefFileName() << "';\n"; + t << " file-first-line = '" << fd->getDefLine() << "';\n"; - t << " file-briefdesc = <<_EnD_oF_dEf_TeXt_" << endl - << fd->briefDescription() << endl << "_EnD_oF_dEf_TeXt_;" << endl; + t << " file-briefdesc = <<_EnD_oF_dEf_TeXt_\n" + << fd->briefDescription() << "\n_EnD_oF_dEf_TeXt_;\n"; - t << " file-documentation = <<_EnD_oF_dEf_TeXt_" << endl - << fd->documentation() << endl << "_EnD_oF_dEf_TeXt_;" << endl; + t << " file-documentation = <<_EnD_oF_dEf_TeXt_\n" + << fd->documentation() << "\n_EnD_oF_dEf_TeXt_;\n"; - t << "}; /* file */" << endl; + t << "}; /* file */\n"; } @@ -531,14 +531,13 @@ void generateDEF() } QCString fileName=outputDirectory+"/doxygen.def"; - QFile f(fileName); - if (!f.open(IO_WriteOnly)) + std::ofstream t(fileName.str(),std::ostream::out); + if (!t.is_open()) { err("Cannot open file %s for writing!\n",fileName.data()); return; } - FTextStream t(&f); - t << "AutoGen Definitions dummy;" << endl; + t << "AutoGen Definitions dummy;\n"; if (Doxygen::classLinkedMap->size()+ Doxygen::inputNameLinkedMap->size()+ @@ -562,6 +561,6 @@ void generateDEF() } else { - t << "dummy_value = true;" << endl; + t << "dummy_value = true;\n"; } } diff --git a/src/definition.cpp b/src/definition.cpp index 70c1839..03ca911 100644 --- a/src/definition.cpp +++ b/src/definition.cpp @@ -20,6 +20,8 @@ #include <unordered_map> #include <string> +#include <qstring.h> + #include <ctype.h> #include "md5.h" #include <stdio.h> @@ -405,7 +407,7 @@ void DefinitionImpl::addSectionsToIndex() } } -void DefinitionImpl::writeDocAnchorsToTagFile(FTextStream &tagFile) const +void DefinitionImpl::writeDocAnchorsToTagFile(std::ostream &tagFile) const { if (!m_impl->sectionRefs.empty()) { @@ -421,7 +423,7 @@ void DefinitionImpl::writeDocAnchorsToTagFile(FTextStream &tagFile) const { tagFile << " title=\"" << convertToXML(si->title()) << "\""; } - tagFile << ">" << si->label() << "</docanchor>" << endl; + tagFile << ">" << si->label() << "</docanchor>\n"; } } } diff --git a/src/definition.h b/src/definition.h index 4c0c566..900bbb2 100644 --- a/src/definition.h +++ b/src/definition.h @@ -19,6 +19,7 @@ #define DEFINITION_H #include <vector> +#include <iostream> #include "types.h" #include "reflist.h" @@ -39,7 +40,6 @@ class SectionInfo; class Definition; class DefinitionMutable; class DefinitionImpl; -class FTextStream; /** Data associated with a detailed description. */ struct DocInfo @@ -383,7 +383,7 @@ class DefinitionMutable virtual void writeNavigationPath(OutputList &ol) const = 0; virtual void writeQuickMemberLinks(OutputList &,const MemberDef *) const = 0; virtual void writeSummaryLinks(OutputList &) const = 0; - virtual void writeDocAnchorsToTagFile(FTextStream &) const = 0; + virtual void writeDocAnchorsToTagFile(std::ostream &) const = 0; virtual void writeToc(OutputList &ol, const LocalToc <) const = 0; // --------------------------------- diff --git a/src/definitionimpl.h b/src/definitionimpl.h index 541e346..0ac394f 100644 --- a/src/definitionimpl.h +++ b/src/definitionimpl.h @@ -111,7 +111,7 @@ class DefinitionImpl void writeQuickMemberLinks(OutputList &,const MemberDef *) const; void writeSummaryLinks(OutputList &) const; QCString pathFragment() const; - void writeDocAnchorsToTagFile(FTextStream &) const; + void writeDocAnchorsToTagFile(std::ostream &) const; void setLocalName(const QCString name); void addSectionsToIndex(); void writeToc(OutputList &ol, const LocalToc <) const; @@ -261,7 +261,7 @@ class DefinitionMixin : public Base { m_impl.writeSummaryLinks(ol); } virtual QCString pathFragment() const { return m_impl.pathFragment(); } - virtual void writeDocAnchorsToTagFile(FTextStream &fs) const + virtual void writeDocAnchorsToTagFile(std::ostream &fs) const { m_impl.writeDocAnchorsToTagFile(fs); } virtual void setLocalName(const QCString name) { m_impl.setLocalName(name); } @@ -1,12 +1,12 @@ /****************************************************************************** * - * + * * * Copyright (C) 1997-2015 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its - * documentation under the terms of the GNU General Public License is hereby - * granted. No representations are made about the suitability of this software + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * @@ -19,7 +19,6 @@ #define _DIA_H class QCString; -class FTextStream; enum DiaOutputFormat { DIA_BITMAP , DIA_EPS }; diff --git a/src/diagram.cpp b/src/diagram.cpp index 052c1f4..5054756 100644 --- a/src/diagram.cpp +++ b/src/diagram.cpp @@ -15,8 +15,7 @@ #include <stdio.h> #include <stdlib.h> -#include "ftextstream.h" -#include <qfile.h> +#include <fstream> #include "diagram.h" #include "image.h" @@ -107,13 +106,13 @@ class TreeDiagram uint computeRows(); void moveChildren(DiagramItem *root,int dx); void computeExtremes(uint *labelWidth,uint *xpos); - void drawBoxes(FTextStream &t,Image *image, + void drawBoxes(std::ostream &t,Image *image, bool doBase,bool bitmap, uint baseRows,uint superRows, uint cellWidth,uint cellHeight, QCString relPath="", bool generateMap=TRUE); - void drawConnectors(FTextStream &t,Image *image, + void drawConnectors(std::ostream &t,Image *image, bool doBase,bool bitmap, uint baseRows,uint superRows, uint cellWidth,uint cellheight); @@ -232,7 +231,7 @@ static void writeBitmapBox(DiagramItem *di,Image *image, } } -static void writeVectorBox(FTextStream &t,DiagramItem *di, +static void writeVectorBox(std::ostream &t,DiagramItem *di, float x,float y,bool children=FALSE) { if (di->virtualness()==Virtual) t << "dashed\n"; @@ -241,7 +240,7 @@ static void writeVectorBox(FTextStream &t,DiagramItem *di, if (di->virtualness()==Virtual) t << "solid\n"; } -static void writeMapArea(FTextStream &t,const ClassDef *cd,QCString relPath, +static void writeMapArea(std::ostream &t,const ClassDef *cd,QCString relPath, uint x,uint y,uint w,uint h) { if (cd->isLinkable()) @@ -267,7 +266,7 @@ static void writeMapArea(FTextStream &t,const ClassDef *cd,QCString relPath, } t << "alt=\"" << convertToXML(cd->displayName()); t << "\" shape=\"rect\" coords=\"" << x << "," << y << ","; - t << (x+w) << "," << (y+h) << "\"/>" << endl; + t << (x+w) << "," << (y+h) << "\"/>\n"; } } //----------------------------------------------------------------------------- @@ -564,7 +563,7 @@ class DualDirIterator typename C::reverse_iterator m_rit; }; -void TreeDiagram::drawBoxes(FTextStream &t,Image *image, +void TreeDiagram::drawBoxes(std::ostream &t,Image *image, bool doBase,bool bitmap, uint baseRows,uint superRows, uint cellWidth,uint cellHeight, @@ -694,7 +693,7 @@ void TreeDiagram::drawBoxes(FTextStream &t,Image *image, } } -void TreeDiagram::drawConnectors(FTextStream &t,Image *image, +void TreeDiagram::drawConnectors(std::ostream &t,Image *image, bool doBase,bool bitmap, uint baseRows,uint superRows, uint cellWidth,uint cellHeight) @@ -742,7 +741,7 @@ void TreeDiagram::drawConnectors(FTextStream &t,Image *image, } else // draw vectors { - t << protToString(di->protection()) << endl; + t << protToString(di->protection()) << "\n"; if (doBase) { t << "1 " << (di->xPos()/(float)gridWidth) << " " @@ -811,7 +810,7 @@ void TreeDiagram::drawConnectors(FTextStream &t,Image *image, } else { - t << protToString(di->protection()) << endl; + t << protToString(di->protection()) << "\n"; if (doBase) { t << "1 " << xf << " " << yf << " hedge\n"; @@ -850,7 +849,7 @@ void TreeDiagram::drawConnectors(FTextStream &t,Image *image, } else { - t << protToString(di->protection()) << endl; + t << protToString(di->protection()) << "\n"; if (doBase) { t << "1 " << xf << " " << yf << " hedge\n"; @@ -859,7 +858,7 @@ void TreeDiagram::drawConnectors(FTextStream &t,Image *image, { t << "0 " << xf << " " << yf << " hedge\n"; } - t << protToString(getMinProtectionLevel(dil)) << endl; + t << protToString(getMinProtectionLevel(dil)) << "\n"; if (doBase) { t << xf << " " << ysf << " " << yf << " vedge\n"; @@ -909,7 +908,7 @@ void TreeDiagram::drawConnectors(FTextStream &t,Image *image, } else // draw pixels { - t << protToString(di->protection()) << endl; + t << protToString(di->protection()) << "\n"; if (doBase) { t << "1 " << di->xPos()/(float)gridWidth << " " @@ -949,7 +948,7 @@ void TreeDiagram::drawConnectors(FTextStream &t,Image *image, } else { - t << protToString(p) << endl; + t << protToString(p) << "\n"; if (doBase) { t << "0 " << di->xPos()/(float)gridWidth << " " @@ -984,7 +983,7 @@ void TreeDiagram::drawConnectors(FTextStream &t,Image *image, } else { - t << protToString(p) << endl; + t << protToString(p) << "\n"; if (doBase) { t << first->xPos()/(float)gridWidth << " " @@ -1043,7 +1042,7 @@ ClassDiagram::~ClassDiagram() { } -void ClassDiagram::writeFigure(FTextStream &output,const char *path, +void ClassDiagram::writeFigure(std::ostream &output,const char *path, const char *fileName) const { uint baseRows=p->base.computeRows(); @@ -1078,7 +1077,7 @@ void ClassDiagram::writeFigure(FTextStream &output,const char *path, "\\begin{center}\n" "\\leavevmode\n"; output << "\\includegraphics[height=" << realHeight << "cm]{" - << fileName << "}" << endl; + << fileName << "}\n"; output << "\\end{center}\n" "\\end{figure}\n"; @@ -1086,13 +1085,11 @@ void ClassDiagram::writeFigure(FTextStream &output,const char *path, QCString epsBaseName=(QCString)path+"/"+fileName; QCString epsName=epsBaseName+".eps"; - QFile f1; - f1.setName(epsName.data()); - if (!f1.open(IO_WriteOnly)) + std::ofstream t(epsName.str(),std::ofstream::out | std::ofstream::binary); + if (!t.is_open()) { - term("Could not open file %s for writing\n",f1.name().data()); + term("Could not open file %s for writing\n",epsName.data()); } - FTextStream t(&f1); //printf("writeEPS() rows=%d cols=%d\n",rows,cols); @@ -1317,7 +1314,7 @@ void ClassDiagram::writeFigure(FTextStream &output,const char *path, p->base.drawConnectors(t,0,TRUE,FALSE,baseRows,superRows,0,0); p->super.drawConnectors(t,0,FALSE,FALSE,baseRows,superRows,0,0); - f1.close(); + t.close(); if (Config_getBool(USE_PDFLATEX)) { QCString epstopdfArgs(4096); @@ -1336,7 +1333,7 @@ void ClassDiagram::writeFigure(FTextStream &output,const char *path, } -void ClassDiagram::writeImage(FTextStream &t,const char *path, +void ClassDiagram::writeImage(std::ostream &t,const char *path, const char *relPath,const char *fileName, bool generateMap) const { diff --git a/src/diagram.h b/src/diagram.h index d8e7612..9f8ba82 100644 --- a/src/diagram.h +++ b/src/diagram.h @@ -20,9 +20,9 @@ #define DIAGRAM_H #include <memory> +#include <iostream> class ClassDef; -class FTextStream; /** Class representing a built-in class diagram. */ class ClassDiagram @@ -30,10 +30,10 @@ class ClassDiagram public: ClassDiagram(const ClassDef *root); ~ClassDiagram(); - void writeFigure(FTextStream &t,const char *path, + void writeFigure(std::ostream &t,const char *path, const char *file) const; - void writeImage(FTextStream &t,const char *path,const char *relPath, - const char *file,bool generateMap=TRUE) const; + void writeImage(std::ostream &t,const char *path,const char *relPath, + const char *file,bool generateMap=true) const; private: struct Private; std::unique_ptr<Private> p; diff --git a/src/dir.cpp b/src/dir.cpp index caef5c7..558045b 100644 --- a/src/dir.cpp +++ b/src/dir.cpp @@ -259,6 +259,16 @@ bool Dir::rename(const std::string &orgName,const std::string &newName,bool acce return !ec; } +bool Dir::copy(const std::string &srcName,const std::string &dstName,bool acceptsAbsPath) const +{ + const auto copyOptions = fs::copy_options::overwrite_existing; + std::error_code ec; + std::string sn = filePath(srcName,acceptsAbsPath); + std::string dn = filePath(dstName,acceptsAbsPath); + fs::copy(sn,dn,copyOptions,ec); + return !ec; +} + std::string Dir::currentDirPath() { std::error_code ec; @@ -86,6 +86,7 @@ class Dir final bool remove(const std::string &path,bool acceptsAbsPath=true) const; bool rename(const std::string &orgName,const std::string &newName, bool acceptsAbsPath=true) const; + bool copy(const std::string &src,const std::string &dest,bool acceptsAbsPath=true) const; std::string absPath() const; bool isRelative() const; diff --git a/src/dirdef.cpp b/src/dirdef.cpp index 5e5ca93..6e95755 100644 --- a/src/dirdef.cpp +++ b/src/dirdef.cpp @@ -26,7 +26,6 @@ #include "dot.h" #include "dotdirdeps.h" #include "layout.h" -#include "ftextstream.h" #include "config.h" #include "docparser.h" #include "definitionimpl.h" @@ -62,7 +61,7 @@ class DirDefImpl : public DefinitionMixin<DirDef> virtual QCString shortTitle() const; virtual bool hasDetailedDescription() const; virtual void writeDocumentation(OutputList &ol); - virtual void writeTagFile(FTextStream &t); + virtual void writeTagFile(std::ostream &t); virtual void setDiskName(const QCString &name) { m_diskName = name; } virtual void sort(); virtual void setParent(DirDef *parent); @@ -458,12 +457,12 @@ bool DirDefImpl::hasDetailedDescription() const return (!briefDescription().isEmpty() && repeatBrief) || !documentation().isEmpty(); } -void DirDefImpl::writeTagFile(FTextStream &tagFile) +void DirDefImpl::writeTagFile(std::ostream &tagFile) { - tagFile << " <compound kind=\"dir\">" << endl; - tagFile << " <name>" << convertToXML(displayName()) << "</name>" << endl; - tagFile << " <path>" << convertToXML(name()) << "</path>" << endl; - tagFile << " <filename>" << convertToXML(getOutputFileBase()) << Doxygen::htmlFileExtension << "</filename>" << endl; + tagFile << " <compound kind=\"dir\">\n"; + tagFile << " <name>" << convertToXML(displayName()) << "</name>\n"; + tagFile << " <path>" << convertToXML(name()) << "</path>\n"; + tagFile << " <filename>" << convertToXML(getOutputFileBase()) << Doxygen::htmlFileExtension << "</filename>\n"; for (const auto &lde : LayoutDocManager::instance().docEntries(LayoutDocManager::Directory)) { switch (lde->kind()) @@ -474,7 +473,7 @@ void DirDefImpl::writeTagFile(FTextStream &tagFile) { for(const auto dd : m_subdirs) { - tagFile << " <dir>" << convertToXML(dd->displayName()) << "</dir>" << endl; + tagFile << " <dir>" << convertToXML(dd->displayName()) << "</dir>\n"; } } } @@ -483,7 +482,7 @@ void DirDefImpl::writeTagFile(FTextStream &tagFile) { for (const auto &fd : m_fileList) { - tagFile << " <file>" << convertToXML(fd->name()) << "</file>" << endl; + tagFile << " <file>" << convertToXML(fd->name()) << "</file>\n"; } } break; @@ -492,7 +491,7 @@ void DirDefImpl::writeTagFile(FTextStream &tagFile) } } writeDocAnchorsToTagFile(tagFile); - tagFile << " </compound>" << endl; + tagFile << " </compound>\n"; } void DirDefImpl::writeDocumentation(OutputList &ol) diff --git a/src/dirdef.h b/src/dirdef.h index 5bc49e7..5414ddf 100644 --- a/src/dirdef.h +++ b/src/dirdef.h @@ -27,7 +27,6 @@ class FileList; class FileDef; class OutputList; class UsedDir; -class FTextStream; class FilePair; class FilePairDict; class DirDef; @@ -112,7 +111,7 @@ class DirDef : public DefinitionMutable, public Definition // generate output virtual void writeDocumentation(OutputList &ol) = 0; - virtual void writeTagFile(FTextStream &t) = 0; + virtual void writeTagFile(std::ostream &t) = 0; virtual void setDiskName(const QCString &name) = 0; virtual void sort() = 0; diff --git a/src/docbookgen.cpp b/src/docbookgen.cpp index 1f10029..6214249 100644 --- a/src/docbookgen.cpp +++ b/src/docbookgen.cpp @@ -17,7 +17,6 @@ #include <stdlib.h> -#include <qfile.h> #include "docbookgen.h" #include "doxygen.h" #include "message.h" @@ -72,12 +71,12 @@ #endif //------------------ -inline void writeDocbookString(FTextStream &t,const char *s) +inline void writeDocbookString(std::ostream &t,const char *s) { t << convertToDocBook(s); } -inline void writeDocbookCodeString(FTextStream &t,const char *s, int &col) +inline void writeDocbookCodeString(std::ostream &t,const char *s, int &col) { char c; while ((c=*s++)) @@ -117,7 +116,7 @@ inline void writeDocbookCodeString(FTextStream &t,const char *s, int &col) } } -static void addIndexTerm(FTextStream &t, QCString prim, QCString sec = "") +static void addIndexTerm(std::ostream &t, QCString prim, QCString sec = "") { t << "<indexterm><primary>"; t << convertToDocBook(prim); @@ -128,9 +127,9 @@ static void addIndexTerm(FTextStream &t, QCString prim, QCString sec = "") t << convertToDocBook(sec); t << "</secondary>"; } - t << "</indexterm>" << endl; + t << "</indexterm>\n"; } -void writeDocbookLink(FTextStream &t,const char * /*extRef*/,const char *compoundId, +void writeDocbookLink(std::ostream &t,const char * /*extRef*/,const char *compoundId, const char *anchorId,const char * text,const char * /*tooltip*/) { t << "<link linkend=\"_" << stripPath(compoundId); @@ -141,13 +140,13 @@ void writeDocbookLink(FTextStream &t,const char * /*extRef*/,const char *compoun t << "</link>"; } -DocbookCodeGenerator::DocbookCodeGenerator(FTextStream &t) +DocbookCodeGenerator::DocbookCodeGenerator(std::ostream &t) : m_t(nullptr) { m_prettyCode=Config_getBool(DOCBOOK_PROGRAMLISTING); setTextStream(t); } -DocbookCodeGenerator::DocbookCodeGenerator() +DocbookCodeGenerator::DocbookCodeGenerator() : m_t(nullptr) { } @@ -191,7 +190,7 @@ void DocbookCodeGenerator::startCodeLine(bool) } void DocbookCodeGenerator::endCodeLine() { - if (m_insideCodeLine) m_t << endl; + if (m_insideCodeLine) m_t << "\n"; Docbook_DB(("(endCodeLine)\n")); m_lineNumber = -1; m_refId.resize(0); @@ -329,24 +328,24 @@ DB_GEN_C m_codeGen.setRelativePath(relPath); m_codeGen.setSourceFileName(stripPath(fileName)); - t << "<?xml version='1.0' encoding='UTF-8' standalone='no'?>" << endl;; + t << "<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n";; t << "<" << fileType << " xmlns=\"http://docbook.org/ns/docbook\" version=\"5.0\" xmlns:xlink=\"http://www.w3.org/1999/xlink\""; if (!pageName.isEmpty()) t << " xml:id=\"_" << stripPath(pageName) << "\""; t << " xml:lang=\"" << theTranslator->trISOLang() << "\""; - t << ">" << endl; + t << ">\n"; } void DocbookGenerator::endFile() { DB_GEN_C - if (m_inDetail) t << "</section>" << endl; + if (m_inDetail) t << "</section>\n"; m_inDetail = FALSE; while (m_inLevel != -1) { - t << "</section>" << endl; + t << "</section>\n"; m_inLevel--; } - if (m_inGroup) t << "</section>" << endl; + if (m_inGroup) t << "</section>\n"; m_inGroup = FALSE; QCString fileType="section"; @@ -359,7 +358,7 @@ DB_GEN_C { fileType="chapter"; } - t << "</" << fileType << ">" << endl; + t << "</" << fileType << ">\n"; endPlainFile(); m_codeGen.setSourceFileName(""); } @@ -372,15 +371,15 @@ DB_GEN_C2("IndexSections " << is) case isTitlePageStart: { QCString dbk_projectName = Config_getString(PROJECT_NAME); - t << " <info>" << endl; - t << " <title>" << convertToDocBook(dbk_projectName) << "</title>" << endl; - t << " </info>" << endl; + t << " <info>\n"; + t << " <title>" << convertToDocBook(dbk_projectName) << "</title>\n"; + t << " </info>\n"; } break; case isTitlePageAuthor: break; case isMainPage: - t << "<chapter>" << endl; + t << "<chapter>\n"; t << " <title>"; break; case isModuleIndex: @@ -448,44 +447,44 @@ DB_GEN_C2("IndexSections " << is) case isTitlePageAuthor: break; case isMainPage: - t << "</title>" << endl; - t << " <xi:include href=\"mainpage.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl; - t << "</chapter>" << endl; + t << "</title>\n"; + t << " <xi:include href=\"mainpage.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n"; + t << "</chapter>\n"; break; case isModuleIndex: - //t << "</chapter>" << endl; + //t << "</chapter>\n"; break; case isDirIndex: //t << "<xi:include href=\"dirs.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>"; - //t << "</chapter>" << endl; + //t << "</chapter>\n"; break; case isNamespaceIndex: //t << "<xi:include href=\"namespaces.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>"; - //t << "</chapter>" << endl; + //t << "</chapter>\n"; break; case isClassHierarchyIndex: //t << "<xi:include href=\"hierarchy.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>"; - //t << "</chapter>" << endl; + //t << "</chapter>\n"; break; case isCompoundIndex: - //t << "</chapter>" << endl; + //t << "</chapter>\n"; break; case isFileIndex: //t << "<xi:include href=\"files.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>"; - //t << "</chapter>" << endl; + //t << "</chapter>\n"; break; case isPageIndex: //t << "<xi:include href=\"pages.xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>"; - //t << "</chapter>" << endl; + //t << "</chapter>\n"; break; case isModuleDocumentation: { - t << "</title>" << endl; + t << "</title>\n"; for (const auto &gd : *Doxygen::groupLinkedMap) { if (!gd->isReference()) { - t << " <xi:include href=\"" << gd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl; + t << " <xi:include href=\"" << gd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n"; } } } @@ -493,12 +492,12 @@ DB_GEN_C2("IndexSections " << is) break; case isDirDocumentation: { - t << "</title>" << endl; + t << "</title>\n"; for (const auto &dd : *Doxygen::dirLinkedMap) { if (dd->isLinkableInProject()) { - t << "< xi:include href=\"" << dd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl; + t << "< xi:include href=\"" << dd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n"; } } } @@ -506,12 +505,12 @@ DB_GEN_C2("IndexSections " << is) break; case isNamespaceDocumentation: { - t << "</title>" << endl; + t << "</title>\n"; for (const auto &nd : *Doxygen::namespaceLinkedMap) { if (nd->isLinkableInProject() && !nd->isAlias()) { - t << "<xi:include href=\"" << nd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl; + t << "<xi:include href=\"" << nd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n"; } } } @@ -519,7 +518,7 @@ DB_GEN_C2("IndexSections " << is) break; case isClassDocumentation: { - t << "</title>" << endl; + t << "</title>\n"; for (const auto &cd : *Doxygen::classLinkedMap) { if (cd->isLinkableInProject() && @@ -528,7 +527,7 @@ DB_GEN_C2("IndexSections " << is) !cd->isAlias() ) { - t << " <xi:include href=\"" << cd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl; + t << " <xi:include href=\"" << cd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n"; } } } @@ -536,7 +535,7 @@ DB_GEN_C2("IndexSections " << is) break; case isFileDocumentation: { - t << "</title>" << endl; + t << "</title>\n"; bool isFirst=TRUE; for (const auto &fn : *Doxygen::inputNameLinkedMap) { @@ -546,19 +545,19 @@ DB_GEN_C2("IndexSections " << is) { if (isFirst) { - t << " <xi:include href=\"" << fd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl; + t << " <xi:include href=\"" << fd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n"; if (sourceBrowser && m_prettyCode && fd->generateSourceFile()) { - t << " <xi:include href=\"" << fd->getSourceFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl; + t << " <xi:include href=\"" << fd->getSourceFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n"; } isFirst=FALSE; } else { - t << " <xi:include href=\"" << fd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl; + t << " <xi:include href=\"" << fd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n"; if (sourceBrowser && m_prettyCode && fd->generateSourceFile()) { - t << " <xi:include href=\"" << fd->getSourceFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl; + t << " <xi:include href=\"" << fd->getSourceFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n"; } } } @@ -569,10 +568,10 @@ DB_GEN_C2("IndexSections " << is) break; case isExampleDocumentation: { - t << "</title>" << endl; + t << "</title>\n"; for (const auto &pd : *Doxygen::exampleLinkedMap) { - t << " <xi:include href=\"" << pd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl; + t << " <xi:include href=\"" << pd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n"; } } t << "</chapter>\n"; @@ -582,7 +581,7 @@ DB_GEN_C2("IndexSections " << is) case isPageDocumentation2: break; case isEndIndex: - t << "<index/>" << endl; + t << "<index/>\n"; break; } } @@ -596,13 +595,13 @@ DB_GEN_C t << "<chapter>\n"; if (pd->hasTitle()) { - t << " <title>" << convertToDocBook(pd->title()) << "</title>" << endl; + t << " <title>" << convertToDocBook(pd->title()) << "</title>\n"; } else { - t << " <title>" << convertToDocBook(pd->name()) << "</title>" << endl; + t << " <title>" << convertToDocBook(pd->name()) << "</title>\n"; } - t << " <xi:include href=\"" << pd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl; + t << " <xi:include href=\"" << pd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>\n"; t << "</chapter>\n"; } } @@ -620,13 +619,13 @@ DB_GEN_C void DocbookGenerator::startParagraph(const char *) { DB_GEN_C - t << "<para>" << endl; + t << "<para>\n"; } void DocbookGenerator::endParagraph() { DB_GEN_C - t << "</para>" << endl; + t << "</para>\n"; } void DocbookGenerator::writeString(const char *text) { @@ -636,7 +635,7 @@ DB_GEN_C void DocbookGenerator::startMemberHeader(const char *,int) { DB_GEN_C - t << "<simplesect>" << endl; + t << "<simplesect>\n"; m_inSimpleSect[m_levelListItem] = TRUE; t << " <title>"; } @@ -644,7 +643,7 @@ DB_GEN_C void DocbookGenerator::endMemberHeader() { DB_GEN_C - t << " </title>" << endl; + t << " </title>\n"; } void DocbookGenerator::docify(const char *str) { @@ -666,30 +665,30 @@ DB_GEN_C void DocbookGenerator::startMemberList() { DB_GEN_C - t << " <itemizedlist>" << endl; + t << " <itemizedlist>\n"; m_levelListItem++; } void DocbookGenerator::endMemberList() { DB_GEN_C - if (m_inListItem[m_levelListItem]) t << "</listitem>" << endl; + if (m_inListItem[m_levelListItem]) t << "</listitem>\n"; m_inListItem[m_levelListItem] = FALSE; - t << " </itemizedlist>" << endl; + t << " </itemizedlist>\n"; m_levelListItem = (m_levelListItem> 0 ? m_levelListItem - 1 : 0); - if (m_inSimpleSect[m_levelListItem]) t << "</simplesect>" << endl; + if (m_inSimpleSect[m_levelListItem]) t << "</simplesect>\n"; m_inSimpleSect[m_levelListItem] = FALSE; } void DocbookGenerator::startMemberItem(const char *,int,const char *) { DB_GEN_C - if (m_inListItem[m_levelListItem]) t << "</listitem>" << endl; + if (m_inListItem[m_levelListItem]) t << "</listitem>\n"; t << " <listitem><para>"; m_inListItem[m_levelListItem] = TRUE; } void DocbookGenerator::endMemberItem() { DB_GEN_C - t << "</para>" << endl; + t << "</para>\n"; } void DocbookGenerator::startBold() { @@ -706,26 +705,26 @@ void DocbookGenerator::startGroupHeader(int extraIndentLevel) DB_GEN_C2("m_inLevel " << m_inLevel) DB_GEN_C2("extraIndentLevel " << extraIndentLevel) m_firstMember = TRUE; - if (m_inSimpleSect[m_levelListItem]) t << "</simplesect>" << endl; + if (m_inSimpleSect[m_levelListItem]) t << "</simplesect>\n"; m_inSimpleSect[m_levelListItem] = FALSE; if (m_inLevel != -1) m_inGroup = TRUE; - if (m_inLevel == extraIndentLevel) t << "</section>" << endl; + if (m_inLevel == extraIndentLevel) t << "</section>\n"; m_inLevel = extraIndentLevel; - t << "<section>" << endl; + t << "<section>\n"; t << "<title>"; } void DocbookGenerator::writeRuler() { DB_GEN_C2("m_inLevel " << m_inLevel) DB_GEN_C2("m_inGroup " << m_inGroup) - if (m_inGroup) t << "</section>" << endl; + if (m_inGroup) t << "</section>\n"; m_inGroup = FALSE; } void DocbookGenerator::endGroupHeader(int) { DB_GEN_C - t << "</title>" << endl; + t << "</title>\n"; } void DocbookGenerator::startParameterList(bool openBracket) @@ -745,7 +744,7 @@ DB_GEN_C void DocbookGenerator::lineBreak(const char *) { DB_GEN_C - t << endl; + t << "\n"; } void DocbookGenerator::startTypewriter() { @@ -755,7 +754,7 @@ DB_GEN_C void DocbookGenerator::endTypewriter() { DB_GEN_C - if (!m_denseText) t << "</computeroutput>" << endl; + if (!m_denseText) t << "</computeroutput>\n"; } void DocbookGenerator::startTextBlock(bool dense) { @@ -779,13 +778,13 @@ void DocbookGenerator::startMemberDoc(const char *clname, const char *memname, c int memCount, int memTotal, bool) { DB_GEN_C2("m_inLevel " << m_inLevel) - t << " <section>" << endl; + t << " <section>\n"; t << " <title>" << convertToDocBook(title); if (memTotal>1) { t << "<computeroutput>[" << memCount << "/" << memTotal << "]</computeroutput>"; } - t << "</title>" << endl; + t << "</title>\n"; if (memname && memname[0]!='@') { addIndexTerm(t,memname,clname); @@ -805,7 +804,7 @@ DB_GEN_C void DocbookGenerator::endTitleHead(const char *,const char *name) { DB_GEN_C - t << "</title>" << endl; + t << "</title>\n"; if (name) addIndexTerm(t, name); } void DocbookGenerator::startDoxyAnchor(const char *fName,const char *, @@ -844,7 +843,7 @@ DB_GEN_C void DocbookGenerator::endMemberGroupHeader() { DB_GEN_C - t << "</title>" << endl; + t << "</title>\n"; } void DocbookGenerator::startMemberGroup() { @@ -853,7 +852,7 @@ DB_GEN_C void DocbookGenerator::endMemberGroup(bool) { DB_GEN_C - t << "</simplesect>" << endl; + t << "</simplesect>\n"; } void DocbookGenerator::startClassDiagram() { @@ -864,16 +863,16 @@ DB_GEN_C void DocbookGenerator::endClassDiagram(const ClassDiagram &d, const char *fileName,const char *) { DB_GEN_C - t << " <informalfigure>" << endl; - t << " <mediaobject>" << endl; - t << " <imageobject>" << endl; + t << " <informalfigure>\n"; + t << " <mediaobject>\n"; + t << " <imageobject>\n"; t << " <imagedata width=\"50%\" align=\"center\" valign=\"middle\" scalefit=\"0\" fileref=\"" - << relPath << fileName << ".png\">" << "</imagedata>" << endl; - t << " </imageobject>" << endl; + << relPath << fileName << ".png\">" << "</imagedata>\n"; + t << " </imageobject>\n"; d.writeImage(t,dir(),relPath,fileName,FALSE); - t << " </mediaobject>" << endl; - t << " </informalfigure>" << endl; - t << "</para>" << endl; + t << " </mediaobject>\n"; + t << " </informalfigure>\n"; + t << "</para>\n"; } void DocbookGenerator::startLabels() { @@ -902,7 +901,7 @@ DB_GEN_C void DocbookGenerator::endExamples() { DB_GEN_C - t << "</simplesect>" << endl; + t << "</simplesect>\n"; } void DocbookGenerator::startSubsubsection() { @@ -912,7 +911,7 @@ DB_GEN_C void DocbookGenerator::endSubsubsection() { DB_GEN_C - t << "</title></simplesect>" << endl; + t << "</title></simplesect>\n"; } void DocbookGenerator::writeChar(char c) { @@ -987,9 +986,9 @@ void DocbookGenerator::startDescTable(const char *title) { DB_GEN_C int ncols = 2; - t << "<informaltable frame=\"all\">" << endl; - if (title)t << "<title>" << convertToDocBook(title) << "</title>" << endl; - t << " <tgroup cols=\"" << ncols << "\" align=\"left\" colsep=\"1\" rowsep=\"1\">" << endl; + t << "<informaltable frame=\"all\">\n"; + if (title)t << "<title>" << convertToDocBook(title) << "</title>\n"; + t << " <tgroup cols=\"" << ncols << "\" align=\"left\" colsep=\"1\" rowsep=\"1\">\n"; for (int i = 0; i < ncols; i++) { t << " <colspec colname='c" << i+1 << "'/>\n"; @@ -1001,9 +1000,9 @@ DB_GEN_C void DocbookGenerator::endDescTable() { DB_GEN_C - t << " </tbody>" << endl; - t << " </tgroup>" << endl; - t << "</informaltable>" << endl; + t << " </tbody>\n"; + t << " </tgroup>\n"; + t << "</informaltable>\n"; m_descTable = FALSE; } @@ -1100,7 +1099,7 @@ void DocbookGenerator::startConstraintList(const char *header) DB_GEN_C t << "<simplesect><title>"; docify(header); - t << "</title>" << endl; + t << "</title>\n"; } void DocbookGenerator::startConstraintParam() { @@ -1119,7 +1118,7 @@ DB_GEN_C void DocbookGenerator::endConstraintType() { DB_GEN_C - t << "</emphasis></para>" << endl; + t << "</emphasis></para>\n"; } void DocbookGenerator::startConstraintDocs() { @@ -1132,5 +1131,5 @@ DB_GEN_C void DocbookGenerator::endConstraintList() { DB_GEN_C - t << "</simplesect>" << endl; + t << "</simplesect>\n"; } diff --git a/src/docbookgen.h b/src/docbookgen.h index 214ec97..1f8b6ef 100644 --- a/src/docbookgen.h +++ b/src/docbookgen.h @@ -15,19 +15,20 @@ #ifndef DOCBOOKGEN_H #define DOCBOOKGEN_H +#include <iostream> + #include "config.h" #include "outputgen.h" class DocbookCodeGenerator : public CodeOutputInterface { public: - DocbookCodeGenerator(FTextStream &t); + DocbookCodeGenerator(std::ostream &t); DocbookCodeGenerator(); virtual ~DocbookCodeGenerator(); - void setTextStream(FTextStream &t) + void setTextStream(std::ostream &t) { - m_streamSet = t.device()!=0; - m_t.setDevice(t.device()); + m_t.rdbuf(t.rdbuf()); } void setRelativePath(const QCString &path) { m_relPath = path; } void setSourceFileName(const QCString &sourceFileName) { m_sourceFileName = sourceFileName; } @@ -57,8 +58,7 @@ class DocbookCodeGenerator : public CodeOutputInterface void endCodeFragment(const char *style); private: - FTextStream m_t; - bool m_streamSet = false; + std::ostream m_t; QCString m_refId; QCString m_external; int m_lineNumber = -1; diff --git a/src/docbookvisitor.cpp b/src/docbookvisitor.cpp index 2db6fb0..60c1b08 100644 --- a/src/docbookvisitor.cpp +++ b/src/docbookvisitor.cpp @@ -13,6 +13,7 @@ * */ +#include <fstream> #include "docbookvisitor.h" #include "docparser.h" @@ -88,7 +89,7 @@ void DocbookDocVisitor::visitCaption(const DocNodeList &children) for (const auto &n : children) n->accept(this); } -void DocbookDocVisitor::visitPreStart(FTextStream &t, +void DocbookDocVisitor::visitPreStart(std::ostream &t, const DocNodeList &children, bool hasCaption, const QCString &name, @@ -98,17 +99,17 @@ void DocbookDocVisitor::visitPreStart(FTextStream &t, { if (hasCaption && !inlineImage) { - t << " <figure>" << endl; - t << " <title>" << endl; + t << " <figure>\n"; + t << " <title>\n"; visitCaption(children); - t << " </title>" << endl; + t << " </title>\n"; } else { - t << " <informalfigure>" << endl; + t << " <informalfigure>\n"; } - t << " <mediaobject>" << endl; - t << " <imageobject>" << endl; + t << " <mediaobject>\n"; + t << " <imageobject>\n"; t << " <imagedata"; if (!width.isEmpty()) { @@ -123,42 +124,42 @@ void DocbookDocVisitor::visitPreStart(FTextStream &t, t << " depth=\"" << convertToDocBook(height) << "\""; } t << " align=\"center\" valign=\"middle\" scalefit=\"0\" fileref=\"" << name << "\">"; - t << "</imagedata>" << endl; - t << " </imageobject>" << endl; + t << "</imagedata>\n"; + t << " </imageobject>\n"; if (hasCaption && !inlineImage) { - t << " <!--" << endl; // Needed for general formatting with title for other formats + t << " <!--\n"; // Needed for general formatting with title for other formats } } -void DocbookDocVisitor::visitPostEnd(FTextStream &t, bool hasCaption, bool inlineImage) +void DocbookDocVisitor::visitPostEnd(std::ostream &t, bool hasCaption, bool inlineImage) { - t << endl; + t << "\n"; if (hasCaption && !inlineImage) { - t << " -->" << endl; // Needed for general formatting with title for other formats + t << " -->\n"; // Needed for general formatting with title for other formats } - t << " </mediaobject>" << endl; + t << " </mediaobject>\n"; if (hasCaption && !inlineImage) { - t << " </figure>" << endl; + t << " </figure>\n"; } else { - t << " </informalfigure>" << endl; + t << " </informalfigure>\n"; } } -DocbookDocVisitor::DocbookDocVisitor(FTextStream &t,CodeOutputInterface &ci,const char *langExt) +DocbookDocVisitor::DocbookDocVisitor(std::ostream &t,CodeOutputInterface &ci,const char *langExt) : DocVisitor(DocVisitor_Docbook), m_t(t), m_ci(ci),m_langExt(langExt) { DB_VIS_C - // m_t << "<section>" << endl; + // m_t << "<section>\n"; } DocbookDocVisitor::~DocbookDocVisitor() { DB_VIS_C - // m_t << "</section>" << endl; + // m_t << "</section>\n"; } //-------------------------------------- @@ -241,9 +242,9 @@ void DocbookDocVisitor::visit(DocLineBreak *) { DB_VIS_C if (m_hide) return; - m_t << endl << "<literallayout> 
</literallayout>" << endl; + m_t << "\n<literallayout> 
</literallayout>\n"; // gives nicer results but gives problems as it is not allowed in <pare> and also problems with dblatex - // m_t << endl << "<sbr/>" << endl; + // m_t << "\n" << "<sbr/>\n"; } void DocbookDocVisitor::visit(DocHorRuler *) @@ -344,22 +345,23 @@ DB_VIS_C QCString baseName(4096); QCString name; QCString stext = s->text(); - m_t << "<para>" << endl; + m_t << "<para>\n"; name.sprintf("%s%d", "dot_inline_dotgraph_", dotindex); baseName.sprintf("%s%d", (Config_getString(DOCBOOK_OUTPUT)+"/inline_dotgraph_").data(), dotindex++ ); - QFile file(baseName+".dot"); - if (!file.open(IO_WriteOnly)) + std::string fileName = baseName.str()+".dot"; + std::ofstream file(fileName,std::ofstream::out | std::ofstream::binary); + if (!file.is_open()) { - err("Could not open file %s.dot for writing\n",baseName.data()); + err("Could not open file %s for writing\n",fileName.c_str()); } - file.writeBlock( stext, stext.length() ); + file.write( stext.data(), stext.length() ); file.close(); writeDotFile(baseName, s); - m_t << "</para>" << endl; - if (Config_getBool(DOT_CLEANUP)) file.remove(); + m_t << "</para>\n"; + if (Config_getBool(DOT_CLEANUP)) Dir().remove(fileName); } break; case DocVerbatim::Msc: @@ -368,25 +370,26 @@ DB_VIS_C QCString baseName(4096); QCString name; QCString stext = s->text(); - m_t << "<para>" << endl; + m_t << "<para>\n"; name.sprintf("%s%d", "msc_inline_mscgraph_", mscindex); baseName.sprintf("%s%d", (Config_getString(DOCBOOK_OUTPUT)+"/inline_mscgraph_").data(), mscindex++ ); - QFile file(baseName+".msc"); - if (!file.open(IO_WriteOnly)) + std::string fileName = baseName.str()+".msc"; + std::ofstream file(fileName,std::ofstream::out | std::ofstream::binary); + if (!file.is_open()) { - err("Could not open file %s.msc for writing\n",baseName.data()); + err("Could not open file %s for writing\n",fileName.c_str()); } QCString text = "msc {"; text+=stext; text+="}"; - file.writeBlock( text, text.length() ); + file.write( text.data(), text.length() ); file.close(); writeMscFile(baseName,s); - m_t << "</para>" << endl; - if (Config_getBool(DOT_CLEANUP)) file.remove(); + m_t << "</para>\n"; + if (Config_getBool(DOT_CLEANUP)) Dir().remove(fileName); } break; case DocVerbatim::PlantUML: @@ -399,9 +402,9 @@ DB_VIS_C { shortName=shortName.right((int)shortName.length()-i-1); } - m_t << "<para>" << endl; + m_t << "<para>\n"; writePlantUMLFile(baseName,s); - m_t << "</para>" << endl; + m_t << "</para>\n"; } break; } @@ -550,7 +553,7 @@ DB_VIS_C } else { - if (!m_hide) m_t << endl; + if (!m_hide) m_t << "\n"; } } @@ -559,14 +562,14 @@ void DocbookDocVisitor::visit(DocFormula *f) DB_VIS_C if (m_hide) return; - if (f->isInline()) m_t << "<inlinemediaobject>" << endl; - else m_t << " <mediaobject>" << endl; - m_t << " <imageobject>" << endl; + if (f->isInline()) m_t << "<inlinemediaobject>\n"; + else m_t << " <mediaobject>\n"; + m_t << " <imageobject>\n"; m_t << " <imagedata "; - m_t << "align=\"center\" valign=\"middle\" scalefit=\"0\" fileref=\"" << f->relPath() << f->name() << ".png\"/>" << endl; - m_t << " </imageobject>" << endl; - if (f->isInline()) m_t << "</inlinemediaobject>" << endl; - else m_t << " </mediaobject>" << endl; + m_t << "align=\"center\" valign=\"middle\" scalefit=\"0\" fileref=\"" << f->relPath() << f->name() << ".png\"/>\n"; + m_t << " </imageobject>\n"; + if (f->isInline()) m_t << "</inlinemediaobject>\n"; + else m_t << " </mediaobject>\n"; } void DocbookDocVisitor::visit(DocIndexEntry *ie) @@ -575,7 +578,7 @@ DB_VIS_C if (m_hide) return; m_t << "<indexterm><primary>"; filter(ie->entry()); - m_t << "</primary></indexterm>" << endl; + m_t << "</primary></indexterm>\n"; } void DocbookDocVisitor::visit(DocSimpleSectSep *) @@ -643,7 +646,7 @@ void DocbookDocVisitor::visitPre(DocPara *) { DB_VIS_C if (m_hide) return; - m_t << endl; + m_t << "\n"; m_t << "<para>"; } @@ -652,7 +655,7 @@ void DocbookDocVisitor::visitPost(DocPara *) DB_VIS_C if (m_hide) return; m_t << "</para>"; - m_t << endl; + m_t << "\n"; } void DocbookDocVisitor::visitPre(DocRoot *) @@ -676,161 +679,161 @@ DB_VIS_C case DocSimpleSect::See: if (m_insidePre) { - m_t << "<formalpara><title>" << theTranslator->trSeeAlso() << "</title>" << endl; + m_t << "<formalpara><title>" << theTranslator->trSeeAlso() << "</title>\n"; } else { - m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trSeeAlso()) << "</title>" << endl; + m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trSeeAlso()) << "</title>\n"; } break; case DocSimpleSect::Return: if (m_insidePre) { - m_t << "<formalpara><title>" << theTranslator->trReturns()<< "</title>" << endl; + m_t << "<formalpara><title>" << theTranslator->trReturns()<< "</title>\n"; } else { - m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trReturns()) << "</title>" << endl; + m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trReturns()) << "</title>\n"; } break; case DocSimpleSect::Author: if (m_insidePre) { - m_t << "<formalpara><title>" << theTranslator->trAuthor(TRUE, TRUE) << "</title>" << endl; + m_t << "<formalpara><title>" << theTranslator->trAuthor(TRUE, TRUE) << "</title>\n"; } else { - m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trAuthor(TRUE, TRUE)) << "</title>" << endl; + m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trAuthor(TRUE, TRUE)) << "</title>\n"; } break; case DocSimpleSect::Authors: if (m_insidePre) { - m_t << "<formalpara><title>" << theTranslator->trAuthor(TRUE, FALSE) << "</title>" << endl; + m_t << "<formalpara><title>" << theTranslator->trAuthor(TRUE, FALSE) << "</title>\n"; } else { - m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trAuthor(TRUE, FALSE)) << "</title>" << endl; + m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trAuthor(TRUE, FALSE)) << "</title>\n"; } break; case DocSimpleSect::Version: if (m_insidePre) { - m_t << "<formalpara><title>" << theTranslator->trVersion() << "</title>" << endl; + m_t << "<formalpara><title>" << theTranslator->trVersion() << "</title>\n"; } else { - m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trVersion()) << "</title>" << endl; + m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trVersion()) << "</title>\n"; } break; case DocSimpleSect::Since: if (m_insidePre) { - m_t << "<formalpara><title>" << theTranslator->trSince() << "</title>" << endl; + m_t << "<formalpara><title>" << theTranslator->trSince() << "</title>\n"; } else { - m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trSince()) << "</title>" << endl; + m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trSince()) << "</title>\n"; } break; case DocSimpleSect::Date: if (m_insidePre) { - m_t << "<formalpara><title>" << theTranslator->trDate() << "</title>" << endl; + m_t << "<formalpara><title>" << theTranslator->trDate() << "</title>\n"; } else { - m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trDate()) << "</title>" << endl; + m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trDate()) << "</title>\n"; } break; case DocSimpleSect::Note: if (m_insidePre) { - m_t << "<note><title>" << theTranslator->trNote() << "</title>" << endl; + m_t << "<note><title>" << theTranslator->trNote() << "</title>\n"; } else { - m_t << "<note><title>" << convertToDocBook(theTranslator->trNote()) << "</title>" << endl; + m_t << "<note><title>" << convertToDocBook(theTranslator->trNote()) << "</title>\n"; } break; case DocSimpleSect::Warning: if (m_insidePre) { - m_t << "<warning><title>" << theTranslator->trWarning() << "</title>" << endl; + m_t << "<warning><title>" << theTranslator->trWarning() << "</title>\n"; } else { - m_t << "<warning><title>" << convertToDocBook(theTranslator->trWarning()) << "</title>" << endl; + m_t << "<warning><title>" << convertToDocBook(theTranslator->trWarning()) << "</title>\n"; } break; case DocSimpleSect::Pre: if (m_insidePre) { - m_t << "<formalpara><title>" << theTranslator->trPrecondition() << "</title>" << endl; + m_t << "<formalpara><title>" << theTranslator->trPrecondition() << "</title>\n"; } else { - m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trPrecondition()) << "</title>" << endl; + m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trPrecondition()) << "</title>\n"; } break; case DocSimpleSect::Post: if (m_insidePre) { - m_t << "<formalpara><title>" << theTranslator->trPostcondition() << "</title>" << endl; + m_t << "<formalpara><title>" << theTranslator->trPostcondition() << "</title>\n"; } else { - m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trPostcondition()) << "</title>" << endl; + m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trPostcondition()) << "</title>\n"; } break; case DocSimpleSect::Copyright: if (m_insidePre) { - m_t << "<formalpara><title>" << theTranslator->trCopyright() << "</title>" << endl; + m_t << "<formalpara><title>" << theTranslator->trCopyright() << "</title>\n"; } else { - m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trCopyright()) << "</title>" << endl; + m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trCopyright()) << "</title>\n"; } break; case DocSimpleSect::Invar: if (m_insidePre) { - m_t << "<formalpara><title>" << theTranslator->trInvariant() << "</title>" << endl; + m_t << "<formalpara><title>" << theTranslator->trInvariant() << "</title>\n"; } else { - m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trInvariant()) << "</title>" << endl; + m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trInvariant()) << "</title>\n"; } break; case DocSimpleSect::Remark: // <remark> is miising the <title> possibility if (m_insidePre) { - m_t << "<formalpara><title>" << theTranslator->trRemarks() << "</title>" << endl; + m_t << "<formalpara><title>" << theTranslator->trRemarks() << "</title>\n"; } else { - m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trRemarks()) << "</title>" << endl; + m_t << "<formalpara><title>" << convertToDocBook(theTranslator->trRemarks()) << "</title>\n"; } break; case DocSimpleSect::Attention: if (m_insidePre) { - m_t << "<caution><title>" << theTranslator->trAttention() << "</title>" << endl; + m_t << "<caution><title>" << theTranslator->trAttention() << "</title>\n"; } else { - m_t << "<caution><title>" << convertToDocBook(theTranslator->trAttention()) << "</title>" << endl; + m_t << "<caution><title>" << convertToDocBook(theTranslator->trAttention()) << "</title>\n"; } break; case DocSimpleSect::User: case DocSimpleSect::Rcs: case DocSimpleSect::Unknown: if (s->hasTitle()) - m_t << "<formalpara>" << endl; + m_t << "<formalpara>\n"; else - m_t << "<para>" << endl; + m_t << "<para>\n"; break; } } @@ -845,21 +848,21 @@ DB_VIS_C case DocSimpleSect::Rcs: case DocSimpleSect::Unknown: if (s->hasTitle()) - m_t << "</formalpara>" << endl; + m_t << "</formalpara>\n"; else - m_t << "</para>" << endl; + m_t << "</para>\n"; break; case DocSimpleSect::Note: - m_t << "</note>" << endl; + m_t << "</note>\n"; break; case DocSimpleSect::Attention: - m_t << "</caution>" << endl; + m_t << "</caution>\n"; break; case DocSimpleSect::Warning: - m_t << "</warning>" << endl; + m_t << "</warning>\n"; break; default: - m_t << "</formalpara>" << endl; + m_t << "</formalpara>\n"; break; } } @@ -912,10 +915,10 @@ DB_VIS_C if (m_hide) return; m_t << "<section xml:id=\"_" << stripPath(s->file()); if (!s->anchor().isEmpty()) m_t << "_1" << s->anchor(); - m_t << "\">" << endl; + m_t << "\">\n"; m_t << "<title>"; filter(s->title()); - m_t << "</title>" << endl; + m_t << "</title>\n"; } void DocbookDocVisitor::visitPost(DocSection *) @@ -1005,8 +1008,8 @@ void DocbookDocVisitor::visitPre(DocHtmlTable *t) DB_VIS_C m_bodySet.push(false); if (m_hide) return; - m_t << "<informaltable frame=\"all\">" << endl; - m_t << " <tgroup cols=\"" << (unsigned int)t->numColumns() << "\" align=\"left\" colsep=\"1\" rowsep=\"1\">" << endl; + m_t << "<informaltable frame=\"all\">\n"; + m_t << " <tgroup cols=\"" << (unsigned int)t->numColumns() << "\" align=\"left\" colsep=\"1\" rowsep=\"1\">\n"; for (uint i = 0; i <t->numColumns(); i++) { // do something with colwidth based of cell width specification (be aware of possible colspan in the header)? @@ -1018,10 +1021,10 @@ void DocbookDocVisitor::visitPost(DocHtmlTable *) { DB_VIS_C if (m_hide) return; - if (m_bodySet.top()) m_t << " </tbody>" << endl; + if (m_bodySet.top()) m_t << " </tbody>\n"; m_bodySet.pop(); - m_t << " </tgroup>" << endl; - m_t << "</informaltable>" << endl; + m_t << " </tgroup>\n"; + m_t << "</informaltable>\n"; } void DocbookDocVisitor::visitPre(DocHtmlRow *tr) @@ -1189,7 +1192,7 @@ DB_VIS_C if (img->type()==DocImage::DocBook) { if (m_hide) return; - m_t << endl; + m_t << "\n"; QCString baseName=img->name(); int i; if ((i=baseName.findRev('/'))!=-1 || (i=baseName.findRev('\\'))!=-1) @@ -1226,19 +1229,7 @@ DB_VIS_C { m_file=fd->absFilePath(); } - QFile inImage(m_file); - QFile outImage(Config_getString(DOCBOOK_OUTPUT)+"/"+baseName.data()); - if (inImage.open(IO_ReadOnly)) - { - if (outImage.open(IO_WriteOnly)) - { - char *buffer = new char[inImage.size()]; - inImage.readBlock(buffer,inImage.size()); - outImage.writeBlock(buffer,inImage.size()); - outImage.flush(); - delete[] buffer; - } - } + copyFile(m_file,Config_getString(DOCBOOK_OUTPUT)+"/"+baseName.data()); } else { @@ -1336,30 +1327,30 @@ void DocbookDocVisitor::visitPost(DocSecRefItem *) { DB_VIS_C if (m_hide) return; - m_t << "</tocentry>" << endl; + m_t << "</tocentry>\n"; } void DocbookDocVisitor::visitPre(DocSecRefList *) { DB_VIS_C if (m_hide) return; - m_t << "<toc>" << endl; + m_t << "<toc>\n"; } void DocbookDocVisitor::visitPost(DocSecRefList *) { DB_VIS_C if (m_hide) return; - m_t << "</toc>" << endl; + m_t << "</toc>\n"; } void DocbookDocVisitor::visitPre(DocParamSect *s) { DB_VIS_C if (m_hide) return; - m_t << endl; - m_t << " <formalpara>" << endl; - m_t << " <title>" << endl; + m_t << "\n"; + m_t << " <formalpara>\n"; + m_t << " <title>\n"; switch(s->type()) { case DocParamSect::Param: m_t << theTranslator->trParameters(); break; @@ -1369,9 +1360,9 @@ DB_VIS_C default: ASSERT(0); } - m_t << " </title>" << endl; - m_t << " <para>" << endl; - m_t << " <table frame=\"all\">" << endl; + m_t << " </title>\n"; + m_t << " <para>\n"; + m_t << " <table frame=\"all\">\n"; int ncols = 2; if (s->type() == DocParamSect::Param) { @@ -1380,24 +1371,24 @@ DB_VIS_C if (hasInOutSpecs && hasTypeSpecs) ncols += 2; else if (hasInOutSpecs || hasTypeSpecs) ncols += 1; } - m_t << " <tgroup cols=\"" << ncols << "\" align=\"left\" colsep=\"1\" rowsep=\"1\">" << endl; + m_t << " <tgroup cols=\"" << ncols << "\" align=\"left\" colsep=\"1\" rowsep=\"1\">\n"; for (int i = 1; i <= ncols; i++) { - if (i == ncols) m_t << " <colspec colwidth=\"4*\"/>" << endl; - else m_t << " <colspec colwidth=\"1*\"/>" << endl; + if (i == ncols) m_t << " <colspec colwidth=\"4*\"/>\n"; + else m_t << " <colspec colwidth=\"1*\"/>\n"; } - m_t << " <tbody>" << endl; + m_t << " <tbody>\n"; } void DocbookDocVisitor::visitPost(DocParamSect *) { DB_VIS_C if (m_hide) return; - m_t << " </tbody>" << endl; - m_t << " </tgroup>" << endl; - m_t << " </table>" << endl; - m_t << " </para>" << endl; - m_t << " </formalpara>" << endl; + m_t << " </tbody>\n"; + m_t << " </tgroup>\n"; + m_t << " </table>\n"; + m_t << " </para>\n"; + m_t << " </formalpara>\n"; m_t << " "; } @@ -1405,7 +1396,7 @@ void DocbookDocVisitor::visitPre(DocParamList *pl) { DB_VIS_C if (m_hide) return; - m_t << " <row>" << endl; + m_t << " <row>\n"; DocParamSect *sect = 0; if (pl->parent() && pl->parent()->kind()==DocNode::Kind_ParamSect) @@ -1458,7 +1449,7 @@ DB_VIS_C if (pl->parameters().empty()) { - m_t << " <entry></entry>" << endl; + m_t << " <entry></entry>\n"; } else { @@ -1480,7 +1471,7 @@ DB_VIS_C } cnt++; } - m_t << "</entry>" << endl; + m_t << "</entry>\n"; } m_t << " <entry>"; } @@ -1489,8 +1480,8 @@ void DocbookDocVisitor::visitPost(DocParamList *) { DB_VIS_C if (m_hide) return; - m_t << "</entry>" << endl; - m_t << " </row>" << endl; + m_t << "</entry>\n"; + m_t << " </row>\n"; } void DocbookDocVisitor::visitPre(DocXRefItem *x) @@ -1658,7 +1649,7 @@ DB_VIS_C baseName.prepend("msc_"); QCString outDir = Config_getString(DOCBOOK_OUTPUT); writeMscGraphFromFile(fileName,outDir,baseName,MSC_BITMAP); - m_t << "<para>" << endl; + m_t << "<para>\n"; visitPreStart(m_t, children, hasCaption, baseName + ".png", width, height); } @@ -1667,7 +1658,7 @@ void DocbookDocVisitor::endMscFile(bool hasCaption) DB_VIS_C if (m_hide) return; visitPostEnd(m_t, hasCaption); - m_t << "</para>" << endl; + m_t << "</para>\n"; } void DocbookDocVisitor::writeDiaFile(const QCString &baseName, DocVerbatim *s) @@ -1707,7 +1698,7 @@ DB_VIS_C baseName.prepend("dia_"); QCString outDir = Config_getString(DOCBOOK_OUTPUT); writeDiaGraphFromFile(fileName,outDir,baseName,DIA_BITMAP); - m_t << "<para>" << endl; + m_t << "<para>\n"; visitPreStart(m_t, children, hasCaption, baseName + ".png", width, height); } @@ -1716,7 +1707,7 @@ void DocbookDocVisitor::endDiaFile(bool hasCaption) DB_VIS_C if (m_hide) return; visitPostEnd(m_t, hasCaption); - m_t << "</para>" << endl; + m_t << "</para>\n"; } void DocbookDocVisitor::writeDotFile(const QCString &baseName, DocVerbatim *s) @@ -1757,7 +1748,7 @@ DB_VIS_C QCString outDir = Config_getString(DOCBOOK_OUTPUT); QCString imgExt = getDotImageExtension(); writeDotGraphFromFile(fileName,outDir,baseName,GOF_BITMAP); - m_t << "<para>" << endl; + m_t << "<para>\n"; visitPreStart(m_t, children, hasCaption, baseName + "." + imgExt, width, height); } @@ -1765,8 +1756,8 @@ void DocbookDocVisitor::endDotFile(bool hasCaption) { DB_VIS_C if (m_hide) return; - m_t << endl; + m_t << "\n"; visitPostEnd(m_t, hasCaption); - m_t << "</para>" << endl; + m_t << "</para>\n"; } diff --git a/src/docbookvisitor.h b/src/docbookvisitor.h index ad53116..f1be60a 100644 --- a/src/docbookvisitor.h +++ b/src/docbookvisitor.h @@ -18,10 +18,11 @@ #include "containers.h" #include "docvisitor.h" +#include "docparser.h" + #include <qcstring.h> -#include <docparser.h> +#include <iostream> -class FTextStream; class CodeOutputInterface; class QCString; @@ -29,7 +30,7 @@ class QCString; class DocbookDocVisitor : public DocVisitor { public: - DocbookDocVisitor(FTextStream &t,CodeOutputInterface &ci,const char *langExt); + DocbookDocVisitor(std::ostream &t,CodeOutputInterface &ci,const char *langExt); ~DocbookDocVisitor(); //-------------------------------------- // visitor functions for leaf nodes @@ -154,19 +155,19 @@ class DocbookDocVisitor : public DocVisitor void endDotFile(bool hasCaption); void writeDotFile(const QCString &fileName, DocVerbatim *s); void writePlantUMLFile(const QCString &fileName, DocVerbatim *s); - void visitPreStart(FTextStream &t, + void visitPreStart(std::ostream &t, const DocNodeList &children, bool hasCaption, const QCString &name, const QCString &width, const QCString &height, bool inlineImage = FALSE); - void visitPostEnd(FTextStream &t, bool hasCaption, bool inlineImage = FALSE); + void visitPostEnd(std::ostream &t, bool hasCaption, bool inlineImage = FALSE); void visitCaption(const DocNodeList &children); //-------------------------------------- // state variables //-------------------------------------- - FTextStream &m_t; + std::ostream &m_t; CodeOutputInterface &m_ci; bool m_insidePre = false; bool m_hide = false; diff --git a/src/docparser.cpp b/src/docparser.cpp index 36bc8a5..22b7341 100644 --- a/src/docparser.cpp +++ b/src/docparser.cpp @@ -17,7 +17,6 @@ #include <stdlib.h> #include <cassert> -#include <qfile.h> #include <qcstring.h> #include <ctype.h> #include <qcstringlist.h> @@ -52,6 +51,7 @@ #include "htmlentity.h" #include "emoji.h" #include "fileinfo.h" +#include "dir.h" #define TK_COMMAND_CHAR(token) ((token)==TK_COMMAND_AT ? '@' : '\\') @@ -317,8 +317,8 @@ static QCString findAndCopyImage(const char *fileName,DocImage::Type type, bool } QCString inputFile = fd->absFilePath(); - QFile inImage(inputFile); - if (inImage.open(IO_ReadOnly)) + FileInfo infi(inputFile.str()); + if (infi.exists()) { result = fileName; int i; @@ -351,34 +351,18 @@ static QCString findAndCopyImage(const char *fileName,DocImage::Type type, bool FileInfo outfi(outputFile.str()); if (outfi.isSymLink()) { - QFile::remove(outputFile); + Dir().remove(outputFile.str()); warn_doc_error(g_fileName,getDoctokinizerLineNr(), "destination of image %s is a symlink, replacing with image", qPrint(outputFile)); } if (outputFile!=inputFile) // prevent copying to ourself { - QFile outImage(outputFile.data()); - if (outImage.open(IO_WriteOnly)) // copy the image + if (copyFile(inputFile,outputFile) && type==DocImage::Html) { - char *buffer = new char[inImage.size()]; - inImage.readBlock(buffer,inImage.size()); - outImage.writeBlock(buffer,inImage.size()); - outImage.flush(); - delete[] buffer; - if (type==DocImage::Html) Doxygen::indexList->addImageFile(result); - } - else - { - warn_doc_error(g_fileName,getDoctokinizerLineNr(), - "could not write output image %s",qPrint(outputFile)); + Doxygen::indexList->addImageFile(result); } } - //else - //{ - // warn(g_fileName,getDoctokinizerLineNr(), - // "Prevented to copy file %s onto itself!\n",qPrint(inputFile)); - //} } else { @@ -1780,7 +1764,7 @@ DocEmoji::DocEmoji(DocNode *parent,const QCString &symName) : if (locSymName.at(0)!=':') locSymName.prepend(":"); } m_symName = locSymName; - m_index = EmojiEntityMapper::instance()->symbol2index(m_symName); + m_index = EmojiEntityMapper::instance()->symbol2index(m_symName.str()); if (m_index==-1) { warn_doc_error(g_fileName,getDoctokinizerLineNr(),"Found unsupported emoji symbol '%s'\n",qPrint(m_symName)); diff --git a/src/docsets.cpp b/src/docsets.cpp index f7c8c18..6040277 100644 --- a/src/docsets.cpp +++ b/src/docsets.cpp @@ -15,8 +15,8 @@ #include <set> #include <stack> +#include <fstream> -#include <qfile.h> #include "docsets.h" #include "config.h" #include "message.h" @@ -27,15 +27,12 @@ #include "memberdef.h" #include "namespacedef.h" #include "util.h" -#include "ftextstream.h" struct DocSets::Private { QCString indent(); - QFile nf; - QFile tf; - FTextStream nts; - FTextStream tts; + std::ofstream nts; + std::ofstream tts; std::stack<bool> indentStack; std::set<std::string> scopes; }; @@ -67,135 +64,131 @@ void DocSets::initialize() // -- write Makefile { - QCString mfName = Config_getString(HTML_OUTPUT) + "/Makefile"; - QFile makefile(mfName); - if (!makefile.open(IO_WriteOnly)) - { - term("Could not open file %s for writing\n",mfName.data()); - } - FTextStream ts(&makefile); + QCString mfName = Config_getString(HTML_OUTPUT) + "/Makefile"; + std::ofstream ts(mfName.str(),std::ofstream::out | std::ofstream::binary); + if (!ts.is_open()) + { + term("Could not open file %s for writing\n",mfName.data()); + } - ts << "DOCSET_NAME=" << bundleId << ".docset\n" - "DOCSET_CONTENTS=$(DOCSET_NAME)/Contents\n" - "DOCSET_RESOURCES=$(DOCSET_CONTENTS)/Resources\n" - "DOCSET_DOCUMENTS=$(DOCSET_RESOURCES)/Documents\n" - "DESTDIR=~/Library/Developer/Shared/Documentation/DocSets\n" - "XCODE_INSTALL=\"$(shell xcode-select -print-path)\"\n" - "\n" - "all: docset\n" - "\n" - "docset:\n" - "\tmkdir -p $(DOCSET_DOCUMENTS)\n" - "\tcp Nodes.xml $(DOCSET_RESOURCES)\n" - "\tcp Tokens.xml $(DOCSET_RESOURCES)\n" - "\tcp Info.plist $(DOCSET_CONTENTS)\n" - "\ttar --exclude $(DOCSET_NAME) \\\n" - "\t --exclude Nodes.xml \\\n" - "\t --exclude Tokens.xml \\\n" - "\t --exclude Info.plist \\\n" - "\t --exclude Makefile -c -f - . \\\n" - "\t | (cd $(DOCSET_DOCUMENTS); tar xvf -)\n" - "\t$(XCODE_INSTALL)/usr/bin/docsetutil index $(DOCSET_NAME)\n" - "\trm -f $(DOCSET_DOCUMENTS)/Nodes.xml\n" - "\trm -f $(DOCSET_DOCUMENTS)/Info.plist\n" - "\trm -f $(DOCSET_DOCUMENTS)/Makefile\n" - "\trm -f $(DOCSET_RESOURCES)/Nodes.xml\n" - "\trm -f $(DOCSET_RESOURCES)/Tokens.xml\n" - "\n" - "clean:\n" - "\trm -rf $(DOCSET_NAME)\n" - "\n" - "install: docset\n" - "\tmkdir -p $(DESTDIR)\n" - "\tcp -R $(DOCSET_NAME) $(DESTDIR)\n" - "\n" - "uninstall:\n" - "\trm -rf $(DESTDIR)/$(DOCSET_NAME)\n" - "\n" - "always:\n"; + ts << "DOCSET_NAME=" << bundleId << ".docset\n" + "DOCSET_CONTENTS=$(DOCSET_NAME)/Contents\n" + "DOCSET_RESOURCES=$(DOCSET_CONTENTS)/Resources\n" + "DOCSET_DOCUMENTS=$(DOCSET_RESOURCES)/Documents\n" + "DESTDIR=~/Library/Developer/Shared/Documentation/DocSets\n" + "XCODE_INSTALL=\"$(shell xcode-select -print-path)\"\n" + "\n" + "all: docset\n" + "\n" + "docset:\n" + "\tmkdir -p $(DOCSET_DOCUMENTS)\n" + "\tcp Nodes.xml $(DOCSET_RESOURCES)\n" + "\tcp Tokens.xml $(DOCSET_RESOURCES)\n" + "\tcp Info.plist $(DOCSET_CONTENTS)\n" + "\ttar --exclude $(DOCSET_NAME) \\\n" + "\t --exclude Nodes.xml \\\n" + "\t --exclude Tokens.xml \\\n" + "\t --exclude Info.plist \\\n" + "\t --exclude Makefile -c -f - . \\\n" + "\t | (cd $(DOCSET_DOCUMENTS); tar xvf -)\n" + "\t$(XCODE_INSTALL)/usr/bin/docsetutil index $(DOCSET_NAME)\n" + "\trm -f $(DOCSET_DOCUMENTS)/Nodes.xml\n" + "\trm -f $(DOCSET_DOCUMENTS)/Info.plist\n" + "\trm -f $(DOCSET_DOCUMENTS)/Makefile\n" + "\trm -f $(DOCSET_RESOURCES)/Nodes.xml\n" + "\trm -f $(DOCSET_RESOURCES)/Tokens.xml\n" + "\n" + "clean:\n" + "\trm -rf $(DOCSET_NAME)\n" + "\n" + "install: docset\n" + "\tmkdir -p $(DESTDIR)\n" + "\tcp -R $(DOCSET_NAME) $(DESTDIR)\n" + "\n" + "uninstall:\n" + "\trm -rf $(DESTDIR)/$(DOCSET_NAME)\n" + "\n" + "always:\n"; } // -- write Info.plist { - QCString plName = Config_getString(HTML_OUTPUT) + "/Info.plist"; - QFile plist(plName); - if (!plist.open(IO_WriteOnly)) - { - term("Could not open file %s for writing\n",plName.data()); - } - FTextStream ts(&plist); + QCString plName = Config_getString(HTML_OUTPUT) + "/Info.plist"; + std::ofstream ts(plName.str(),std::ofstream::out | std::ofstream::binary); + if (!ts.is_open()) + { + term("Could not open file %s for writing\n",plName.data()); + } - ts << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" - "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\"\n" - "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" - "<plist version=\"1.0\">\n" - "<dict>\n" - " <key>CFBundleName</key>\n" - " <string>" << projectName << "</string>\n" - " <key>CFBundleIdentifier</key>\n" - " <string>" << bundleId << "</string>\n" - " <key>CFBundleVersion</key>\n" - " <string>" << projectNumber << "</string>\n" - " <key>DocSetFeedName</key>\n" - " <string>" << feedName << "</string>\n" - " <key>DocSetPublisherIdentifier</key>\n" - " <string>" << publisherId << "</string>\n" - " <key>DocSetPublisherName</key>\n" - " <string>" << publisherName << "</string>\n" - // markers for Dash - " <key>DashDocSetFamily</key>\n" - " <string>doxy</string>\n" - " <key>DocSetPlatformFamily</key>\n" - " <string>doxygen</string>\n" - "</dict>\n" - "</plist>\n"; + ts << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\"\n" + "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" + "<plist version=\"1.0\">\n" + "<dict>\n" + " <key>CFBundleName</key>\n" + " <string>" << projectName << "</string>\n" + " <key>CFBundleIdentifier</key>\n" + " <string>" << bundleId << "</string>\n" + " <key>CFBundleVersion</key>\n" + " <string>" << projectNumber << "</string>\n" + " <key>DocSetFeedName</key>\n" + " <string>" << feedName << "</string>\n" + " <key>DocSetPublisherIdentifier</key>\n" + " <string>" << publisherId << "</string>\n" + " <key>DocSetPublisherName</key>\n" + " <string>" << publisherName << "</string>\n" + // markers for Dash + " <key>DashDocSetFamily</key>\n" + " <string>doxy</string>\n" + " <key>DocSetPlatformFamily</key>\n" + " <string>doxygen</string>\n" + "</dict>\n" + "</plist>\n"; } // -- start Nodes.xml QCString notes = Config_getString(HTML_OUTPUT) + "/Nodes.xml"; - p->nf.setName(notes); - if (!p->nf.open(IO_WriteOnly)) + p->nts.open(notes.str(),std::ofstream::out | std::ofstream::binary); + if (!p->nts.is_open()) { term("Could not open file %s for writing\n",notes.data()); } //QCString indexName=Config_getBool(GENERATE_TREEVIEW)?"main":"index"; QCString indexName="index"; - p->nts.setDevice(&p->nf); - p->nts << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl; - p->nts << "<DocSetNodes version=\"1.0\">" << endl; - p->nts << " <TOC>" << endl; - p->nts << " <Node>" << endl; - p->nts << " <Name>Root</Name>" << endl; - p->nts << " <Path>" << indexName << Doxygen::htmlFileExtension << "</Path>" << endl; - p->nts << " <Subnodes>" << endl; + p->nts << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; + p->nts << "<DocSetNodes version=\"1.0\">\n"; + p->nts << " <TOC>\n"; + p->nts << " <Node>\n"; + p->nts << " <Name>Root</Name>\n"; + p->nts << " <Path>" << indexName << Doxygen::htmlFileExtension << "</Path>\n"; + p->nts << " <Subnodes>\n"; p->indentStack.push(true); QCString tokens = Config_getString(HTML_OUTPUT) + "/Tokens.xml"; - p->tf.setName(tokens); - if (!p->tf.open(IO_WriteOnly)) + p->tts.open(tokens.str(),std::ofstream::out | std::ofstream::binary); + if (!p->tts.is_open()) { term("Could not open file %s for writing\n",tokens.data()); } - p->tts.setDevice(&p->tf); - p->tts << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl; - p->tts << "<Tokens version=\"1.0\">" << endl; + p->tts << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; + p->tts << "<Tokens version=\"1.0\">\n"; } void DocSets::finalize() { if (!p->indentStack.top()) { - p->nts << p->indent() << " </Node>" << endl; + p->nts << p->indent() << " </Node>\n"; } p->indentStack.pop(); - p->nts << " </Subnodes>" << endl; - p->nts << " </Node>" << endl; - p->nts << " </TOC>" << endl; - p->nts << "</DocSetNodes>" << endl; - p->nf.close(); + p->nts << " </Subnodes>\n"; + p->nts << " </Node>\n"; + p->nts << " </TOC>\n"; + p->nts << "</DocSetNodes>\n"; + p->nts.close(); - p->tts << "</Tokens>" << endl; - p->tf.close(); + p->tts << "</Tokens>\n"; + p->tts.close(); } QCString DocSets::Private::indent() @@ -208,7 +201,7 @@ QCString DocSets::Private::indent() void DocSets::incContentsDepth() { //printf("DocSets::incContentsDepth() depth=%zu\n",p->indentStack.size()); - p->nts << p->indent() << "<Subnodes>" << endl; + p->nts << p->indent() << "<Subnodes>\n"; p->indentStack.push(true); } @@ -216,9 +209,9 @@ void DocSets::decContentsDepth() { if (!p->indentStack.top()) { - p->nts << p->indent() << " </Node>" << endl; + p->nts << p->indent() << " </Node>\n"; } - p->nts << p->indent() << "</Subnodes>" << endl; + p->nts << p->indent() << "</Subnodes>\n"; p->indentStack.pop(); //printf("DocSets::decContentsDepth() depth=%zu\n",p->indentStack.size()); } @@ -238,15 +231,15 @@ void DocSets::addContentsItem(bool isDir, { if (!p->indentStack.top()) { - p->nts << p->indent() << " </Node>" << endl; + p->nts << p->indent() << " </Node>\n"; } p->indentStack.top()=false; - p->nts << p->indent() << " <Node>" << endl; - p->nts << p->indent() << " <Name>" << convertToXML(name) << "</Name>" << endl; + p->nts << p->indent() << " <Node>\n"; + p->nts << p->indent() << " <Name>" << convertToXML(name) << "</Name>\n"; if (file && file[0]=='^') // URL marker { p->nts << p->indent() << " <URL>" << convertToXML(&file[1]) - << "</URL>" << endl; + << "</URL>\n"; } else // relative file { @@ -259,10 +252,10 @@ void DocSets::addContentsItem(bool isDir, { p->nts << file << Doxygen::htmlFileExtension; } - p->nts << "</Path>" << endl; + p->nts << "</Path>\n"; if (file && anchor) { - p->nts << p->indent() << " <Anchor>" << anchor << "</Anchor>" << endl; + p->nts << p->indent() << " <Anchor>" << anchor << "</Anchor>\n"; } } } @@ -483,7 +476,7 @@ void DocSets::addIndexItem(const Definition *context,const MemberDef *md, } } -void DocSets::writeToken(FTextStream &t, +void DocSets::writeToken(std::ostream &t, const Definition *d, const QCString &type, const QCString &lang, @@ -491,40 +484,40 @@ void DocSets::writeToken(FTextStream &t, const char *anchor, const char *decl) { - t << " <Token>" << endl; - t << " <TokenIdentifier>" << endl; + t << " <Token>\n"; + t << " <TokenIdentifier>\n"; QCString name = d->name(); if (name.right(2)=="-p") name=name.left(name.length()-2); - t << " <Name>" << convertToXML(name) << "</Name>" << endl; + t << " <Name>" << convertToXML(name) << "</Name>\n"; if (!lang.isEmpty()) { - t << " <APILanguage>" << lang << "</APILanguage>" << endl; + t << " <APILanguage>" << lang << "</APILanguage>\n"; } if (!type.isEmpty()) { - t << " <Type>" << type << "</Type>" << endl; + t << " <Type>" << type << "</Type>\n"; } if (scope) { - t << " <Scope>" << convertToXML(scope) << "</Scope>" << endl; + t << " <Scope>" << convertToXML(scope) << "</Scope>\n"; } - t << " </TokenIdentifier>" << endl; + t << " </TokenIdentifier>\n"; t << " <Path>" << d->getOutputFileBase() - << Doxygen::htmlFileExtension << "</Path>" << endl; + << Doxygen::htmlFileExtension << "</Path>\n"; if (anchor) { - t << " <Anchor>" << anchor << "</Anchor>" << endl; + t << " <Anchor>" << anchor << "</Anchor>\n"; } QCString tooltip = d->briefDescriptionAsTooltip(); if (!tooltip.isEmpty()) { - t << " <Abstract>" << convertToXML(tooltip) << "</Abstract>" << endl; + t << " <Abstract>" << convertToXML(tooltip) << "</Abstract>\n"; } if (decl) { - t << " <DeclaredIn>" << convertToXML(decl) << "</DeclaredIn>" << endl; + t << " <DeclaredIn>" << convertToXML(decl) << "</DeclaredIn>\n"; } - t << " </Token>" << endl; + t << " </Token>\n"; } void DocSets::addIndexFile(const char *name) diff --git a/src/docsets.h b/src/docsets.h index 6065cfe..2bdf7ac 100644 --- a/src/docsets.h +++ b/src/docsets.h @@ -17,12 +17,11 @@ #define DOCSETS_H #include <memory> +#include <iostream> #include "index.h" -class QFile; class Definition; -class FTextStream; /** A class that generates docset files. * @@ -55,7 +54,7 @@ class DocSets : public IndexIntf void addStyleSheetFile(const char *) {} private: - void writeToken(FTextStream &t, const Definition *d, + void writeToken(std::ostream &t, const Definition *d, const QCString &type, const QCString &lang, const char *scope=0, const char *anchor=0, const char *decl=0); diff --git a/src/doctokenizer.l b/src/doctokenizer.l index eaf8a43..5debd5f 100644 --- a/src/doctokenizer.l +++ b/src/doctokenizer.l @@ -28,8 +28,6 @@ #include <stack> #include <string> -#include <qfile.h> - #include "doctokenizer.h" #include "cmdmapper.h" #include "config.h" diff --git a/src/dot.cpp b/src/dot.cpp index cc0f070..8deb0d8 100644 --- a/src/dot.cpp +++ b/src/dot.cpp @@ -15,6 +15,7 @@ #include <cstdlib> #include <cassert> +#include <sstream> #include "config.h" #include "dot.h" @@ -23,7 +24,6 @@ #include "util.h" #include "portable.h" #include "message.h" -#include "ftextstream.h" #include "doxygen.h" #include "language.h" #include "index.h" @@ -319,7 +319,7 @@ void writeDotGraphFromFile(const char *inFile,const char *outDir, * \param context the scope in which this graph is found (for resolving links) * \param graphId a unique id for this graph, use for dynamic sections */ -void writeDotImageMapFromFile(FTextStream &t, +void writeDotImageMapFromFile(std::ostream &t, const QCString &inFile, const QCString &outDir, const QCString &relPath, const QCString &baseName, const QCString &context,int graphId) @@ -346,7 +346,7 @@ void writeDotImageMapFromFile(FTextStream &t, if (imgExt=="svg") // vector graphics { - QCString svgName=outDir+"/"+baseName+".svg"; + QCString svgName = outDir+"/"+baseName+".svg"; DotFilePatcher::writeSVGFigureLink(t,relPath,baseName,svgName); DotFilePatcher patcher(svgName); patcher.addSVGConversion("",TRUE,context,TRUE,graphId); @@ -354,17 +354,15 @@ void writeDotImageMapFromFile(FTextStream &t, } else // bitmap graphics { - QGString result; - FTextStream tt(&result); - + std::stringstream tt; t << "<img src=\"" << relPath << imgName << "\" alt=\"" - << imgName << "\" border=\"0\" usemap=\"#" << mapName << "\"/>" << endl; + << imgName << "\" border=\"0\" usemap=\"#" << mapName << "\"/>\n"; DotFilePatcher::convertMapFile(tt, absOutFile, relPath ,TRUE, context); - if (!result.isEmpty()) + if (tt.tellg()>0) { t << "<map name=\"" << mapName << "\" id=\"" << mapName << "\">"; - t << result; - t << "</map>" << endl; + t << tt.str(); + t << "</map>\n"; } } d.remove(absOutFile.str()); @@ -23,7 +23,6 @@ #include "dotfilepatcher.h" #include "dotrunner.h" -class FTextStream; class DotRunner; class DotRunnerQueue; @@ -50,7 +49,7 @@ class DotManager void writeDotGraphFromFile(const char *inFile,const char *outDir, const char *outFile,GraphOutputFormat format); -void writeDotImageMapFromFile(FTextStream &t, +void writeDotImageMapFromFile(std::ostream &t, const QCString& inFile, const QCString& outDir, const QCString& relPath,const QCString& baseName, const QCString& context,int graphId=-1); diff --git a/src/dotcallgraph.cpp b/src/dotcallgraph.cpp index 78e9b9b..efe829f 100644 --- a/src/dotcallgraph.cpp +++ b/src/dotcallgraph.cpp @@ -179,7 +179,7 @@ QCString DotCallGraph::getMapLabel() const } QCString DotCallGraph::writeGraph( - FTextStream &out, + std::ostream &out, GraphOutputFormat graphFormat, EmbeddedOutputFormat textFormat, const char *path, diff --git a/src/dotcallgraph.h b/src/dotcallgraph.h index 1bc8882..ad9006f 100644 --- a/src/dotcallgraph.h +++ b/src/dotcallgraph.h @@ -18,7 +18,6 @@ #include "dotnode.h" #include "dotgraph.h" -#include "ftextstream.h" #include "memberdef.h" /** Representation of an call graph */ @@ -30,7 +29,7 @@ class DotCallGraph : public DotGraph bool isTrivial() const; bool isTooBig() const; int numNodes() const; - QCString writeGraph(FTextStream &t, GraphOutputFormat gf, EmbeddedOutputFormat ef, + QCString writeGraph(std::ostream &t, GraphOutputFormat gf, EmbeddedOutputFormat ef, const char *path,const char *fileName, const char *relPath,bool writeImageMap=TRUE, int graphId=-1); diff --git a/src/dotclassgraph.cpp b/src/dotclassgraph.cpp index 9146a25..c4f5b48 100644 --- a/src/dotclassgraph.cpp +++ b/src/dotclassgraph.cpp @@ -441,7 +441,7 @@ QCString DotClassGraph::getImgAltText() const return ""; } -QCString DotClassGraph::writeGraph(FTextStream &out, +QCString DotClassGraph::writeGraph(std::ostream &out, GraphOutputFormat graphFormat, EmbeddedOutputFormat textFormat, const char *path, @@ -456,7 +456,7 @@ QCString DotClassGraph::writeGraph(FTextStream &out, //-------------------------------------------------------------------- -void DotClassGraph::writeXML(FTextStream &t) +void DotClassGraph::writeXML(std::ostream &t) { for (const auto &kv : m_usedNodes) { @@ -464,7 +464,7 @@ void DotClassGraph::writeXML(FTextStream &t) } } -void DotClassGraph::writeDocbook(FTextStream &t) +void DotClassGraph::writeDocbook(std::ostream &t) { for (const auto &kv : m_usedNodes) { @@ -472,7 +472,7 @@ void DotClassGraph::writeDocbook(FTextStream &t) } } -void DotClassGraph::writeDEF(FTextStream &t) +void DotClassGraph::writeDEF(std::ostream &t) { for (const auto &kv : m_usedNodes) { diff --git a/src/dotclassgraph.h b/src/dotclassgraph.h index 168d315..5b00098 100644 --- a/src/dotclassgraph.h +++ b/src/dotclassgraph.h @@ -16,6 +16,8 @@ #ifndef DOTCLASSGRAPH_H #define DOTCLASSGRAPH_H +#include <iostream> + #include "classdef.h" #include "dotnode.h" #include "dotgraph.h" @@ -29,13 +31,13 @@ public: bool isTrivial() const; bool isTooBig() const; int numNodes() const; - QCString writeGraph(FTextStream &t,GraphOutputFormat gf,EmbeddedOutputFormat ef, + QCString writeGraph(std::ostream &t,GraphOutputFormat gf,EmbeddedOutputFormat ef, const char *path, const char *fileName, const char *relPath, bool TBRank=TRUE,bool imageMap=TRUE,int graphId=-1); - void writeXML(FTextStream &t); - void writeDocbook(FTextStream &t); - void writeDEF(FTextStream &t); + void writeXML(std::ostream &t); + void writeDocbook(std::ostream &t); + void writeDEF(std::ostream &t); protected: virtual QCString getBaseName() const; diff --git a/src/dotdirdeps.cpp b/src/dotdirdeps.cpp index a4e556e..8e203c7 100644 --- a/src/dotdirdeps.cpp +++ b/src/dotdirdeps.cpp @@ -13,9 +13,9 @@ * */ -#include "dotdirdeps.h" +#include <sstream> -#include "ftextstream.h" +#include "dotdirdeps.h" #include "util.h" #include "doxygen.h" #include "config.h" @@ -29,7 +29,7 @@ using DirDefMap = std::map<std::string,const DirDef *>; * @param[in] fillBackground if the node shall be explicitly filled * @param[in,out] directoriesInGraph lists the directories which have been written to the output stream */ -static void drawDirectory(FTextStream &outStream, const DirDef *const directory, const bool fillBackground, +static void drawDirectory(std::ostream &outStream, const DirDef *const directory, const bool fillBackground, DirDefMap &directoriesInGraph) { outStream << " " << directory->getOutputFileBase() << " [shape=box " @@ -46,7 +46,7 @@ static void drawDirectory(FTextStream &outStream, const DirDef *const directory, directoriesInGraph.insert(std::make_pair(directory->getOutputFileBase().str(), directory)); } -void writeDotDirDepGraph(FTextStream &t,const DirDef *dd,bool linkRelations) +void writeDotDirDepGraph(std::ostream &t,const DirDef *dd,bool linkRelations) { int fontSize = Config_getInt(DOT_FONTSIZE); QCString fontName = Config_getString(DOT_FONTNAME); @@ -199,9 +199,10 @@ QCString DotDirDeps::getBaseName() const void DotDirDeps::computeTheGraph() { // compute md5 checksum of the graph were are about to generate - FTextStream md5stream(&m_theGraph); + std::stringstream md5stream; //m_dir->writeDepGraph(md5stream); writeDotDirDepGraph(md5stream,m_dir,m_linkRelations); + m_theGraph = md5stream.str(); } QCString DotDirDeps::getMapLabel() const @@ -214,7 +215,7 @@ QCString DotDirDeps::getImgAltText() const return convertToXML(m_dir->displayName()); } -QCString DotDirDeps::writeGraph(FTextStream &out, +QCString DotDirDeps::writeGraph(std::ostream &out, GraphOutputFormat graphFormat, EmbeddedOutputFormat textFormat, const char *path, diff --git a/src/dotdirdeps.h b/src/dotdirdeps.h index a71e8f1..ff46db2 100644 --- a/src/dotdirdeps.h +++ b/src/dotdirdeps.h @@ -26,7 +26,7 @@ class DotDirDeps : public DotGraph DotDirDeps(const DirDef *dir); ~DotDirDeps(); bool isTrivial() const; - QCString writeGraph(FTextStream &out, + QCString writeGraph(std::ostream &out, GraphOutputFormat gf, EmbeddedOutputFormat ef, const char *path, diff --git a/src/dotfilepatcher.cpp b/src/dotfilepatcher.cpp index 4960cf4..2d934f0 100644 --- a/src/dotfilepatcher.cpp +++ b/src/dotfilepatcher.cpp @@ -13,13 +13,12 @@ * */ +#include <sstream> + #include "dotfilepatcher.h" #include "dotrunner.h" - -#include "qstring.h" #include "config.h" #include "message.h" -#include "ftextstream.h" #include "docparser.h" #include "doxygen.h" #include "util.h" @@ -212,40 +211,34 @@ static QCString replaceRef(const QCString &buf,const QCString relPath, * map file was found * \returns TRUE if successful. */ -bool DotFilePatcher::convertMapFile(FTextStream &t,const char *mapName, +bool DotFilePatcher::convertMapFile(std::ostream &t,const char *mapName, const QCString relPath, bool urlOnly, const QCString &context) { - QFile f(mapName); - if (!f.open(IO_ReadOnly)) + std::ifstream f(mapName,std::ifstream::in); + if (!f.is_open()) { err("problems opening map file %s for inclusion in the docs!\n" "If you installed Graphviz/dot after a previous failing run, \n" "try deleting the output directory and rerun doxygen.\n",mapName); return FALSE; } - const int maxLineLen=10240; - while (!f.atEnd()) // foreach line + std::string line; + while (getline(f,line)) // foreach line { - QCString buf(maxLineLen); - int numBytes = f.readLine(buf.rawData(),maxLineLen); - if (numBytes>0) + QCString buf = line+'\n'; + if (buf.left(5)=="<area") { - buf.resize(numBytes+1); - - if (buf.left(5)=="<area") + QCString replBuf = replaceRef(buf,relPath,urlOnly,context); + // strip id="..." from replBuf since the id's are not needed and not unique. + int indexS = replBuf.find("id=\""), indexE; + if (indexS>0 && (indexE=replBuf.find('"',indexS+4))!=-1) { - QCString replBuf = replaceRef(buf,relPath,urlOnly,context); - // strip id="..." from replBuf since the id's are not needed and not unique. - int indexS = replBuf.find("id=\""), indexE; - if (indexS>0 && (indexE=replBuf.find('"',indexS+4))!=-1) - { - t << replBuf.left(indexS-1) << replBuf.right(replBuf.length() - indexE - 1); - } - else - { - t << replBuf; - } + t << replBuf.left(indexS-1) << replBuf.right(replBuf.length() - indexE - 1); + } + else + { + t << replBuf; } } } @@ -320,40 +313,31 @@ bool DotFilePatcher::run() const err("Failed to rename file %s to %s!\n",m_patchFile.data(),tmpName.c_str()); return FALSE; } - QFile fi(tmpName.c_str()); - QFile fo(patchFile.c_str()); - if (!fi.open(IO_ReadOnly)) + std::ifstream fi(tmpName, std::ifstream::in); + std::ofstream t(patchFile, std::ofstream::out | std::ofstream::binary); + if (!fi.is_open()) { err("problem opening file %s for patching!\n",tmpName.c_str()); thisDir.rename(tmpName,patchFile); return FALSE; } - if (!fo.open(IO_WriteOnly)) + if (!t.is_open()) { err("problem opening file %s for patching!\n",m_patchFile.data()); thisDir.rename(tmpName,patchFile); return FALSE; } - FTextStream t(&fo); - const int maxLineLen=100*1024; - int lineNr=1; int width,height; bool insideHeader=FALSE; bool replacedHeader=FALSE; bool foundSize=FALSE; - while (!fi.atEnd()) // foreach line + int lineNr=1; + std::string lineStr; + while (getline(fi,lineStr)) { - QCString line(maxLineLen); - int numBytes = fi.readLine(line.rawData(),maxLineLen); - if (numBytes<=0) - { - break; - } - line.resize(numBytes+1); - + QCString line = lineStr+'\n'; //printf("line=[%s]\n",line.stripWhiteSpace().data()); int i; - ASSERT(numBytes<maxLineLen); if (isSVGFile) { if (interactiveSVG_local) @@ -427,17 +411,16 @@ bool DotFilePatcher::run() const int n = sscanf(line.data()+i,"<!-- MAP %d",&mapId); if (n==1 && mapId>=0 && mapId<(int)m_maps.size()) { - QGString result; - FTextStream tt(&result); + std::stringstream tt; const Map &map = m_maps.at(mapId); //printf("patching MAP %d in file %s with contents of %s\n", // mapId,m_patchFile.data(),map.mapFile.data()); convertMapFile(tt,map.mapFile,map.relPath,map.urlOnly,map.context); - if (!result.isEmpty()) + if (tt.tellg()>0) { - t << "<map name=\"" << correctId(map.label) << "\" id=\"" << correctId(map.label) << "\">" << endl; - t << result; - t << "</map>" << endl; + t << "<map name=\"" << correctId(map.label) << "\" id=\"" << correctId(map.label) << "\">\n"; + t << tt.str(); + t << "</map>\n"; } } else // error invalid map id! @@ -479,36 +462,29 @@ bool DotFilePatcher::run() const { QCString orgName=m_patchFile.left(m_patchFile.length()-4)+"_org.svg"; t << substitute(svgZoomFooter,"$orgname",stripPath(orgName)); - fo.close(); + t.close(); // keep original SVG file so we can refer to it, we do need to replace // dummy link by real ones - fi.setName(tmpName.c_str()); - fo.setName(orgName); - if (!fi.open(IO_ReadOnly)) + fi.open(tmpName,std::ifstream::in); + t.open(orgName,std::ofstream::out); + if (!fi.is_open()) { err("problem opening file %s for reading!\n",tmpName.c_str()); return FALSE; } - if (!fo.open(IO_WriteOnly)) + if (!t.is_open()) { err("problem opening file %s for writing!\n",orgName.data()); return FALSE; } - FTextStream to(&fo); - while (!fi.atEnd()) // foreach line + while (getline(fi,lineStr)) // foreach line { - QCString line(maxLineLen); - int numBytes = fi.readLine(line.rawData(),maxLineLen); - if (numBytes<=0) - { - break; - } - line.resize(numBytes+1); + std::string line = lineStr+'\n'; const Map &map = m_maps.front(); // there is only one 'map' for a SVG file - to << replaceRef(line,map.relPath,map.urlOnly,map.context,"_top"); + t << replaceRef(line.c_str(),map.relPath,map.urlOnly,map.context,"_top"); } fi.close(); - fo.close(); + t.close(); } // remove temporary file thisDir.remove(tmpName); @@ -522,50 +498,37 @@ bool DotFilePatcher::run() const static bool readSVGSize(const QCString &fileName,int *width,int *height) { bool found=FALSE; - QFile f(fileName); - if (!f.open(IO_ReadOnly)) + std::ifstream f(fileName.str(),std::ifstream::in); + if (!f.is_open()) { - return FALSE; + return false; } - const int maxLineLen=4096; - char buf[maxLineLen]; - while (!f.atEnd() && !found) + std::string line; + while (getline(f,line) && !found) { - int numBytes = f.readLine(buf,maxLineLen-1); // read line - if (numBytes>0) + if (qstrncmp(line.c_str(),"<!--zoomable ",13)==0) { - buf[numBytes]='\0'; - if (qstrncmp(buf,"<!--zoomable ",13)==0) - { - *width=-1; - *height=-1; - sscanf(buf,"<!--zoomable %d",height); - //printf("Found zoomable for %s!\n",fileName.data()); - found=TRUE; - } - else if (sscanf(buf,"<svg width=\"%dpt\" height=\"%dpt\"",width,height)==2) - { - //printf("Found fixed size %dx%d for %s!\n",*width,*height,fileName.data()); - found=TRUE; - } + *width=-1; + *height=-1; + sscanf(line.c_str(),"<!--zoomable %d",height); + found=true; } - else // read error! + else if (sscanf(line.c_str(),"<svg width=\"%dpt\" height=\"%dpt\"",width,height)==2) { - //printf("Read error %d!\n",numBytes); - return FALSE; + found=true; } } - return TRUE; + return true; } -static void writeSVGNotSupported(FTextStream &out) +static void writeSVGNotSupported(std::ostream &out) { out << "<p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p>"; } /// Check if a reference to a SVG figure can be written and do so if possible. /// Returns FALSE if not possible (for instance because the SVG file is not yet generated). -bool DotFilePatcher::writeSVGFigureLink(FTextStream &out,const QCString &relPath, +bool DotFilePatcher::writeSVGFigureLink(std::ostream &out,const QCString &relPath, const QCString &baseName,const QCString &absImgName) { int width=600,height=600; @@ -604,7 +567,7 @@ bool DotFilePatcher::writeSVGFigureLink(FTextStream &out,const QCString &relPath return TRUE; } -bool DotFilePatcher::writeVecGfxFigure(FTextStream &out,const QCString &baseName, +bool DotFilePatcher::writeVecGfxFigure(std::ostream &out,const QCString &baseName, const QCString &figureName) { int width=400,height=550; diff --git a/src/dotfilepatcher.h b/src/dotfilepatcher.h index 1886e47..5b51da8 100644 --- a/src/dotfilepatcher.h +++ b/src/dotfilepatcher.h @@ -17,11 +17,10 @@ #define DOTFILEPATCHER_H #include <vector> +#include <iostream> #include "qcstring.h" -class FTextStream; - /** Helper class to insert a set of map file into an output file */ class DotFilePatcher { @@ -42,14 +41,14 @@ class DotFilePatcher bool run() const; bool isSVGFile() const; - static bool convertMapFile(FTextStream &t,const char *mapName, + static bool convertMapFile(std::ostream &t,const char *mapName, const QCString relPath, bool urlOnly=FALSE, const QCString &context=QCString()); - static bool writeSVGFigureLink(FTextStream &out,const QCString &relPath, + static bool writeSVGFigureLink(std::ostream &out,const QCString &relPath, const QCString &baseName,const QCString &absImgName); - static bool writeVecGfxFigure(FTextStream& out, const QCString& baseName, + static bool writeVecGfxFigure(std::ostream& out, const QCString& baseName, const QCString& figureName); private: diff --git a/src/dotgfxhierarchytable.cpp b/src/dotgfxhierarchytable.cpp index 9a14cb4..f05f982 100644 --- a/src/dotgfxhierarchytable.cpp +++ b/src/dotgfxhierarchytable.cpp @@ -13,8 +13,9 @@ * */ -#include "dotgfxhierarchytable.h" +#include <sstream> +#include "dotgfxhierarchytable.h" #include "language.h" #include "util.h" #include "message.h" @@ -34,9 +35,9 @@ QCString DotGfxHierarchyTable::getBaseName() const void DotGfxHierarchyTable::computeTheGraph() { - FTextStream md5stream(&m_theGraph); + std::stringstream md5stream; writeGraphHeader(md5stream,theTranslator->trGraphicalHierarchy()); - md5stream << " rankdir=\"LR\";" << endl; + md5stream << " rankdir=\"LR\";\n"; for (auto node : m_rootNodes) { if (node->subgraphId()==m_rootSubgraphNode->subgraphId()) @@ -52,7 +53,7 @@ void DotGfxHierarchyTable::computeTheGraph() } } writeGraphFooter(md5stream); - + m_theGraph = md5stream.str(); } QCString DotGfxHierarchyTable::getMapLabel() const @@ -60,7 +61,7 @@ QCString DotGfxHierarchyTable::getMapLabel() const return escapeCharsInString(m_rootSubgraphNode->label(),FALSE); } -void DotGfxHierarchyTable::createGraph(DotNode *n,FTextStream &out, +void DotGfxHierarchyTable::createGraph(DotNode *n,std::ostream &out, const char *path,const char *fileName,int id) { m_rootSubgraphNode = n; @@ -70,7 +71,7 @@ void DotGfxHierarchyTable::createGraph(DotNode *n,FTextStream &out, DotGraph::writeGraph(out, GOF_BITMAP, EOF_Html, path, fileName, "", TRUE, 0); } -void DotGfxHierarchyTable::writeGraph(FTextStream &out, +void DotGfxHierarchyTable::writeGraph(std::ostream &out, const char *path,const char *fileName) { //printf("DotGfxHierarchyTable::writeGraph(%s)\n",name); @@ -86,7 +87,7 @@ void DotGfxHierarchyTable::writeGraph(FTextStream &out, } // put each connected subgraph of the hierarchy in a row of the HTML output - out << "<table border=\"0\" cellspacing=\"10\" cellpadding=\"0\">" << endl; + out << "<table border=\"0\" cellspacing=\"10\" cellpadding=\"0\">\n"; int count=0; std::sort(m_rootSubgraphs.begin(),m_rootSubgraphs.end(), @@ -95,9 +96,9 @@ void DotGfxHierarchyTable::writeGraph(FTextStream &out, { out << "<tr><td>"; createGraph(n,out,path,fileName,count++); - out << "</td></tr>" << endl; + out << "</td></tr>\n"; } - out << "</table>" << endl; + out << "</table>\n"; } void DotGfxHierarchyTable::addHierarchy(DotNode *n,const ClassDef *cd,ClassDefSet &visitedClasses) diff --git a/src/dotgfxhierarchytable.h b/src/dotgfxhierarchytable.h index 089ecd2..e85f3e9 100644 --- a/src/dotgfxhierarchytable.h +++ b/src/dotgfxhierarchytable.h @@ -22,8 +22,6 @@ #include <vector> #include "classdef.h" -#include "ftextstream.h" - #include "dotgraph.h" #include "dotnode.h" @@ -34,9 +32,9 @@ class DotGfxHierarchyTable : public DotGraph { public: DotGfxHierarchyTable(const char *prefix="",ClassDef::CompoundType ct=ClassDef::Class); - void createGraph(DotNode *rootNode,FTextStream &t,const char *path, + void createGraph(DotNode *rootNode,std::ostream &t,const char *path, const char *fileName,int id); - void writeGraph(FTextStream &t,const char *path, const char *fileName); + void writeGraph(std::ostream &t,const char *path, const char *fileName); const std::vector<DotNode*> subGraphs() const { return m_rootSubgraphs; } protected: diff --git a/src/dotgraph.cpp b/src/dotgraph.cpp index e044bec..1f5d5a0 100644 --- a/src/dotgraph.cpp +++ b/src/dotgraph.cpp @@ -13,6 +13,8 @@ * */ +#include <sstream> + #include "config.h" #include "doxygen.h" #include "index.h" @@ -39,22 +41,21 @@ static bool checkMd5Signature(const QCString &baseName, const QCString &md5) { - QFile f(baseName+".md5"); - if (f.open(IO_ReadOnly)) + std::ifstream f(baseName.str()+".md5",std::ifstream::in | std::ifstream::binary); + if (f.is_open()) { // read checksum QCString md5stored(33); - int bytesRead=f.readBlock(md5stored.rawData(),32); + f.read(md5stored.rawData(),32); md5stored[32]='\0'; // compare checksum - if (bytesRead==32 && md5==md5stored) + if (!f.fail() && md5==md5stored) { // bail out if equal - return FALSE; + return false; } } - f.close(); - return TRUE; + return true; } static bool checkDeliverables(const QCString &file1, @@ -75,24 +76,23 @@ static bool checkDeliverables(const QCString &file1, return file1Ok && file2Ok; } -static bool insertMapFile(FTextStream &out,const QCString &mapFile, +static bool insertMapFile(std::ostream &out,const QCString &mapFile, const QCString &relPath,const QCString &mapLabel) { FileInfo fi(mapFile.str()); if (fi.exists() && fi.size()>0) // reuse existing map file { - QGString tmpstr; - FTextStream tmpout(&tmpstr); - DotFilePatcher::convertMapFile(tmpout,mapFile,relPath,FALSE); - if (!tmpstr.isEmpty()) + std::stringstream t; + DotFilePatcher::convertMapFile(t,mapFile,relPath,false); + if (t.tellg()>0) { - out << "<map name=\"" << mapLabel << "\" id=\"" << mapLabel << "\">" << endl; - out << tmpstr; - out << "</map>" << endl; + out << "<map name=\"" << mapLabel << "\" id=\"" << mapLabel << "\">\n"; + out << t.str(); + out << "</map>\n"; } - return TRUE; + return true; } - return FALSE; // no map file yet, need to generate it + return false; // no map file yet, need to generate it } //-------------------------------------------------------------------- @@ -104,7 +104,7 @@ QCString DotGraph::imgName() const } QCString DotGraph::writeGraph( - FTextStream& t, // output stream for the code file (html, ...) + std::ostream& t, // output stream for the code file (html, ...) GraphOutputFormat gf, // bitmap(png/svg) or ps(eps/pdf) EmbeddedOutputFormat ef, // html, latex, ... const char* path, // output folder @@ -164,14 +164,13 @@ bool DotGraph::prepareDotFile() // need to rebuild the image // write .dot file because image was new or has changed - QFile f(absDotName()); - if (!f.open(IO_WriteOnly)) + std::ofstream f(absDotName().str(),std::ofstream::out | std::ofstream::binary); + if (!f.is_open()) { - err("Could not open file %s for writing\n",f.name().data()); + err("Could not open file %s for writing\n",absDotName().data()); return TRUE; } - FTextStream t(&f); - t << m_theGraph; + f << m_theGraph; f.close(); if (m_graphFormat == GOF_BITMAP) @@ -197,22 +196,22 @@ bool DotGraph::prepareDotFile() return TRUE; } -void DotGraph::generateCode(FTextStream &t) +void DotGraph::generateCode(std::ostream &t) { QCString imgExt = getDotImageExtension(); if (m_graphFormat==GOF_BITMAP && m_textFormat==EOF_DocBook) { - t << "<para>" << endl; - t << " <informalfigure>" << endl; - t << " <mediaobject>" << endl; - t << " <imageobject>" << endl; + t << "<para>\n"; + t << " <informalfigure>\n"; + t << " <mediaobject>\n"; + t << " <imageobject>\n"; t << " <imagedata"; t << " width=\"50%\" align=\"center\" valign=\"middle\" scalefit=\"0\" fileref=\"" << m_relPath << m_baseName << "." << imgExt << "\">"; - t << "</imagedata>" << endl; - t << " </imageobject>" << endl; - t << " </mediaobject>" << endl; - t << " </informalfigure>" << endl; - t << "</para>" << endl; + t << "</imagedata>\n"; + t << " </imageobject>\n"; + t << " </mediaobject>\n"; + t << " </informalfigure>\n"; + t << "</para>\n"; } else if (m_graphFormat==GOF_BITMAP && m_generateImageMap) // produce HTML to include the image { @@ -230,22 +229,22 @@ void DotGraph::generateCode(FTextStream &t) int mapId = DotManager::instance()-> createFilePatcher(m_fileName.data())-> addSVGObject(m_baseName,absImgName(),m_relPath); - t << "<!-- SVG " << mapId << " -->" << endl; + t << "<!-- SVG " << mapId << " -->\n"; } - if (!m_noDivTag) t << "</div>" << endl; + if (!m_noDivTag) t << "</div>\n"; } else // add link to bitmap file with image map { if (!m_noDivTag) t << "<div class=\"center\">"; t << "<img src=\"" << relImgName() << "\" border=\"0\" usemap=\"#" << correctId(getMapLabel()) << "\" alt=\"" << getImgAltText() << "\"/>"; if (!m_noDivTag) t << "</div>"; - t << endl; + t << "\n"; if (m_regenerate || !insertMapFile(t, absMapName(), m_relPath, correctId(getMapLabel()))) { int mapId = DotManager::instance()-> createFilePatcher(m_fileName.data())-> addMap(absMapName(), m_relPath, m_urlOnly, QCString(), getMapLabel()); - t << "<!-- MAP " << mapId << " -->" << endl; + t << "<!-- MAP " << mapId << " -->\n"; } } } @@ -256,12 +255,12 @@ void DotGraph::generateCode(FTextStream &t) int figId = DotManager::instance()-> createFilePatcher(m_fileName.data())-> addFigure(m_baseName,absBaseName(),FALSE /*TRUE*/); - t << endl << "% FIG " << figId << endl; + t << "\n% FIG " << figId << "\n"; } } } -void DotGraph::writeGraphHeader(FTextStream &t,const QCString &title) +void DotGraph::writeGraphHeader(std::ostream &t,const QCString &title) { int fontSize = Config_getInt(DOT_FONTSIZE); QCString fontName = Config_getString(DOT_FONTNAME); @@ -274,7 +273,7 @@ void DotGraph::writeGraphHeader(FTextStream &t,const QCString &title) { t << "\"" << convertToXML(title) << "\""; } - t << endl << "{" << endl; + t << "\n{\n"; if (Config_getBool(INTERACTIVE_SVG)) // insert a comment to force regeneration when this // option is toggled { @@ -283,7 +282,7 @@ void DotGraph::writeGraphHeader(FTextStream &t,const QCString &title) t << " // LATEX_PDF_SIZE\n"; // write placeholder for LaTeX PDF bounding box size replacement if (Config_getBool(DOT_TRANSPARENT)) { - t << " bgcolor=\"transparent\";" << endl; + t << " bgcolor=\"transparent\";\n"; } t << " edge [fontname=\"" << fontName << "\"," "fontsize=\"" << fontSize << "\"," @@ -293,9 +292,9 @@ void DotGraph::writeGraphHeader(FTextStream &t,const QCString &title) "fontsize=\"" << fontSize << "\",shape=record];\n"; } -void DotGraph::writeGraphFooter(FTextStream &t) +void DotGraph::writeGraphFooter(std::ostream &t) { - t << "}" << endl; + t << "}\n"; } void DotGraph::computeGraph(DotNode *root, @@ -305,15 +304,14 @@ void DotGraph::computeGraph(DotNode *root, bool renderParents, bool backArrows, const QCString &title, - QGString &graphStr) + QCString &graphStr) { //printf("computeMd5Signature\n"); - QGString buf; - FTextStream md5stream(&buf); + std::stringstream md5stream; writeGraphHeader(md5stream,title); if (!rank.isEmpty()) { - md5stream << " rankdir=\"" << rank << "\";" << endl; + md5stream << " rankdir=\"" << rank << "\";\n"; } root->clearWriteFlag(); root->write(md5stream, gt, format, gt!=CallGraph && gt!=Dependency, TRUE, backArrows); @@ -346,6 +344,6 @@ void DotGraph::computeGraph(DotNode *root, } writeGraphFooter(md5stream); - graphStr=buf.data(); + graphStr=md5stream.str(); } diff --git a/src/dotgraph.h b/src/dotgraph.h index ea3891b..a0b6136 100644 --- a/src/dotgraph.h +++ b/src/dotgraph.h @@ -16,11 +16,11 @@ #ifndef DOTGRAPH_H #define DOTGRAPH_H +#include <iostream> + #include <qcstring.h> -#include <qgstring.h> #include "dir.h" -class FTextStream; class DotNode; enum GraphOutputFormat { GOF_BITMAP, GOF_EPS }; @@ -39,7 +39,7 @@ class DotGraph /** returns node numbers. The Counter is reset by the constructor */ int getNextNodeNumber() { return ++m_curNodeNumber; } - QCString writeGraph(FTextStream &t, + QCString writeGraph(std::ostream &t, GraphOutputFormat gf, EmbeddedOutputFormat ef, const char *path, @@ -49,8 +49,8 @@ class DotGraph int graphId=-1 ); - static void writeGraphHeader(FTextStream& t, const QCString& title = QCString()); - static void writeGraphFooter(FTextStream& t); + static void writeGraphHeader(std::ostream& t, const QCString& title = QCString()); + static void writeGraphFooter(std::ostream& t); static void computeGraph(DotNode* root, GraphType gt, GraphOutputFormat format, @@ -58,7 +58,7 @@ class DotGraph bool renderParents, bool backArrows, const QCString& title, - QGString& graphStr + QCString& graphStr ); virtual QCString getBaseName() const = 0; @@ -85,7 +85,7 @@ class DotGraph QCString m_absPath; QCString m_baseName; - QGString m_theGraph; + QCString m_theGraph; bool m_regenerate = false; bool m_doNotAddImageToIndex = false; bool m_noDivTag = false; @@ -97,7 +97,7 @@ class DotGraph DotGraph &operator=(const DotGraph &); bool prepareDotFile(); - void generateCode(FTextStream &t); + void generateCode(std::ostream &t); int m_curNodeNumber = 0; }; diff --git a/src/dotgroupcollaboration.cpp b/src/dotgroupcollaboration.cpp index 1dc1380..34359dd 100644 --- a/src/dotgroupcollaboration.cpp +++ b/src/dotgroupcollaboration.cpp @@ -13,6 +13,8 @@ * */ +#include <sstream> + #include "dotgroupcollaboration.h" #include "classlist.h" #include "doxygen.h" @@ -207,7 +209,7 @@ QCString DotGroupCollaboration::getBaseName() const void DotGroupCollaboration::computeTheGraph() { - FTextStream md5stream(&m_theGraph); + std::stringstream md5stream; writeGraphHeader(md5stream,m_rootNode->label()); // clean write flags @@ -230,6 +232,7 @@ void DotGroupCollaboration::computeTheGraph() writeGraphFooter(md5stream); + m_theGraph = md5stream.str(); } QCString DotGroupCollaboration::getMapLabel() const @@ -237,7 +240,7 @@ QCString DotGroupCollaboration::getMapLabel() const return escapeCharsInString(m_baseName, FALSE); } -QCString DotGroupCollaboration::writeGraph( FTextStream &t, +QCString DotGroupCollaboration::writeGraph( std::ostream &t, GraphOutputFormat graphFormat, EmbeddedOutputFormat textFormat, const char *path, const char *fileName, const char *relPath, bool generateImageMap,int graphId) @@ -247,7 +250,7 @@ QCString DotGroupCollaboration::writeGraph( FTextStream &t, return DotGraph::writeGraph(t, graphFormat, textFormat, path, fileName, relPath, generateImageMap, graphId); } -void DotGroupCollaboration::Edge::write( FTextStream &t ) const +void DotGroupCollaboration::Edge::write( std::ostream &t ) const { const char* linkTypeColor[] = { "darkorchid3" @@ -304,7 +307,7 @@ void DotGroupCollaboration::Edge::write( FTextStream &t ) const break; } t << ", " << arrowStyle; - t << "];" << endl; + t << "];\n"; } bool DotGroupCollaboration::isTrivial() const @@ -312,7 +315,7 @@ bool DotGroupCollaboration::isTrivial() const return m_usedNodes.size() <= 1; } -void DotGroupCollaboration::writeGraphHeader(FTextStream &t,const QCString &title) const +void DotGroupCollaboration::writeGraphHeader(std::ostream &t,const QCString &title) const { int fontSize = Config_getInt(DOT_FONTSIZE); QCString fontName = Config_getString(DOT_FONTNAME); @@ -325,11 +328,11 @@ void DotGroupCollaboration::writeGraphHeader(FTextStream &t,const QCString &titl { t << "\"" << convertToXML(title) << "\""; } - t << endl; - t << "{" << endl; + t << "\n"; + t << "{\n"; if (Config_getBool(DOT_TRANSPARENT)) { - t << " bgcolor=\"transparent\";" << endl; + t << " bgcolor=\"transparent\";\n"; } t << " edge [fontname=\"" << fontName << "\",fontsize=\"" << fontSize << "\"," "labelfontname=\"" << fontName << "\",labelfontsize=\"" << fontSize << "\"];\n"; diff --git a/src/dotgroupcollaboration.h b/src/dotgroupcollaboration.h index ebfe6e7..3d83673 100644 --- a/src/dotgroupcollaboration.h +++ b/src/dotgroupcollaboration.h @@ -16,6 +16,8 @@ #ifndef DOTGROUPCOLLABORATION_H #define DOTGROUPCOLLABORATION_H +#include <iostream> + #include "dotnode.h" #include "dotgraph.h" #include "groupdef.h" @@ -26,7 +28,7 @@ class DotGroupCollaboration : public DotGraph public : DotGroupCollaboration(const GroupDef* gd); ~DotGroupCollaboration(); - QCString writeGraph(FTextStream &t, GraphOutputFormat gf,EmbeddedOutputFormat ef, + QCString writeGraph(std::ostream &t, GraphOutputFormat gf,EmbeddedOutputFormat ef, const char *path,const char *fileName,const char *relPath, bool writeImageMap=TRUE,int graphId=-1); bool isTrivial() const; @@ -65,13 +67,13 @@ class DotGroupCollaboration : public DotGraph EdgeType eType; std::vector<Link> links; - void write( FTextStream &t ) const; + void write( std::ostream &t ) const; }; void buildGraph(const GroupDef* gd); void addCollaborationMember(const Definition* def, QCString& url, EdgeType eType ); void addMemberList( class MemberList* ml ); - void writeGraphHeader(FTextStream &t,const QCString &title) const; + void writeGraphHeader(std::ostream &t,const QCString &title) const; Edge* addEdge( DotNode* _pNStart, DotNode* _pNEnd, EdgeType _eType, const QCString& _label, const QCString& _url ); diff --git a/src/dotincldepgraph.cpp b/src/dotincldepgraph.cpp index 07b2139..4f6b8c3 100644 --- a/src/dotincldepgraph.cpp +++ b/src/dotincldepgraph.cpp @@ -180,7 +180,7 @@ QCString DotInclDepGraph::getMapLabel() const } } -QCString DotInclDepGraph::writeGraph(FTextStream &out, +QCString DotInclDepGraph::writeGraph(std::ostream &out, GraphOutputFormat graphFormat, EmbeddedOutputFormat textFormat, const char *path, @@ -207,7 +207,7 @@ int DotInclDepGraph::numNodes() const return (int)m_startNode->children().size(); } -void DotInclDepGraph::writeXML(FTextStream &t) +void DotInclDepGraph::writeXML(std::ostream &t) { for (const auto &kv : m_usedNodes) { @@ -215,7 +215,7 @@ void DotInclDepGraph::writeXML(FTextStream &t) } } -void DotInclDepGraph::writeDocbook(FTextStream &t) +void DotInclDepGraph::writeDocbook(std::ostream &t) { for (const auto &kv : m_usedNodes) { diff --git a/src/dotincldepgraph.h b/src/dotincldepgraph.h index 0105489..f511608 100644 --- a/src/dotincldepgraph.h +++ b/src/dotincldepgraph.h @@ -28,14 +28,14 @@ class DotInclDepGraph : public DotGraph public: DotInclDepGraph(const FileDef *fd,bool inverse); ~DotInclDepGraph(); - QCString writeGraph(FTextStream &t, GraphOutputFormat gf, EmbeddedOutputFormat ef, + QCString writeGraph(std::ostream &t, GraphOutputFormat gf, EmbeddedOutputFormat ef, const char *path,const char *fileName,const char *relPath, bool writeImageMap=TRUE,int graphId=-1); bool isTrivial() const; bool isTooBig() const; int numNodes() const; - void writeXML(FTextStream &t); - void writeDocbook(FTextStream &t); + void writeXML(std::ostream &t); + void writeDocbook(std::ostream &t); protected: virtual QCString getBaseName() const; diff --git a/src/dotlegendgraph.cpp b/src/dotlegendgraph.cpp index b17a293..c1f800b 100644 --- a/src/dotlegendgraph.cpp +++ b/src/dotlegendgraph.cpp @@ -13,6 +13,8 @@ * */ +#include <sstream> + #include "dotlegendgraph.h" #include "util.h" #include "config.h" @@ -23,7 +25,7 @@ void DotLegendGraph::writeGraph(const char *path) { - FTextStream ts; + std::stringstream ts; DotGraph::writeGraph(ts, GOF_BITMAP, EOF_Html, path, "", "", FALSE, 0); if (getDotImageExtension()=="svg") @@ -43,7 +45,7 @@ void DotLegendGraph::computeTheGraph() { int fontSize = Config_getInt(DOT_FONTSIZE); QCString fontName = Config_getString(DOT_FONTNAME); - FTextStream md5stream(&m_theGraph); + std::stringstream md5stream; writeGraphHeader(md5stream,theTranslator->trLegendTitle()); md5stream << " Node9 [shape=\"box\",label=\"Inherited\",fontsize=\"" << fontSize << "\",height=0.2,width=0.4,fontname=\"" << fontName << "\",fillcolor=\"grey75\",style=\"filled\" fontcolor=\"black\"];\n"; md5stream << " Node10 -> Node9 [dir=\"back\",color=\"midnightblue\",fontsize=\"" << fontSize << "\",style=\"solid\",fontname=\"" << fontName << "\"];\n"; @@ -63,6 +65,7 @@ void DotLegendGraph::computeTheGraph() md5stream << " Node18 -> Node9 [dir=\"back\",color=\"darkorchid3\",fontsize=\"" << fontSize << "\",style=\"dashed\",label=\"m_usedClass\",fontname=\"" << fontName << "\"];\n"; md5stream << " Node18 [shape=\"box\",label=\"Used\",fontsize=\"" << fontSize << "\",height=0.2,width=0.4,fontname=\"" << fontName << "\",color=\"black\"];\n"; writeGraphFooter(md5stream); + m_theGraph = md5stream.str(); } QCString DotLegendGraph::getMapLabel() const diff --git a/src/dotnode.cpp b/src/dotnode.cpp index 318878d..234dff0 100644 --- a/src/dotnode.cpp +++ b/src/dotnode.cpp @@ -14,8 +14,6 @@ */ #include "dotnode.h" - -#include "ftextstream.h" #include "classdef.h" #include "config.h" #include "memberlist.h" @@ -139,7 +137,7 @@ static QCString escapeTooltip(const QCString &tooltip) return result; } -static void writeBoxMemberList(FTextStream &t, +static void writeBoxMemberList(std::ostream &t, char prot,const MemberList *ml,const ClassDef *scope, bool isStatic=FALSE,const StringUnorderedSet *skipNames=nullptr) { @@ -378,7 +376,7 @@ void DotNode::deleteNodes(DotNode *node) } } -void DotNode::writeBox(FTextStream &t, +void DotNode::writeBox(std::ostream &t, GraphType gt, GraphOutputFormat /*format*/, bool hasNonReachableChildren) const @@ -500,10 +498,10 @@ void DotNode::writeBox(FTextStream &t, { t << ",tooltip=\" \""; // space in tooltip is required otherwise still something like 'Node0' is used } - t << "];" << endl; + t << "];\n"; } -void DotNode::writeArrow(FTextStream &t, +void DotNode::writeArrow(std::ostream &t, GraphType gt, GraphOutputFormat format, const DotNode *cn, @@ -549,10 +547,10 @@ void DotNode::writeArrow(FTextStream &t, } if (format==GOF_BITMAP) t << ",fontname=\"" << Config_getString(DOT_FONTNAME) << "\""; - t << "];" << endl; + t << "];\n"; } -void DotNode::write(FTextStream &t, +void DotNode::write(std::ostream &t, GraphType gt, GraphOutputFormat format, bool topDown, @@ -603,10 +601,10 @@ void DotNode::write(FTextStream &t, //printf("end DotNode::write(%d) name=%s\n",distance,m_label.data()); } -void DotNode::writeXML(FTextStream &t,bool isClassGraph) const +void DotNode::writeXML(std::ostream &t,bool isClassGraph) const { - t << " <node id=\"" << m_number << "\">" << endl; - t << " <label>" << convertToXML(m_label) << "</label>" << endl; + t << " <node id=\"" << m_number << "\">\n"; + t << " <label>" << convertToXML(m_label) << "</label>\n"; if (!m_url.isEmpty()) { QCString url(m_url); @@ -620,7 +618,7 @@ void DotNode::writeXML(FTextStream &t,bool isClassGraph) const { t << " external=\"" << convertToXML(refPtr) << "\""; } - t << "/>" << endl; + t << "/>\n"; } } auto it = m_edgeInfo.begin(); @@ -645,7 +643,7 @@ void DotNode::writeXML(FTextStream &t,bool isClassGraph) const { t << "include"; } - t << "\">" << endl; + t << "\">\n"; if (!edgeInfo.label().isEmpty()) { int p=0; @@ -654,23 +652,23 @@ void DotNode::writeXML(FTextStream &t,bool isClassGraph) const { t << " <edgelabel>" << convertToXML(edgeInfo.label().mid(p,ni-p)) - << "</edgelabel>" << endl; + << "</edgelabel>\n"; p=ni+1; } t << " <edgelabel>" << convertToXML(edgeInfo.label().right(edgeInfo.label().length()-p)) - << "</edgelabel>" << endl; + << "</edgelabel>\n"; } - t << " </childnode>" << endl; + t << " </childnode>\n"; ++it; } - t << " </node>" << endl; + t << " </node>\n"; } -void DotNode::writeDocbook(FTextStream &t,bool isClassGraph) const +void DotNode::writeDocbook(std::ostream &t,bool isClassGraph) const { - t << " <node id=\"" << m_number << "\">" << endl; - t << " <label>" << convertToXML(m_label) << "</label>" << endl; + t << " <node id=\"" << m_number << "\">\n"; + t << " <label>" << convertToXML(m_label) << "</label>\n"; if (!m_url.isEmpty()) { QCString url(m_url); @@ -684,7 +682,7 @@ void DotNode::writeDocbook(FTextStream &t,bool isClassGraph) const { t << " external=\"" << convertToXML(refPtr) << "\""; } - t << "/>" << endl; + t << "/>\n"; } } auto it = m_edgeInfo.begin(); @@ -709,7 +707,7 @@ void DotNode::writeDocbook(FTextStream &t,bool isClassGraph) const { t << "include"; } - t << "\">" << endl; + t << "\">\n"; if (!edgeInfo.label().isEmpty()) { int p=0; @@ -718,27 +716,27 @@ void DotNode::writeDocbook(FTextStream &t,bool isClassGraph) const { t << " <edgelabel>" << convertToXML(edgeInfo.label().mid(p,ni-p)) - << "</edgelabel>" << endl; + << "</edgelabel>\n"; p=ni+1; } t << " <edgelabel>" << convertToXML(edgeInfo.label().right(edgeInfo.label().length()-p)) - << "</edgelabel>" << endl; + << "</edgelabel>\n"; } - t << " </childnode>" << endl; + t << " </childnode>\n"; ++it; } - t << " </node>" << endl; + t << " </node>\n"; } -void DotNode::writeDEF(FTextStream &t) const +void DotNode::writeDEF(std::ostream &t) const { const char* nodePrefix = " node-"; - t << " node = {" << endl; - t << nodePrefix << "id = " << m_number << ';' << endl; - t << nodePrefix << "label = '" << m_label << "';" << endl; + t << " node = {\n"; + t << nodePrefix << "id = " << m_number << ";\n"; + t << nodePrefix << "label = '" << m_label << "';\n"; if (!m_url.isEmpty()) { @@ -748,23 +746,23 @@ void DotNode::writeDEF(FTextStream &t) const if (urlPtr) { *urlPtr++='\0'; - t << nodePrefix << "link = {" << endl << " " - << nodePrefix << "link-id = '" << urlPtr << "';" << endl; + t << nodePrefix << "link = {\n" << " " + << nodePrefix << "link-id = '" << urlPtr << "';\n"; if (*refPtr!='\0') { t << " " << nodePrefix << "link-external = '" - << refPtr << "';" << endl; + << refPtr << "';\n"; } - t << " };" << endl; + t << " };\n"; } } auto it = m_edgeInfo.begin(); for (const auto &childNode : m_children) { const EdgeInfo &edgeInfo = *it; - t << " node-child = {" << endl; - t << " child-id = '" << childNode->number() << "';" << endl; + t << " node-child = {\n"; + t << " child-id = '" << childNode->number() << "';\n"; t << " relation = "; switch (edgeInfo.color()) @@ -777,18 +775,18 @@ void DotNode::writeDEF(FTextStream &t) const case EdgeInfo::Orange2: t << "type-constraint"; break; case EdgeInfo::Grey: ASSERT(0); break; } - t << ';' << endl; + t << ";\n"; if (!edgeInfo.label().isEmpty()) { - t << " edgelabel = <<_EnD_oF_dEf_TeXt_" << endl - << edgeInfo.label() << endl - << "_EnD_oF_dEf_TeXt_;" << endl; + t << " edgelabel = <<_EnD_oF_dEf_TeXt_\n" + << edgeInfo.label() << "\n" + << "_EnD_oF_dEf_TeXt_;\n"; } - t << " }; /* node-child */" << endl; + t << " }; /* node-child */\n"; ++it; } - t << " }; /* node */" << endl; + t << " }; /* node */\n"; } diff --git a/src/dotnode.h b/src/dotnode.h index 2eb3f7d..bfe5af4 100644 --- a/src/dotnode.h +++ b/src/dotnode.h @@ -19,12 +19,12 @@ #include <vector> #include <map> #include <deque> +#include <iostream> #include "dotgraph.h" class ClassDef; class DotNode; -class FTextStream; /** Attributes of an edge of a dot graph */ class EdgeInfo @@ -75,14 +75,14 @@ class DotNode void removeParent(DotNode *n); int findParent( DotNode *n ); - void write(FTextStream &t,GraphType gt,GraphOutputFormat f, + void write(std::ostream &t,GraphType gt,GraphOutputFormat f, bool topDown,bool toChildren,bool backArrows) const; - void writeXML(FTextStream &t,bool isClassGraph) const; - void writeDocbook(FTextStream &t,bool isClassGraph) const; - void writeDEF(FTextStream &t) const; - void writeBox(FTextStream &t,GraphType gt,GraphOutputFormat f, + void writeXML(std::ostream &t,bool isClassGraph) const; + void writeDocbook(std::ostream &t,bool isClassGraph) const; + void writeDEF(std::ostream &t) const; + void writeBox(std::ostream &t,GraphType gt,GraphOutputFormat f, bool hasNonReachableChildren) const; - void writeArrow(FTextStream &t,GraphType gt,GraphOutputFormat f,const DotNode *cn, + void writeArrow(std::ostream &t,GraphType gt,GraphOutputFormat f,const DotNode *cn, const EdgeInfo *ei,bool topDown, bool pointBack=TRUE) const; QCString label() const { return m_label; } diff --git a/src/dotrunner.cpp b/src/dotrunner.cpp index 727b44e..7c31c85 100644 --- a/src/dotrunner.cpp +++ b/src/dotrunner.cpp @@ -16,13 +16,10 @@ #include <cassert> #include "dotrunner.h" - -#include "qstring.h" #include "util.h" #include "portable.h" #include "dot.h" #include "message.h" -#include "ftextstream.h" #include "config.h" #include "dir.h" @@ -75,42 +72,33 @@ static bool resetPDFSize(const int width,const int height, const char *base) err("Failed to rename file %s to %s!\n",patchFile.data(),tmpName.data()); return FALSE; } - QFile fi(tmpName.c_str()); - QFile fo(patchFile.c_str()); - if (!fi.open(IO_ReadOnly)) + std::ifstream fi(tmpName,std::ifstream::in); + std::ofstream t(patchFile,std::ofstream::out | std::ofstream::binary); + if (!fi.is_open()) { err("problem opening file %s for patching!\n",tmpName.data()); thisDir.rename(tmpName,patchFile); return FALSE; } - if (!fo.open(IO_WriteOnly)) + if (!t.is_open()) { err("problem opening file %s for patching!\n",patchFile.data()); thisDir.rename(tmpName,patchFile); - fi.close(); return FALSE; } - FTextStream t(&fo); - const int maxLineLen=100*1024; - while (!fi.atEnd()) // foreach line + std::string line; + while (getline(fi,line)) // foreach line { - QCString line(maxLineLen); - int numBytes = fi.readLine(line.rawData(),maxLineLen); - if (numBytes<=0) - { - break; - } - line.resize(numBytes+1); - if (line.find("LATEX_PDF_SIZE") != -1) + if (line.find("LATEX_PDF_SIZE") != std::string::npos) { double scale = (width > height ? width : height)/double(MAX_LATEX_GRAPH_INCH); - t << " size=\""<<width/scale << "," <<height/scale <<"\";\n"; + t << " size=\""<<width/scale << "," <<height/scale << "\";\n"; } else - t << line; + t << line << "\n"; } fi.close(); - fo.close(); + t.close(); // remove temporary file thisDir.remove(tmpName); return TRUE; diff --git a/src/doxygen.cpp b/src/doxygen.cpp index 89ca1aa..cb9ed19 100644 --- a/src/doxygen.cpp +++ b/src/doxygen.cpp @@ -13,9 +13,6 @@ * */ -#include <qfile.h> -#include <qdir.h> - #include <stdio.h> #include <stdlib.h> #include <sys/stat.h> @@ -8980,12 +8977,11 @@ static QCString fixSlashes(QCString &s) static void generateConfigFile(const char *configFile,bool shortList, bool updateOnly=FALSE) { - QFile f; - bool fileOpened=openOutputFile(configFile,f); + std::ofstream t; + bool fileOpened=openOutputFile(configFile,t); bool writeToStdout=(configFile[0]=='-' && configFile[1]=='\0'); if (fileOpened) { - FTextStream t(&f); Config::writeTemplate(t,shortList,updateOnly); if (!writeToStdout) { @@ -9010,35 +9006,26 @@ static void generateConfigFile(const char *configFile,bool shortList, term("Cannot open file %s for writing\n",configFile); } } + static void compareDoxyfile() { - QFile f; + std::ofstream f; char configFile[2]; configFile[0] = '-'; configFile[1] = '\0'; bool fileOpened=openOutputFile(configFile,f); if (fileOpened) { - FTextStream t(&f); - Config::compareDoxyfile(t); + Config::compareDoxyfile(f); } else { term("Cannot open file %s for writing\n",configFile); } } -//---------------------------------------------------------------------------- -// read and parse a tag file - -//static bool readLineFromFile(QFile &f,QCString &s) -//{ -// char c=0; -// s.resize(0); -// while (!f.atEnd() && (c=f.getch())!='\n') s+=c; -// return f.atEnd(); -//} //---------------------------------------------------------------------------- +// read and parse a tag file static void readTagFile(const std::shared_ptr<Entry> &root,const char *tl) { @@ -9301,7 +9288,7 @@ static std::shared_ptr<Entry> parseFile(OutlineParserInterface &parser, } FileInfo fi(fileName.str()); - BufStr preBuf(fi.size()+4096); + BufStr preBuf((uint)fi.size()+4096); if (Config_getBool(ENABLE_PREPROCESSING) && parser.needsPreprocessing(extension)) @@ -9313,7 +9300,7 @@ static std::shared_ptr<Entry> parseFile(OutlineParserInterface &parser, std::string absPath = FileInfo(s).absFilePath(); preprocessor.addSearchDir(absPath.c_str()); } - BufStr inBuf(fi.size()+4096); + BufStr inBuf((uint)fi.size()+4096); msg("Preprocessing %s...\n",fn); readInputFile(fileName,inBuf); preprocessor.processFile(fileName,inBuf,preBuf); @@ -9891,7 +9878,7 @@ void readAliases() //---------------------------------------------------------------------------- -static void dumpSymbol(FTextStream &t,Definition *d) +static void dumpSymbol(std::ostream &t,Definition *d) { QCString anchor; if (d->definitionType()==Definition::TypeMember) @@ -9910,15 +9897,14 @@ static void dumpSymbol(FTextStream &t,Definition *d) << d->name() << "','" << d->getDefFileName() << "','" << d->getDefLine() - << "');" << endl; + << "');\n"; } static void dumpSymbolMap() { - QFile f("symbols.sql"); - if (f.open(IO_WriteOnly)) + std::ofstream t("symbols.sql",std::ofstream::out | std::ofstream::binary); + if (t.is_open()) { - FTextStream t(&f); for (const auto &kv : Doxygen::symbolMap) { dumpSymbol(t,kv.second); @@ -10247,7 +10233,7 @@ void readConfiguration(int argc, char **argv) cleanUpDoxygen(); exit(1); } - QFile f; + std::ofstream f; if (openOutputFile(argv[optind+1],f)) { RTFGenerator::writeExtensionsFile(f); @@ -10275,7 +10261,7 @@ void readConfiguration(int argc, char **argv) cleanUpDoxygen(); exit(1); } - QFile f; + std::ofstream f; if (openOutputFile(argv[optind+1],f)) { EmojiEntityMapper::instance()->writeEmojiFile(f); @@ -10303,7 +10289,7 @@ void readConfiguration(int argc, char **argv) cleanUpDoxygen(); exit(1); } - QFile f; + std::ofstream f; if (openOutputFile(argv[optind+1],f)) { RTFGenerator::writeStyleSheetFile(f); @@ -10340,7 +10326,7 @@ void readConfiguration(int argc, char **argv) warn_uncond("Output language %s not supported! Using English instead.\n", outputLanguage.data()); } - QFile f; + std::ofstream f; if (openOutputFile(argv[optind+1],f)) { HtmlGenerator::writeHeaderFile(f, argv[optind+3]); @@ -10386,7 +10372,7 @@ void readConfiguration(int argc, char **argv) warn_uncond("Output language %s not supported! Using English instead.\n", outputLanguage.data()); } - QFile f; + std::ofstream f; if (openOutputFile(argv[optind+1],f)) { LatexGenerator::writeHeaderFile(f); @@ -10666,22 +10652,21 @@ static void writeTagFile() QCString generateTagFile = Config_getString(GENERATE_TAGFILE); if (generateTagFile.isEmpty()) return; - QFile tag(generateTagFile); - if (!tag.open(IO_WriteOnly)) + std::ofstream tagFile(generateTagFile.str(),std::ofstream::out); + if (!tagFile.is_open()) { err("cannot open tag file %s for writing\n", generateTagFile.data() ); return; } - FTextStream tagFile(&tag); - tagFile << "<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>" << endl; + tagFile << "<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>\n"; tagFile << "<tagfile doxygen_version=\"" << getDoxygenVersion() << "\""; if (strlen(getGitVersion())>0) { tagFile << " doxygen_gitid=\"" << getGitVersion() << "\""; } - tagFile << ">" << endl; + tagFile << ">\n"; // for each file for (const auto &fn : *Doxygen::inputNameLinkedMap) @@ -10721,27 +10706,7 @@ static void writeTagFile() } if (Doxygen::mainPage) Doxygen::mainPage->writeTagFile(tagFile); - /* - if (Doxygen::mainPage && !Config_getString(GENERATE_TAGFILE).isEmpty()) - { - tagFile << " <compound kind=\"page\">" << endl - << " <name>" - << convertToXML(Doxygen::mainPage->name()) - << "</name>" << endl - << " <title>" - << convertToXML(Doxygen::mainPage->title()) - << "</title>" << endl - << " <filename>" - << convertToXML(Doxygen::mainPage->getOutputFileBase()) - << Doxygen::htmlFileExtension - << "</filename>" << endl; - - mainPage->writeDocAnchorsToTagFile(); - tagFile << " </compound>" << endl; - } - */ - - tagFile << "</tagfile>" << endl; + tagFile << "</tagfile>\n"; } static void exitDoxygen() @@ -11136,8 +11101,8 @@ void parseInput() defaultLayoutUsed = TRUE; } - QFile layoutFile(layoutFileName); - if (layoutFile.open(IO_ReadOnly)) + FileInfo fi(layoutFileName.str()); + if (fi.exists()) { msg("Parsing layout file %s...\n",layoutFileName.data()); LayoutDocManager::instance().parse(layoutFileName); diff --git a/src/doxygen.h b/src/doxygen.h index 137fb8c..5b136b4 100644 --- a/src/doxygen.h +++ b/src/doxygen.h @@ -17,7 +17,6 @@ #define DOXYGEN_H #include "containers.h" -#include "ftextstream.h" #include "membergroup.h" #include "dirdef.h" #include "memberlist.h" @@ -34,7 +33,6 @@ class PageLinkedMap; class PageDef; class SearchIndexIntf; class ParserManager; -class QFileInfo; class BufStr; class CiteDict; class MemberDef; diff --git a/src/eclipsehelp.cpp b/src/eclipsehelp.cpp index bbb3b01..d9ef12f 100644 --- a/src/eclipsehelp.cpp +++ b/src/eclipsehelp.cpp @@ -3,8 +3,8 @@ * Copyright (C) 1997-2015 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its - * documentation under the terms of the GNU General Public License is hereby - * granted. No representations are made about the suitability of this software + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * @@ -17,13 +17,12 @@ #include "config.h" #include "message.h" #include "doxygen.h" -#include <qfile.h> -EclipseHelp::EclipseHelp() : m_depth(0), m_endtag(FALSE), m_openTags(0), m_tocfile(0) +EclipseHelp::EclipseHelp() : m_depth(0), m_endtag(FALSE), m_openTags(0) { } -EclipseHelp::~EclipseHelp() +EclipseHelp::~EclipseHelp() { } @@ -38,18 +37,18 @@ void EclipseHelp::indent() void EclipseHelp::closedTag() { - if (m_endtag) + if (m_endtag) { - m_tocstream << "/>" << endl; + m_tocstream << "/>\n"; m_endtag = FALSE; } } void EclipseHelp::openedTag() { - if (m_endtag) + if (m_endtag) { - m_tocstream << ">" << endl; + m_tocstream << ">\n"; m_endtag = FALSE; ++m_openTags; } @@ -61,33 +60,29 @@ void EclipseHelp::openedTag() * This method opens the XML TOC file and writes headers of the files. * \sa finalize() */ -void EclipseHelp::initialize() +void EclipseHelp::initialize() { // -- read path prefix from the configuration //m_pathprefix = Config_getString(ECLIPSE_PATHPREFIX); //if (m_pathprefix.isEmpty()) m_pathprefix = "html/"; - // -- open the contents file + // -- open the contents file QCString name = Config_getString(HTML_OUTPUT) + "/toc.xml"; - m_tocfile = new QFile(name); - if (!m_tocfile->open(IO_WriteOnly)) + m_tocstream.open(name.str(), std::ofstream::out | std::ofstream::binary); + if (!m_tocstream.is_open()) { term("Could not open file %s for writing\n", name.data()); } - // -- initialize its text stream - m_tocstream.setDevice(m_tocfile); - //m_tocstream.setEncoding(FTextStream::UnicodeUTF8); - // -- write the opening tag QCString title = Config_getString(PROJECT_NAME); if (title.isEmpty()) { title = "Doxygen generated documentation"; } - m_tocstream << "<toc label=\"" << convertToXML(title) - << "\" topic=\"" << convertToXML(m_pathprefix) - << "index" << Doxygen::htmlFileExtension << "\">" << endl; + m_tocstream << "<toc label=\"" << convertToXML(title) + << "\" topic=\"" << convertToXML(m_pathprefix) + << "index" << Doxygen::htmlFileExtension << "\">\n"; ++ m_depth; } @@ -97,38 +92,35 @@ void EclipseHelp::initialize() * This method writes footers of the files and closes them. * \sa initialize() */ -void EclipseHelp::finalize() +void EclipseHelp::finalize() { closedTag(); // -- close previous tag - // -- write ending tag + // -- write ending tag --m_depth; - m_tocstream << "</toc>" << endl; + m_tocstream << "</toc>\n"; // -- close the content file - m_tocstream.unsetDevice(); - m_tocfile->close(); - delete m_tocfile; m_tocfile = 0; + m_tocstream.close(); QCString name = Config_getString(HTML_OUTPUT) + "/plugin.xml"; - QFile pluginFile(name); - if (pluginFile.open(IO_WriteOnly)) + std::ofstream t(name.str(),std::ofstream::out | std::ofstream::binary); + if (t.is_open()) { QCString docId = Config_getString(ECLIPSE_DOC_ID); - FTextStream t(&pluginFile); - t << "<plugin name=\"" << docId << "\" id=\"" << docId << "\"" << endl; - t << " version=\"1.0.0\" provider-name=\"Doxygen\">" << endl; - t << " <extension point=\"org.eclipse.help.toc\">" << endl; - t << " <toc file=\"toc.xml\" primary=\"true\" />" << endl; - t << " </extension>" << endl; - t << "</plugin>" << endl; + t << "<plugin name=\"" << docId << "\" id=\"" << docId << "\"\n"; + t << " version=\"1.0.0\" provider-name=\"Doxygen\">\n"; + t << " <extension point=\"org.eclipse.help.toc\">\n"; + t << " <toc file=\"toc.xml\" primary=\"true\" />\n"; + t << " </extension>\n"; + t << "</plugin>\n"; } } /*! * \brief Increase the level of content hierarchy */ -void EclipseHelp::incContentsDepth() +void EclipseHelp::incContentsDepth() { openedTag(); ++m_depth; @@ -139,7 +131,7 @@ void EclipseHelp::incContentsDepth() * * It closes currently opened topic tag. */ -void EclipseHelp::decContentsDepth() +void EclipseHelp::decContentsDepth() { // -- end of the opened topic closedTag(); @@ -149,7 +141,7 @@ void EclipseHelp::decContentsDepth() { --m_openTags; indent(); - m_tocstream << "</topic>" << endl; + m_tocstream << "</topic>\n"; } } @@ -173,12 +165,12 @@ void EclipseHelp::addContentsItem( const char *anchor, bool /* separateIndex */, bool /* addToNavIndex */, - const Definition * /*def*/) + const Definition * /*def*/) { - // -- write the topic tag + // -- write the topic tag closedTag(); - if (file) - { + if (file) + { switch (file[0]) // check for special markers (user defined URLs) { case '^': @@ -195,7 +187,7 @@ void EclipseHelp::addContentsItem( default: indent(); m_tocstream << "<topic label=\"" << convertToXML(name) << "\""; - m_tocstream << " href=\"" << convertToXML(m_pathprefix) + m_tocstream << " href=\"" << convertToXML(m_pathprefix) << file << Doxygen::htmlFileExtension; if (anchor) { @@ -222,15 +214,15 @@ void EclipseHelp::addIndexItem( { } -void EclipseHelp::addIndexFile(const char * /* name */) +void EclipseHelp::addIndexFile(const char * /* name */) { } -void EclipseHelp::addImageFile(const char * /* name */) +void EclipseHelp::addImageFile(const char * /* name */) { } -void EclipseHelp::addStyleSheetFile(const char * /* name */) +void EclipseHelp::addStyleSheetFile(const char * /* name */) { } diff --git a/src/eclipsehelp.h b/src/eclipsehelp.h index 5d63768..1f4a8df 100644 --- a/src/eclipsehelp.h +++ b/src/eclipsehelp.h @@ -1,12 +1,12 @@ /****************************************************************************** * - * + * * * Copyright (C) 1997-2015 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its - * documentation under the terms of the GNU General Public License is hereby - * granted. No representations are made about the suitability of this software + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * @@ -24,11 +24,11 @@ #ifndef ECLIPSEHELP_H #define ECLIPSEHELP_H +#include <fstream> + #include "index.h" -#include "ftextstream.h" /* -- forward declarations */ -class QFile; class Definition; /** Generator for Eclipse help files. @@ -37,7 +37,7 @@ class Definition; * These files can be used to generate a help plugin readable * by the Eclipse IDE. */ -class EclipseHelp : public IndexIntf +class EclipseHelp : public IndexIntf { public: EclipseHelp(); @@ -62,8 +62,7 @@ class EclipseHelp : public IndexIntf bool m_endtag; int m_openTags; - QFile * m_tocfile; - FTextStream m_tocstream; + std::ofstream m_tocstream; QCString m_pathprefix; /* -- avoid copying */ diff --git a/src/emoji.cpp b/src/emoji.cpp index a8a2bb8..9871c22 100644 --- a/src/emoji.cpp +++ b/src/emoji.cpp @@ -15,7 +15,6 @@ #include "emoji.h" #include "message.h" -#include "ftextstream.h" #include "util.h" static struct emojiEntityInfo @@ -1555,21 +1554,20 @@ void EmojiEntityMapper::deleteInstance() * @return the code for the requested Emoji entity name, * in case the requested Emoji item does not exist `-1` is returned. */ -int EmojiEntityMapper::symbol2index(const QCString &symName) const +int EmojiEntityMapper::symbol2index(const std::string &symName) const { - auto it = m_name2symGh.find(symName.str()); + auto it = m_name2symGh.find(symName); return it!=m_name2symGh.end() ? it->second : -1; } /*! * @brief Writes the list of supported emojis to the given file. */ -void EmojiEntityMapper::writeEmojiFile(QFile &file) +void EmojiEntityMapper::writeEmojiFile(std::ostream &t) { - FTextStream t(&file); for (int i = 0; i < g_numEmojiEntities; i++) { - t << g_emojiEntities[i].name << endl; + t << g_emojiEntities[i].name << "\n"; } } diff --git a/src/emoji.h b/src/emoji.h index b27b761..a0184f6 100644 --- a/src/emoji.h +++ b/src/emoji.h @@ -17,10 +17,7 @@ #include <map> #include <string> - -#include <qfile.h> - -class FTextStream; +#include <iostream> /** @brief Singleton helper class to map emoji entities to other formats */ class EmojiEntityMapper @@ -30,8 +27,8 @@ class EmojiEntityMapper static void deleteInstance(); const char *name(int index) const; const char *unicode(int index) const; - void writeEmojiFile(QFile &file); - int symbol2index(const QCString &symName) const; + void writeEmojiFile(std::ostream &t); + int symbol2index(const std::string &symName) const; private: EmojiEntityMapper(); diff --git a/src/entry.cpp b/src/entry.cpp index 6e343b0..9962b3f 100644 --- a/src/entry.cpp +++ b/src/entry.cpp @@ -17,7 +17,6 @@ #include <algorithm> #include <stdlib.h> -#include <qfile.h> #include "entry.h" #include "util.h" #include "section.h" diff --git a/src/entry.h b/src/entry.h index d6c0936..f11870a 100644 --- a/src/entry.h +++ b/src/entry.h @@ -28,7 +28,6 @@ #include "reflist.h" class SectionInfo; -class QFile; class FileDef; /** This class stores information about an inheritance relation diff --git a/src/filedef.cpp b/src/filedef.cpp index 0e357d9..18050dd 100644 --- a/src/filedef.cpp +++ b/src/filedef.cpp @@ -104,7 +104,7 @@ class FileDefImpl : public DefinitionMixin<FileDef> virtual void writeMemberPages(OutputList &ol); virtual void writeQuickMemberLinks(OutputList &ol,const MemberDef *currentMd) const; virtual void writeSummaryLinks(OutputList &ol) const; - virtual void writeTagFile(FTextStream &t); + virtual void writeTagFile(std::ostream &t); virtual void writeSourceHeader(OutputList &ol); virtual void writeSourceBody(OutputList &ol,ClangTUParser *clangParser); virtual void writeSourceFooter(OutputList &ol); @@ -150,7 +150,7 @@ class FileDefImpl : public DefinitionMixin<FileDef> void endMemberDocumentation(OutputList &ol); void writeDetailedDescription(OutputList &ol,const QCString &title); void writeBriefDescription(OutputList &ol); - void writeClassesToTagFile(FTextStream &t,const ClassLinkedRefMap &list); + void writeClassesToTagFile(std::ostream &t,const ClassLinkedRefMap &list); IncludeInfoMap m_includeMap; IncludeInfoList m_includeList; @@ -307,12 +307,12 @@ bool FileDefImpl::hasDetailedDescription() const ); } -void FileDefImpl::writeTagFile(FTextStream &tagFile) +void FileDefImpl::writeTagFile(std::ostream &tagFile) { - tagFile << " <compound kind=\"file\">" << endl; - tagFile << " <name>" << convertToXML(name()) << "</name>" << endl; - tagFile << " <path>" << convertToXML(getPath()) << "</path>" << endl; - tagFile << " <filename>" << convertToXML(getOutputFileBase()) << Doxygen::htmlFileExtension << "</filename>" << endl; + tagFile << " <compound kind=\"file\">\n"; + tagFile << " <name>" << convertToXML(name()) << "</name>\n"; + tagFile << " <path>" << convertToXML(getPath()) << "</path>\n"; + tagFile << " <filename>" << convertToXML(getOutputFileBase()) << Doxygen::htmlFileExtension << "</filename>\n"; for (const auto &ii : m_includeList) { const FileDef *fd=ii.fileDef; @@ -329,8 +329,7 @@ void FileDefImpl::writeTagFile(FTextStream &tagFile) << "local=\"" << locStr << "\" " << "imported=\"" << impStr << "\">" << convertToXML(ii.includeName) - << "</includes>" - << endl; + << "</includes>\n"; } } for (const auto &lde : LayoutDocManager::instance().docEntries(LayoutDocManager::File)) @@ -363,7 +362,7 @@ void FileDefImpl::writeTagFile(FTextStream &tagFile) { if (nd->isLinkableInProject()) { - tagFile << " <namespace>" << convertToXML(nd->name()) << "</namespace>" << endl; + tagFile << " <namespace>" << convertToXML(nd->name()) << "</namespace>\n"; } } } @@ -392,7 +391,7 @@ void FileDefImpl::writeTagFile(FTextStream &tagFile) } writeDocAnchorsToTagFile(tagFile); - tagFile << " </compound>" << endl; + tagFile << " </compound>\n"; } void FileDefImpl::writeDetailedDescription(OutputList &ol,const QCString &title) @@ -514,14 +513,14 @@ void FileDefImpl::writeBriefDescription(OutputList &ol) ol.writeSynopsis(); } -void FileDefImpl::writeClassesToTagFile(FTextStream &tagFile, const ClassLinkedRefMap &list) +void FileDefImpl::writeClassesToTagFile(std::ostream &tagFile, const ClassLinkedRefMap &list) { for (const auto &cd : list) { if (cd->isLinkableInProject()) { tagFile << " <class kind=\"" << cd->compoundTypeString() << - "\">" << convertToXML(cd->name()) << "</class>" << endl; + "\">" << convertToXML(cd->name()) << "</class>\n"; } } } diff --git a/src/filedef.h b/src/filedef.h index 7984a78..b3c38ba 100644 --- a/src/filedef.h +++ b/src/filedef.h @@ -36,7 +36,6 @@ class NamespaceDef; class NamespaceLinkedRefMap; class PackageDef; class DirDef; -class FTextStream; class ClangTUParser; // --- Set of files @@ -155,7 +154,7 @@ class FileDef : public DefinitionMutable, public Definition virtual void writeMemberPages(OutputList &ol) = 0; virtual void writeQuickMemberLinks(OutputList &ol,const MemberDef *currentMd) const = 0; virtual void writeSummaryLinks(OutputList &ol) const = 0; - virtual void writeTagFile(FTextStream &t) = 0; + virtual void writeTagFile(std::ostream &t) = 0; virtual void writeSourceHeader(OutputList &ol) = 0; virtual void writeSourceBody(OutputList &ol,ClangTUParser *clangParser) = 0; diff --git a/src/formula.cpp b/src/formula.cpp index 82bcc3f..1237fbd 100644 --- a/src/formula.cpp +++ b/src/formula.cpp @@ -16,15 +16,12 @@ #include "formula.h" #include "message.h" #include "config.h" -#include "ftextstream.h" #include "util.h" #include "portable.h" #include "image.h" #include "fileinfo.h" #include "dir.h" -#include <qfile.h> - #include <map> #include <vector> #include <string> @@ -73,7 +70,7 @@ FormulaManager &FormulaManager::instance() void FormulaManager::readFormulas(const char *dir,bool doCompare) { - std::ifstream f(std::string(dir)+"/formula.repository"); + std::ifstream f(std::string(dir)+"/formula.repository",std::ifstream::in); if (f.is_open()) { uint formulaCount=0; @@ -105,7 +102,7 @@ void FormulaManager::readFormulas(const char *dir,bool doCompare) formName = formName.substr(0,ei); // keep only the '\_form#<digits>' part if (doCompare) { - int formId = stoi(formName.substr(hi+1)); + int formId = std::stoi(formName.substr(hi+1)); std::string storedFormText = FormulaManager::instance().findFormula(formId); if (storedFormText!=formText) { @@ -154,24 +151,23 @@ void FormulaManager::generateImages(const char *path,Format format,HighDPI hd) c // generate a latex file containing one formula per page. QCString texName="_formulas.tex"; IntVector formulasToGenerate; - QFile f(texName); - if (f.open(IO_WriteOnly)) + std::ofstream t(texName.str(),std::ofstream::out | std::ofstream::binary); + if (t.is_open()) { - FTextStream t(&f); - if (Config_getBool(LATEX_BATCHMODE)) t << "\\batchmode" << endl; - t << "\\documentclass{article}" << endl; - t << "\\usepackage{ifthen}" << endl; - t << "\\usepackage{epsfig}" << endl; // for those who want to include images - t << "\\usepackage[utf8]{inputenc}" << endl; // looks like some older distributions with newunicode package 1.1 need this option. + if (Config_getBool(LATEX_BATCHMODE)) t << "\\batchmode\n"; + t << "\\documentclass{article}\n"; + t << "\\usepackage{ifthen}\n"; + t << "\\usepackage{epsfig}\n"; // for those who want to include images + t << "\\usepackage[utf8]{inputenc}\n"; // looks like some older distributions with newunicode package 1.1 need this option. writeExtraLatexPackages(t); writeLatexSpecialFormulaChars(t); if (!macroFile.isEmpty()) { copyFile(macroFile,stripMacroFile); - t << "\\input{" << stripMacroFile << "}" << endl; + t << "\\input{" << stripMacroFile << "}\n"; } - t << "\\pagestyle{empty}" << endl; - t << "\\begin{document}" << endl; + t << "\\pagestyle{empty}\n"; + t << "\\begin{document}\n"; for (int i=0; i<(int)p->formulas.size(); i++) { QCString resultName; @@ -181,13 +177,13 @@ void FormulaManager::generateImages(const char *path,Format format,HighDPI hd) c if (!fi.exists()) { // we force a pagebreak after each formula - t << p->formulas[i].c_str() << endl << "\\pagebreak\n\n"; + t << p->formulas[i].c_str() << "\n\\pagebreak\n\n"; formulasToGenerate.push_back(i); } Doxygen::indexList->addImageFile(resultName); } - t << "\\end{document}" << endl; - f.close(); + t << "\\end{document}\n"; + t.close(); } if (!formulasToGenerate.empty()) // there are new formulas { @@ -352,30 +348,23 @@ void FormulaManager::generateImages(const char *path,Format format,HighDPI hd) c // read back %s_tmp.eps and replace // bounding box values with x1,y1,x2,y2 and remove the HiResBoundingBox - QFile epsIn(formBase+"_tmp.eps"); - QFile epsOut(formBase+"_tmp_corr.eps"); - if (epsIn.open(IO_ReadOnly) && epsOut.open(IO_WriteOnly)) + std::ifstream epsIn(formBase.str()+"_tmp.eps",std::ifstream::in); + std::ofstream epsOut(formBase.str()+"_tmp_corr.eps",std::ofstream::out); + if (epsIn.is_open() && epsOut.is_open()) { - int maxLineLen=100*1024; - while (!epsIn.atEnd()) + std::string line; + while (getline(epsIn,line)) { - QCString buf(maxLineLen); - FTextStream t(&epsOut); - int numBytes = epsIn.readLine(buf.rawData(),maxLineLen); - if (numBytes>0) + if (line.rfind("%%BoundingBox",0)==0) + { + epsOut << "%%BoundingBox: " << x1 << " " << y1 << " " << x2 << " " << y2 << "\n"; + } + else if (line.rfind("%%HiResBoundingBox",0)==0) // skip this one { - buf.resize(numBytes+1); - if (buf.startsWith("%%BoundingBox")) - { - t << "%%BoundingBox: " << x1 << " " << y1 << " " << x2 << " " << y2 << endl; - } - else if (buf.startsWith("%%HiResBoundingBox")) // skip this one - { - } - else - { - t << buf; - } + } + else + { + epsOut << line << "\n"; } } epsIn.close(); @@ -438,10 +427,9 @@ void FormulaManager::generateImages(const char *path,Format format,HighDPI hd) c // generated images represent (we use this next time to avoid regeneration // of the images, and to avoid forcing the user to delete all images in order // to let a browser refresh the images). - f.setName("formula.repository"); - if (f.open(IO_WriteOnly)) + t.open("formula.repository",std::ofstream::out); + if (t.is_open()) { - FTextStream t(&f); for (int i=0; i<(int)p->formulas.size(); i++) { DisplaySize size = p->getDisplaySize(i); @@ -450,9 +438,9 @@ void FormulaManager::generateImages(const char *path,Format format,HighDPI hd) c { t << "=" << size.width << "x" << size.height; } - t << ":" << p->formulas[i].c_str() << endl; + t << ":" << p->formulas[i].c_str() << "\n"; } - f.close(); + t.close(); } // reset the directory to the original location. Dir::setCurrent(oldDir); @@ -522,36 +510,18 @@ static int determineInkscapeVersion(Dir &thisDir) } } // read version file and determine major version - QFile inkscapeVersionIn(inkscapeVersionFile); - if (inkscapeVersionIn.open(IO_ReadOnly)) + std::ifstream inkscapeVersionIn(inkscapeVersionFile.str(),std::ifstream::in); + if (inkscapeVersionIn.is_open()) { - int maxLineLen=1024; - while (!inkscapeVersionIn.atEnd()) + std::string line; + while (getline(inkscapeVersionIn,line)) { - QCString buf(maxLineLen); - int numBytes = inkscapeVersionIn.readLine(buf.rawData(),maxLineLen); - if (numBytes>0) + size_t dotPos = line.find('.'); + if (line.rfind("Inkscape ",0)==0 && dotPos>0) { - buf.resize(numBytes+1); - int dotPos = buf.find('.'); - if (buf.startsWith("Inkscape ") && dotPos>0) - { - // get major version - bool ok; - int version = buf.mid(9,dotPos-9).toInt(&ok); - if (!ok) - { - Portable::sysTimerStop(); - return -1; - } - inkscapeVersion = version; - break; - } - } - else - { - Portable::sysTimerStop(); - return -1; + // get major version + inkscapeVersion = std::stoi(line.substr(9,dotPos-9)); + break; } } inkscapeVersionIn.close(); diff --git a/src/fortranscanner.l b/src/fortranscanner.l index cf8a0bb..34ca344 100755 --- a/src/fortranscanner.l +++ b/src/fortranscanner.l @@ -56,8 +56,6 @@ #include <assert.h> #include <ctype.h> -#include <qfile.h> - #include "fortranscanner.h" #include "entry.h" #include "message.h" @@ -837,8 +835,8 @@ private { } {ATTR_SPEC}. { /* update yyextra->current yyextra->modifiers when it is an ATTR_SPEC and not a variable name */ /* buyyextra->625519 */ - QChar chr = yytext[(int)yyleng-1]; - if (chr.isLetter() || chr.isDigit() || (chr == '_')) + char chr = yytext[(int)yyleng-1]; + if (isId(chr)) { yyextra->colNr -= (int)yyleng; REJECT; @@ -1177,7 +1175,7 @@ private { <Parameterlist>{ID} { //yyextra->current->type not yet available QCString param = yytext; - // std::cout << "3=========> got parameter " << param << std::endl; + // std::cout << "3=========> got parameter " << param << "\n"; yyextra->current->args += param; Argument arg; arg.name = param; @@ -2428,7 +2426,7 @@ static void addInterface(yyscan_t yyscanner,QCString name, InterfaceType type) static Argument *getParameter(yyscan_t yyscanner,const QCString &name) { struct yyguts_t *yyg = (struct yyguts_t*)yyscanner; - // std::cout<<"addFortranParameter(): "<<name<<" DOCS:"<<(docs.isNull()?QCString("null"):docs)<<std::endl; + // std::cout<<"addFortranParameter(): "<<name<<" DOCS:"<<(docs.isNull()?QCString("null"):docs)<<"\n"; Argument *ret = 0; for (Argument &a:yyextra->current_root->argList) { diff --git a/src/ftextstream.cpp b/src/ftextstream.cpp deleted file mode 100644 index 3038af3..0000000 --- a/src/ftextstream.cpp +++ /dev/null @@ -1,260 +0,0 @@ -#include "ftextstream.h" -#include <qfile.h> - -//---------------------------------------------------------------------------- - -class QGStringBuffer : public QIODevice -{ - public: - QGStringBuffer( QGString* str ); - ~QGStringBuffer(); - bool open( int m ); - void close(); - void flush(); - uint size() const; - int at() const; - bool at( int pos ); - int readBlock( char *, uint) { return -1; } - int writeBlock( const char *p, uint len ); - int getch() { return -1; } - int putch( int ch ); - int ungetch( int ) { return -1; } - - protected: - QGString* m_str; - - private: // Disabled copy constructor and operator= - QGStringBuffer( const QGStringBuffer & ); - QGStringBuffer &operator=( const QGStringBuffer & ); -}; - -QGStringBuffer::QGStringBuffer( QGString* str ) : m_str(str) -{ - //printf("QGStringBuffer::QGStringBuffer(%p)\n",str); -} - -QGStringBuffer::~QGStringBuffer() -{ -} - -bool QGStringBuffer::open( int m ) -{ - if ( !m_str ) - { -#if defined(CHECK_STATE) - qWarning( "QGStringBuffer::open: No string" ); -#endif - return FALSE; - } - if ( isOpen() ) - { // buffer already open -#if defined(CHECK_STATE) - qWarning( "QGStringBuffer::open: Buffer already open" ); -#endif - return FALSE; - } - setMode( m ); - if ( m & IO_Truncate ) - { // truncate buffer - m_str->truncate( 0 ); - } - if ( m & IO_Append ) - { // append to end of buffer - ioIndex = m_str->length(); - } - else - { - ioIndex = 0; - } - setState( IO_Open ); - setStatus( 0 ); - return TRUE; -} - -void QGStringBuffer::close() -{ - if ( isOpen() ) - { - setFlags( IO_Direct ); - ioIndex = 0; - } -} - -void QGStringBuffer::flush() -{ -} - -uint QGStringBuffer::size() const -{ - return m_str ? m_str->length() : 0; -} - -int QGStringBuffer::at() const -{ - return ioIndex; -} - -bool QGStringBuffer::at( int pos ) -{ -#if defined(CHECK_STATE) - if ( !isOpen() ) - { - qWarning( "QGStringBuffer::at: Buffer is not open" ); - return FALSE; - } -#endif - if ( (uint)pos >= m_str->length() ) - { -#if defined(CHECK_RANGE) - qWarning( "QGStringBuffer::at: Index %d out of range", pos ); -#endif - return FALSE; - } - - ioIndex = pos; - return TRUE; -} - -int QGStringBuffer::writeBlock( const char *p, uint len ) -{ - //printf("QGStringBuffer::writeBlock(%p,%d) m_str=%p ioIndex=%d\n",p,len, - // m_str,ioIndex); - m_str->enlarge(ioIndex+len+1); - memcpy(m_str->data()+ioIndex,p,len); - ioIndex+=len; - m_str->data()[ioIndex]='\0'; - m_str->setLen(ioIndex); - return len; -} - -int QGStringBuffer::putch( int ch ) -{ - //printf("QGStringBuffer::putch(%d) m_str=%p ioIndex=%d\n", - // ch,m_str,ioIndex); - m_str->enlarge(ioIndex+2); - m_str->data()[ioIndex] = (char)ch; - ioIndex++; - m_str->data()[ioIndex] = '\0'; - m_str->setLen(ioIndex); - return ch; -} - - -//---------------------------------------------------------------------------- - -FTextStream::FTextStream() -{ - m_dev = 0; - m_owndev = FALSE; -} - -FTextStream::FTextStream( QIODevice *dev ) -{ - m_dev = dev; - m_owndev = FALSE; -} - -FTextStream::FTextStream( QGString *s ) -{ - m_dev = new QGStringBuffer(s); - ((QGStringBuffer*)m_dev)->open( IO_WriteOnly ); - m_owndev = TRUE; -} - -FTextStream::FTextStream( FILE *fh ) -{ - m_dev = new QFile; - ((QFile *)m_dev)->open( IO_WriteOnly, fh); - m_owndev = TRUE; -} - -FTextStream::~FTextStream() -{ - if (m_owndev) delete m_dev; - m_dev = 0; -} - -QIODevice *FTextStream::device() const -{ - return m_dev; -} - -void FTextStream::setDevice( QIODevice *dev ) -{ - if (m_owndev) - { - delete m_dev; - m_owndev = FALSE; - } - m_dev = dev; -} - -void FTextStream::unsetDevice() -{ - setDevice(0); -} - -FTextStream &FTextStream::output_int( ulong n, bool neg ) -{ - char buf[20]; - char *p = &buf[19]; - *p = '\0'; - if ( neg ) - { - n = (ulong)(-(long)n); - } - do - { - *--p = ((int)(n%10)) + '0'; - n /= 10; - } while ( n ); - if ( neg ) *--p = '-'; - return operator<<(p); -} - -FTextStream &FTextStream::operator<<( signed short i ) -{ - return output_int( i, i < 0 ); -} - -FTextStream &FTextStream::operator<<( unsigned short i ) -{ - return output_int( i, FALSE ); -} - -FTextStream &FTextStream::operator<<( signed int i ) -{ - return output_int( i, i < 0 ); -} - -FTextStream &FTextStream::operator<<( unsigned int i ) -{ - return output_int( i, FALSE ); -} - -FTextStream &FTextStream::operator<<( signed long i ) -{ - return output_int( i, i < 0 ); -} - -FTextStream &FTextStream::operator<<( unsigned long i ) -{ - return output_int( i, FALSE ); -} - -FTextStream &FTextStream::operator<<( float f ) -{ - return *this << (double)f; -} - -FTextStream &FTextStream::operator<<( double d ) -{ - char buf[64]; - sprintf(buf,"%f",d); - return *this << buf; -} - - - - - diff --git a/src/ftextstream.h b/src/ftextstream.h deleted file mode 100644 index 8e56174..0000000 --- a/src/ftextstream.h +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef FTEXTSTREAM_H -#define FTEXTSTREAM_H - -#include <stdio.h> - -#include <qiodevice.h> -#include <qgstring.h> - -/** @brief Simplified and optimized version of QTextStream */ -class FTextStream -{ - public: - FTextStream(); - FTextStream( QIODevice * ); - FTextStream( QGString * ); - FTextStream( FILE * ); - virtual ~FTextStream(); - - QIODevice *device() const; - void setDevice( QIODevice * ); - void unsetDevice(); - - FTextStream &operator<<( char ); - FTextStream &operator<<( const char *); - FTextStream &operator<<( const QCString & ); - FTextStream &operator<<( signed short ); - FTextStream &operator<<( unsigned short ); - FTextStream &operator<<( signed int ); - FTextStream &operator<<( unsigned int ); - FTextStream &operator<<( signed long ); - FTextStream &operator<<( unsigned long ); - FTextStream &operator<<( float ); - FTextStream &operator<<( double ); - - private: - QIODevice *m_dev; - bool m_owndev; - FTextStream &output_int( ulong n, bool neg ); - - private: // Disabled copy constructor and operator= -#if defined(Q_DISABLE_COPY) - FTextStream( const FTextStream & ); - FTextStream &operator=( const FTextStream & ); -#endif -}; - -inline FTextStream &FTextStream::operator<<( char c) -{ - if (m_dev) m_dev->putch(c); - return *this; -} - -inline FTextStream &FTextStream::operator<<( const char* s) -{ - uint len = qstrlen( s ); - if (m_dev) m_dev->writeBlock( s, len ); - return *this; -} - -inline FTextStream &FTextStream::operator<<( const QCString &s) -{ - if (m_dev) m_dev->writeBlock( s, s.length() ); - return *this; -} - -typedef FTextStream & (*FTSFUNC)(FTextStream &);// manipulator function - -inline FTextStream &operator<<( FTextStream &s, FTSFUNC f ) -{ return (*f)( s ); } - -inline FTextStream &endl( FTextStream & s) -{ - return s << '\n'; -} - -#endif // FTEXTSTREAM_H diff --git a/src/ftvhelp.cpp b/src/ftvhelp.cpp index 2435cce..572556d 100644 --- a/src/ftvhelp.cpp +++ b/src/ftvhelp.cpp @@ -279,7 +279,7 @@ QCString FTVHelp::generateIndentLabel(FTVNode *n,int level) return result; } -void FTVHelp::generateIndent(FTextStream &t, FTVNode *n,bool opened) +void FTVHelp::generateIndent(std::ostream &t, FTVNode *n,bool opened) { int indent=0; FTVNode *p = n->parent; @@ -299,7 +299,7 @@ void FTVHelp::generateIndent(FTextStream &t, FTVNode *n,bool opened) } } -void FTVHelp::generateLink(FTextStream &t,FTVNode *n) +void FTVHelp::generateLink(std::ostream &t,FTVNode *n) { //printf("FTVHelp::generateLink(ref=%s,file=%s,anchor=%s\n", // n->ref.data(),n->file.data(),n->anchor.data()); @@ -344,7 +344,7 @@ void FTVHelp::generateLink(FTextStream &t,FTVNode *n) } } -static void generateBriefDoc(FTextStream &t,const Definition *def) +static void generateBriefDoc(std::ostream &t,const Definition *def) { QCString brief = def->briefDescription(TRUE); //printf("*** %p: generateBriefDoc(%s)='%s'\n",def,def->name().data(),brief.data()); @@ -383,7 +383,7 @@ static char compoundIcon(const ClassDef *cd) return icon; } -void FTVHelp::generateTree(FTextStream &t, const std::vector<FTVNode*> &nl,int level,int maxLevel,int &index) +void FTVHelp::generateTree(std::ostream &t, const std::vector<FTVNode*> &nl,int level,int maxLevel,int &index) { for (const auto &n : nl) { @@ -437,7 +437,7 @@ void FTVHelp::generateTree(FTextStream &t, const std::vector<FTVNode*> &nl,int l { generateBriefDoc(t,n->def); } - t << "</td></tr>" << endl; + t << "</td></tr>\n"; folderId++; generateTree(t,n->children,level+1,maxLevel,index); } @@ -497,7 +497,7 @@ void FTVHelp::generateTree(FTextStream &t, const std::vector<FTVNode*> &nl,int l { generateBriefDoc(t,n->def); } - t << "</td></tr>" << endl; + t << "</td></tr>\n"; } } } @@ -534,7 +534,7 @@ static bool dupOfParent(const FTVNode *n) return FALSE; } -static void generateJSLink(FTextStream &t,const FTVNode *n) +static void generateJSLink(std::ostream &t,const FTVNode *n) { if (n->file.isEmpty()) // no link { @@ -557,7 +557,7 @@ static QCString convertFileId2Var(const QCString &fileId) return substitute(varId,"-","_"); } -static bool generateJSTree(NavIndexEntryList &navIndex,FTextStream &t, +static bool generateJSTree(NavIndexEntryList &navIndex,std::ostream &t, const std::vector<FTVNode*> &nl,int level,bool &first) { static QCString htmlOutput = Config_getString(HTML_OUTPUT); @@ -567,13 +567,13 @@ static bool generateJSTree(NavIndexEntryList &navIndex,FTextStream &t, for (const auto &n : nl) { // terminate previous entry - if (!first) t << "," << endl; + if (!first) t << ",\n"; first=FALSE; // start entry if (!found) { - t << "[" << endl; + t << "[\n"; } found=TRUE; @@ -615,14 +615,15 @@ static bool generateJSTree(NavIndexEntryList &navIndex,FTextStream &t, { fileId+="_dup"; } - QFile f(htmlOutput+"/"+fileId+".js"); - if (f.open(IO_WriteOnly)) + QCString fileName = htmlOutput+"/"+fileId+".js"; + std::ofstream tt(fileName,std::ofstream::out | std::ofstream::binary); + if (tt.is_open()) { - FTextStream tt(&f); - tt << "var " << convertFileId2Var(fileId) << " =" << endl; + tt << "var " << convertFileId2Var(fileId) << " =\n"; generateJSTree(navIndex,tt,n->children,1,firstChild); - tt << endl << "];"; + tt << "\n];"; } + tt.close(); t << "\"" << fileId << "\" ]"; } else // no children @@ -639,7 +640,7 @@ static bool generateJSTree(NavIndexEntryList &navIndex,FTextStream &t, if (emptySection) t << "null ]"; else - t << endl << indentStr << " ] ]"; + t << "\n" << indentStr << " ] ]"; } } return found; @@ -648,17 +649,16 @@ static bool generateJSTree(NavIndexEntryList &navIndex,FTextStream &t, static void generateJSNavTree(const std::vector<FTVNode*> &nodeList) { QCString htmlOutput = Config_getString(HTML_OUTPUT); - QFile f(htmlOutput+"/navtreedata.js"); + std::ofstream t(htmlOutput.str()+"/navtreedata.js",std::ofstream::out | std::ofstream::binary); NavIndexEntryList navIndex; - if (f.open(IO_WriteOnly) /*&& fidx.open(IO_WriteOnly)*/) + if (t.is_open()) { - //FTextStream tidx(&fidx); - //tidx << "var NAVTREEINDEX =" << endl; - //tidx << "{" << endl; - FTextStream t(&f); + //std::ostream tidx(&fidx); + //tidx << "var NAVTREEINDEX =\n"; + //tidx << "{\n"; t << JAVASCRIPT_LICENSE_TEXT; - t << "var NAVTREE =" << endl; - t << "[" << endl; + t << "var NAVTREE =\n"; + t << "[\n"; t << " [ "; QCString projName = Config_getString(PROJECT_NAME); if (projName.isEmpty()) @@ -688,10 +688,10 @@ static void generateJSNavTree(const std::vector<FTVNode*> &nodeList) generateJSTree(navIndex,t,nodeList,1,first); if (first) - t << "]" << endl; + t << "]\n"; else - t << endl << " ] ]" << endl; - t << "];" << endl << endl; + t << "\n ] ]\n"; + t << "];\n\n"; // write the navigation index (and sub-indices) std::sort(navIndex.begin(),navIndex.end(),[](const auto &n1,const auto &n2) @@ -700,16 +700,13 @@ static void generateJSNavTree(const std::vector<FTVNode*> &nodeList) int subIndex=0; int elemCount=0; const int maxElemCount=250; - //QFile fidx(htmlOutput+"/navtreeindex.js"); - QFile fsidx(htmlOutput+"/navtreeindex0.js"); - if (/*fidx.open(IO_WriteOnly) &&*/ fsidx.open(IO_WriteOnly)) + std::ofstream tsidx(htmlOutput.str()+"/navtreeindex0.js",std::ofstream::out | std::ofstream::binary); + if (tsidx.is_open()) { - //FTextStream tidx(&fidx); - FTextStream tsidx(&fsidx); - t << "var NAVTREEINDEX =" << endl; - t << "[" << endl; - tsidx << "var NAVTREEINDEX" << subIndex << " =" << endl; - tsidx << "{" << endl; + t << "var NAVTREEINDEX =\n"; + t << "[\n"; + tsidx << "var NAVTREEINDEX" << subIndex << " =\n"; + tsidx << "{\n"; first=TRUE; auto it = navIndex.begin(); while (it!=navIndex.end()) @@ -719,7 +716,7 @@ static void generateJSNavTree(const std::vector<FTVNode*> &nodeList) { if (!first) { - t << "," << endl; + t << ",\n"; } else { @@ -730,27 +727,27 @@ static void generateJSNavTree(const std::vector<FTVNode*> &nodeList) tsidx << "\"" << e.url << "\":[" << e.path << "]"; ++it; if (it!=navIndex.end() && elemCount<maxElemCount-1) tsidx << ","; // not last entry - tsidx << endl; + tsidx << "\n"; elemCount++; if (it!=navIndex.end() && elemCount>=maxElemCount) // switch to new sub-index { - tsidx << "};" << endl; + tsidx << "};\n"; elemCount=0; - fsidx.close(); + tsidx.close(); subIndex++; - fsidx.setName(htmlOutput+"/navtreeindex"+QCString().setNum(subIndex)+".js"); - if (!fsidx.open(IO_WriteOnly)) break; - tsidx.setDevice(&fsidx); - tsidx << "var NAVTREEINDEX" << subIndex << " =" << endl; - tsidx << "{" << endl; + QCString fileName = htmlOutput+"/navtreeindex"+QCString().setNum(subIndex)+".js"; + tsidx.open(fileName.str(),std::ofstream::out | std::ofstream::binary); + if (!tsidx.is_open()) break; + tsidx << "var NAVTREEINDEX" << subIndex << " =\n"; + tsidx << "{\n"; } } - tsidx << "};" << endl; - t << endl << "];" << endl; + tsidx << "};\n"; + t << "\n];\n"; } - t << endl << "var SYNCONMSG = '" << theTranslator->trPanelSynchronisationTooltip(FALSE) << "';"; - t << endl << "var SYNCOFFMSG = '" << theTranslator->trPanelSynchronisationTooltip(TRUE) << "';"; + t << "\nvar SYNCONMSG = '" << theTranslator->trPanelSynchronisationTooltip(FALSE) << "';"; + t << "\nvar SYNCOFFMSG = '" << theTranslator->trPanelSynchronisationTooltip(TRUE) << "';"; } ResourceMgr::instance().copyResource("navtree.js",htmlOutput); } @@ -782,7 +779,7 @@ void FTVHelp::generateTreeViewScripts() } // write tree inside page -void FTVHelp::generateTreeViewInline(FTextStream &t) +void FTVHelp::generateTreeViewInline(std::ostream &t) { int preferredNumEntries = Config_getInt(HTML_INDEX_NUM_ENTRIES); t << "<div class=\"directory\">\n"; diff --git a/src/ftvhelp.h b/src/ftvhelp.h index b04247c..11317fd 100644 --- a/src/ftvhelp.h +++ b/src/ftvhelp.h @@ -24,13 +24,12 @@ #ifndef FTVHELP_H #define FTVHELP_H +#include <iostream> #include <vector> #include "index.h" -class QFile; class Definition; struct FTVNode; -class FTextStream; /** A class that generates a dynamic tree view side panel. */ @@ -56,14 +55,14 @@ class FTVHelp : public IndexIntf void addImageFile(const char *) {} void addStyleSheetFile(const char *) {} void generateTreeView(); - void generateTreeViewInline(FTextStream &t); + void generateTreeViewInline(std::ostream &t); static void generateTreeViewImages(); void generateTreeViewScripts(); private: - void generateTree(FTextStream &t,const std::vector<FTVNode*> &nl,int level,int maxLevel,int &index); + void generateTree(std::ostream &t,const std::vector<FTVNode*> &nl,int level,int maxLevel,int &index); QCString generateIndentLabel(FTVNode *n,int level); - void generateIndent(FTextStream &t,FTVNode *n,bool opened); - void generateLink(FTextStream &t,FTVNode *n); + void generateIndent(std::ostream &t,FTVNode *n,bool opened); + void generateLink(std::ostream &t,FTVNode *n); std::vector< std::vector<FTVNode*> > m_indentNodes; int m_indent; bool m_topLevelIndex; diff --git a/src/groupdef.cpp b/src/groupdef.cpp index 095069e..7e6dca4 100644 --- a/src/groupdef.cpp +++ b/src/groupdef.cpp @@ -75,7 +75,7 @@ class GroupDefImpl : public DefinitionMixin<GroupDef> virtual void writeDocumentation(OutputList &ol); virtual void writeMemberPages(OutputList &ol); virtual void writeQuickMemberLinks(OutputList &ol,const MemberDef *currentMd) const; - virtual void writeTagFile(FTextStream &); + virtual void writeTagFile(std::ostream &); virtual size_t numDocMembers() const; virtual bool isLinkableInProject() const; virtual bool isLinkable() const; @@ -597,12 +597,12 @@ void GroupDefImpl::computeAnchors() m_allMemberList.setAnchors(); } -void GroupDefImpl::writeTagFile(FTextStream &tagFile) +void GroupDefImpl::writeTagFile(std::ostream &tagFile) { - tagFile << " <compound kind=\"group\">" << endl; - tagFile << " <name>" << convertToXML(name()) << "</name>" << endl; - tagFile << " <title>" << convertToXML(m_title) << "</title>" << endl; - tagFile << " <filename>" << convertToXML(getOutputFileBase()) << Doxygen::htmlFileExtension << "</filename>" << endl; + tagFile << " <compound kind=\"group\">\n"; + tagFile << " <name>" << convertToXML(name()) << "</name>\n"; + tagFile << " <title>" << convertToXML(m_title) << "</title>\n"; + tagFile << " <filename>" << convertToXML(getOutputFileBase()) << Doxygen::htmlFileExtension << "</filename>\n"; for (const auto &lde : LayoutDocManager::instance().docEntries(LayoutDocManager::Group)) { switch (lde->kind()) @@ -614,7 +614,7 @@ void GroupDefImpl::writeTagFile(FTextStream &tagFile) if (cd->isLinkableInProject()) { tagFile << " <class kind=\"" << cd->compoundTypeString() - << "\">" << convertToXML(cd->name()) << "</class>" << endl; + << "\">" << convertToXML(cd->name()) << "</class>\n"; } } } @@ -626,7 +626,7 @@ void GroupDefImpl::writeTagFile(FTextStream &tagFile) if (nd->isLinkableInProject()) { tagFile << " <namespace>" << convertToXML(nd->name()) - << "</namespace>" << endl; + << "</namespace>\n"; } } } @@ -637,7 +637,7 @@ void GroupDefImpl::writeTagFile(FTextStream &tagFile) { if (fd->isLinkableInProject()) { - tagFile << " <file>" << convertToXML(fd->name()) << "</file>" << endl; + tagFile << " <file>" << convertToXML(fd->name()) << "</file>\n"; } } } @@ -649,7 +649,7 @@ void GroupDefImpl::writeTagFile(FTextStream &tagFile) QCString pageName = pd->getOutputFileBase(); if (pd->isLinkableInProject()) { - tagFile << " <page>" << convertToXML(pageName) << "</page>" << endl; + tagFile << " <page>" << convertToXML(pageName) << "</page>\n"; } } } @@ -660,7 +660,7 @@ void GroupDefImpl::writeTagFile(FTextStream &tagFile) { if (dd->isLinkableInProject()) { - tagFile << " <dir>" << convertToXML(dd->displayName()) << "</dir>" << endl; + tagFile << " <dir>" << convertToXML(dd->displayName()) << "</dir>\n"; } } } @@ -671,7 +671,7 @@ void GroupDefImpl::writeTagFile(FTextStream &tagFile) { if (gd->isVisible()) { - tagFile << " <subgroup>" << convertToXML(gd->name()) << "</subgroup>" << endl; + tagFile << " <subgroup>" << convertToXML(gd->name()) << "</subgroup>\n"; } } } @@ -699,7 +699,7 @@ void GroupDefImpl::writeTagFile(FTextStream &tagFile) } } writeDocAnchorsToTagFile(tagFile); - tagFile << " </compound>" << endl; + tagFile << " </compound>\n"; } void GroupDefImpl::writeDetailedDescription(OutputList &ol,const QCString &title) diff --git a/src/groupdef.h b/src/groupdef.h index 94214c4..2d0dafc 100644 --- a/src/groupdef.h +++ b/src/groupdef.h @@ -42,7 +42,6 @@ class DirDef; class FTVHelp; class Entry; class MemberDef; -class FTextStream; /** A model of a group of symbols. */ class GroupDef : public DefinitionMutable, public Definition @@ -70,7 +69,7 @@ class GroupDef : public DefinitionMutable, public Definition virtual void writeDocumentation(OutputList &ol) = 0; virtual void writeMemberPages(OutputList &ol) = 0; virtual void writeQuickMemberLinks(OutputList &ol,const MemberDef *currentMd) const = 0; - virtual void writeTagFile(FTextStream &) = 0; + virtual void writeTagFile(std::ostream &) = 0; virtual size_t numDocMembers() const = 0; virtual bool isLinkableInProject() const = 0; virtual bool isLinkable() const = 0; diff --git a/src/htags.cpp b/src/htags.cpp index fdde0f3..e59e7c8 100644 --- a/src/htags.cpp +++ b/src/htags.cpp @@ -24,7 +24,6 @@ #include "config.h" #include "portable.h" #include "fileinfo.h" -#include "qdir.h" bool Htags::useHtags = FALSE; @@ -123,16 +122,13 @@ bool Htags::loadFilemap(const QCString &htmlDir) */ if (fi.exists() && fi.isReadable()) { - QFile f(fileMapName); - const int maxlen = 8192; - QCString line(maxlen+1); - line.at(maxlen)='\0'; - if (f.open(IO_ReadOnly)) + std::ifstream f(fileMapName.str(),std::ifstream::in); + if (f.is_open()) { - int len; - while ((len=f.readLine(line.rawData(),maxlen))>0) + std::string lineStr; + while (getline(f,lineStr)) { - line.at(len)='\0'; + QCString line = lineStr; //printf("Read line: %s",line.data()); int sep = line.find('\t'); if (sep!=-1) @@ -145,14 +141,14 @@ bool Htags::loadFilemap(const QCString &htmlDir) //printf("Key/Value=(%s,%s)\n",key.data(),value.data()); } } - return TRUE; + return true; } else { err("file %s cannot be opened\n",fileMapName.data()); } } - return FALSE; + return false; } /*! convert path name into the url in the hypertext generated by htags. diff --git a/src/htmldocvisitor.cpp b/src/htmldocvisitor.cpp index a7d8321..73939a0 100644 --- a/src/htmldocvisitor.cpp +++ b/src/htmldocvisitor.cpp @@ -13,7 +13,6 @@ * */ -#include <qdir.h> #include "htmldocvisitor.h" #include "docparser.h" #include "language.h" @@ -265,7 +264,7 @@ static QCString htmlAttribsToString(const HtmlAttribList &attribs, QCString *pAl //------------------------------------------------------------------------- -HtmlDocVisitor::HtmlDocVisitor(FTextStream &t,CodeOutputInterface &ci, +HtmlDocVisitor::HtmlDocVisitor(std::ostream &t,CodeOutputInterface &ci, const Definition *ctx) : DocVisitor(DocVisitor_Html), m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE), m_ctx(ctx) @@ -472,20 +471,20 @@ void HtmlDocVisitor::visit(DocStyleChange *s) } -static void visitPreCaption(FTextStream &t, DocVerbatim *s) +static void visitPreCaption(std::ostream &t, DocVerbatim *s) { if (s->hasCaption()) { - t << "<div class=\"caption\">" << endl; + t << "<div class=\"caption\">\n"; } } -static void visitPostCaption(FTextStream &t, DocVerbatim *s) +static void visitPostCaption(std::ostream &t, DocVerbatim *s) { if (s->hasCaption()) { - t << "</div>" << endl; + t << "</div>\n"; } } @@ -559,24 +558,25 @@ void HtmlDocVisitor::visit(DocVerbatim *s) dotindex++, ".dot" ); - QFile file(fileName); - if (!file.open(IO_WriteOnly)) + std::ofstream file(fileName.str(),std::ofstream::out | std::ofstream::binary); + if (!file.is_open()) { err("Could not open file %s for writing\n",fileName.data()); } else { - file.writeBlock( s->text(), s->text().length() ); + QCString stext = s->text(); + file.write( stext.data(), stext.length() ); file.close(); - m_t << "<div class=\"dotgraph\">" << endl; + m_t << "<div class=\"dotgraph\">\n"; writeDotFile(fileName,s->relPath(),s->context()); visitPreCaption(m_t, s); visitCaption(this, s->children()); visitPostCaption(m_t, s); - m_t << "</div>" << endl; + m_t << "</div>\n"; - if (Config_getBool(DOT_CLEANUP)) file.remove(); + if (Config_getBool(DOT_CLEANUP)) Dir().remove(fileName.str()); } forceStartParagraph(s); } @@ -592,8 +592,8 @@ void HtmlDocVisitor::visit(DocVerbatim *s) (Config_getString(HTML_OUTPUT)+"/inline_mscgraph_").data(), mscindex++ ); - QFile file(baseName+".msc"); - if (!file.open(IO_WriteOnly)) + std::ofstream file(baseName.str()+".msc",std::ofstream::out | std::ofstream::binary); + if (!file.is_open()) { err("Could not open file %s.msc for writing\n",baseName.data()); } @@ -603,17 +603,17 @@ void HtmlDocVisitor::visit(DocVerbatim *s) text+=s->text(); text+="}"; - file.writeBlock( text, text.length() ); + file.write( text.data(), text.length() ); file.close(); - m_t << "<div class=\"mscgraph\">" << endl; + m_t << "<div class=\"mscgraph\">\n"; writeMscFile(baseName+".msc",s->relPath(),s->context()); visitPreCaption(m_t, s); visitCaption(this, s->children()); visitPostCaption(m_t, s); - m_t << "</div>" << endl; + m_t << "</div>\n"; - if (Config_getBool(DOT_CLEANUP)) file.remove(); + if (Config_getBool(DOT_CLEANUP)) Dir().remove(baseName.str()+".msc"); } forceStartParagraph(s); } @@ -629,12 +629,12 @@ void HtmlDocVisitor::visit(DocVerbatim *s) format = PlantumlManager::PUML_SVG; } QCString baseName = PlantumlManager::instance().writePlantUMLSource(htmlOutput,s->exampleFile(),s->text(),format); - m_t << "<div class=\"plantumlgraph\">" << endl; + m_t << "<div class=\"plantumlgraph\">\n"; writePlantUMLFile(baseName,s->relPath(),s->context()); visitPreCaption(m_t, s); visitCaption(this, s->children()); visitPostCaption(m_t, s); - m_t << "</div>" << endl; + m_t << "</div>\n"; forceStartParagraph(s); } break; @@ -828,7 +828,7 @@ void HtmlDocVisitor::visit(DocIncOperator *op) } else { - if (!m_hide) m_t << endl; + if (!m_hide) m_t << "\n"; } } @@ -839,7 +839,7 @@ void HtmlDocVisitor::visit(DocFormula *f) if (bDisplay) { forceEndParagraph(f); - m_t << "<p class=\"formulaDsp\">" << endl; + m_t << "<p class=\"formulaDsp\">\n"; } if (Config_getBool(USE_MATHJAX)) @@ -888,7 +888,7 @@ void HtmlDocVisitor::visit(DocFormula *f) } if (bDisplay) { - m_t << endl << "</p>" << endl; + m_t << "\n</p>\n"; forceStartParagraph(f); } } @@ -911,8 +911,8 @@ void HtmlDocVisitor::visit(DocIndexEntry *e) void HtmlDocVisitor::visit(DocSimpleSectSep *) { - m_t << "</dd>" << endl; - m_t << "<dd>" << endl; + m_t << "</dd>\n"; + m_t << "<dd>\n"; } void HtmlDocVisitor::visit(DocCite *cite) @@ -1437,7 +1437,7 @@ void HtmlDocVisitor::visitPre(DocSection *s) forceEndParagraph(s); m_t << "<h" << s->level() << ">"; m_t << "<a class=\"anchor\" id=\"" << s->anchor(); - m_t << "\"></a>" << endl; + m_t << "\"></a>\n"; filter(convertCharEntitiesToUTF8(s->title().data())); m_t << "</h" << s->level() << ">\n"; } @@ -1608,7 +1608,7 @@ void HtmlDocVisitor::visitPre(DocInternal *) { if (m_hide) return; //forceEndParagraph(i); - //m_t << "<p><b>" << theTranslator->trForInternalUseOnly() << "</b></p>" << endl; + //m_t << "<p><b>" << theTranslator->trForInternalUseOnly() << "</b></p>\n"; } void HtmlDocVisitor::visitPost(DocInternal *) @@ -1671,7 +1671,7 @@ void HtmlDocVisitor::visitPre(DocImage *img) { baseName=baseName.right(baseName.length()-i-1); } - if (!inlineImage) m_t << "<div class=\"image\">" << endl; + if (!inlineImage) m_t << "<div class=\"image\">\n"; QCString sizeAttribs; if (!img->width().isEmpty()) { @@ -1713,7 +1713,7 @@ void HtmlDocVisitor::visitPre(DocImage *img) } else { - m_t << ">" << alt << "</object>" << endl; + m_t << ">" << alt << "</object>\n"; } } else @@ -1736,7 +1736,7 @@ void HtmlDocVisitor::visitPre(DocImage *img) } else { - m_t << "<div class=\"caption\">" << endl; + m_t << "<div class=\"caption\">\n"; } } else if (inlineImage) @@ -1770,7 +1770,7 @@ void HtmlDocVisitor::visitPost(DocImage *img) } if (!inlineImage) // end <div class="image"> { - m_t << "</div>" << endl; + m_t << "</div>\n"; forceStartParagraph(img); } } @@ -1783,11 +1783,11 @@ void HtmlDocVisitor::visitPost(DocImage *img) void HtmlDocVisitor::visitPre(DocDotFile *df) { if (m_hide) return; - m_t << "<div class=\"dotgraph\">" << endl; + m_t << "<div class=\"dotgraph\">\n"; writeDotFile(df->file(),df->relPath(),df->context()); if (df->hasCaption()) { - m_t << "<div class=\"caption\">" << endl; + m_t << "<div class=\"caption\">\n"; } } @@ -1796,19 +1796,19 @@ void HtmlDocVisitor::visitPost(DocDotFile *df) if (m_hide) return; if (df->hasCaption()) { - m_t << "</div>" << endl; + m_t << "</div>\n"; } - m_t << "</div>" << endl; + m_t << "</div>\n"; } void HtmlDocVisitor::visitPre(DocMscFile *df) { if (m_hide) return; - m_t << "<div class=\"mscgraph\">" << endl; + m_t << "<div class=\"mscgraph\">\n"; writeMscFile(df->file(),df->relPath(),df->context()); if (df->hasCaption()) { - m_t << "<div class=\"caption\">" << endl; + m_t << "<div class=\"caption\">\n"; } } void HtmlDocVisitor::visitPost(DocMscFile *df) @@ -1816,19 +1816,19 @@ void HtmlDocVisitor::visitPost(DocMscFile *df) if (m_hide) return; if (df->hasCaption()) { - m_t << "</div>" << endl; + m_t << "</div>\n"; } - m_t << "</div>" << endl; + m_t << "</div>\n"; } void HtmlDocVisitor::visitPre(DocDiaFile *df) { if (m_hide) return; - m_t << "<div class=\"diagraph\">" << endl; + m_t << "<div class=\"diagraph\">\n"; writeDiaFile(df->file(),df->relPath(),df->context()); if (df->hasCaption()) { - m_t << "<div class=\"caption\">" << endl; + m_t << "<div class=\"caption\">\n"; } } void HtmlDocVisitor::visitPost(DocDiaFile *df) @@ -1836,9 +1836,9 @@ void HtmlDocVisitor::visitPost(DocDiaFile *df) if (m_hide) return; if (df->hasCaption()) { - m_t << "</div>" << endl; + m_t << "</div>\n"; } - m_t << "</div>" << endl; + m_t << "</div>\n"; } void HtmlDocVisitor::visitPre(DocLink *lnk) @@ -1890,15 +1890,15 @@ void HtmlDocVisitor::visitPre(DocSecRefList *s) { if (m_hide) return; forceEndParagraph(s); - m_t << "<div>" << endl; - m_t << "<ul class=\"multicol\">" << endl; + m_t << "<div>\n"; + m_t << "<ul class=\"multicol\">\n"; } void HtmlDocVisitor::visitPost(DocSecRefList *s) { if (m_hide) return; - m_t << "</ul>" << endl; - m_t << "</div>" << endl; + m_t << "</ul>\n"; + m_t << "</div>\n"; forceStartParagraph(s); } @@ -1931,16 +1931,16 @@ void HtmlDocVisitor::visitPre(DocParamSect *s) } m_t << "<dl class=\"" << className << "\"><dt>"; m_t << heading; - m_t << "</dt><dd>" << endl; - m_t << " <table class=\"" << className << "\">" << endl; + m_t << "</dt><dd>\n"; + m_t << " <table class=\"" << className << "\">\n"; } void HtmlDocVisitor::visitPost(DocParamSect *s) { if (m_hide) return; - m_t << " </table>" << endl; - m_t << " </dd>" << endl; - m_t << "</dl>" << endl; + m_t << " </table>\n"; + m_t << " </dd>\n"; + m_t << "</dl>\n"; forceStartParagraph(s); } @@ -2017,7 +2017,7 @@ void HtmlDocVisitor::visitPost(DocParamList *) { //printf("DocParamList::visitPost\n"); if (m_hide) return; - m_t << "</td></tr>" << endl; + m_t << "</td></tr>\n"; } void HtmlDocVisitor::visitPre(DocXRefItem *x) @@ -2047,7 +2047,7 @@ void HtmlDocVisitor::visitPost(DocXRefItem *x) { if (m_hide) return; if (x->title().isEmpty()) return; - m_t << "</dd></dl>" << endl; + m_t << "</dd></dl>\n"; forceStartParagraph(x); } @@ -2083,7 +2083,7 @@ void HtmlDocVisitor::visitPre(DocHtmlBlockQuote *b) void HtmlDocVisitor::visitPost(DocHtmlBlockQuote *b) { if (m_hide) return; - m_t << "</blockquote>" << endl; + m_t << "</blockquote>\n"; forceStartParagraph(b); } @@ -2295,7 +2295,7 @@ void HtmlDocVisitor::writeDiaFile(const QCString &fileName, QCString outDir = Config_getString(HTML_OUTPUT); writeDiaGraphFromFile(fileName,outDir,baseName,DIA_BITMAP); - m_t << "<img src=\"" << relPath << baseName << ".png" << "\" />" << endl; + m_t << "<img src=\"" << relPath << baseName << ".png" << "\" />\n"; } void HtmlDocVisitor::writePlantUMLFile(const QCString &fileName, @@ -2317,15 +2317,15 @@ void HtmlDocVisitor::writePlantUMLFile(const QCString &fileName, if (imgExt=="svg") { PlantumlManager::instance().generatePlantUMLOutput(fileName,outDir,PlantumlManager::PUML_SVG); - //m_t << "<iframe scrolling=\"no\" frameborder=\"0\" src=\"" << relPath << baseName << ".svg" << "\" />" << endl; + //m_t << "<iframe scrolling=\"no\" frameborder=\"0\" src=\"" << relPath << baseName << ".svg" << "\" />\n"; //m_t << "<p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p>"; - //m_t << "</iframe>" << endl; - m_t << "<object type=\"image/svg+xml\" data=\"" << relPath << baseName << ".svg\"></object>" << endl; + //m_t << "</iframe>\n"; + m_t << "<object type=\"image/svg+xml\" data=\"" << relPath << baseName << ".svg\"></object>\n"; } else { PlantumlManager::instance().generatePlantUMLOutput(fileName,outDir,PlantumlManager::PUML_BITMAP); - m_t << "<img src=\"" << relPath << baseName << ".png" << "\" />" << endl; + m_t << "<img src=\"" << relPath << baseName << ".png" << "\" />\n"; } } diff --git a/src/htmldocvisitor.h b/src/htmldocvisitor.h index 084482e..44e1597 100644 --- a/src/htmldocvisitor.h +++ b/src/htmldocvisitor.h @@ -22,14 +22,13 @@ class Definition; class MemberDef; class DocNode; -class FTextStream; class CodeOutputInterface; /*! @brief Concrete visitor implementation for HTML output. */ class HtmlDocVisitor : public DocVisitor { public: - HtmlDocVisitor(FTextStream &t,CodeOutputInterface &ci,const Definition *ctx); + HtmlDocVisitor(std::ostream &t,CodeOutputInterface &ci,const Definition *ctx); //-------------------------------------- // visitor functions for leaf nodes @@ -157,7 +156,7 @@ class HtmlDocVisitor : public DocVisitor // state variables //-------------------------------------- - FTextStream &m_t; + std::ostream &m_t; CodeOutputInterface &m_ci; bool m_insidePre; bool m_hide; diff --git a/src/htmlentity.cpp b/src/htmlentity.cpp index 29ff6e3..f5ddd6f 100644 --- a/src/htmlentity.cpp +++ b/src/htmlentity.cpp @@ -15,7 +15,6 @@ #include "htmlentity.h" #include "message.h" -#include "ftextstream.h" //! Number of doxygen commands mapped as if it were HTML entities static const int g_numberHtmlMappedCmds = 11; @@ -474,7 +473,7 @@ DocSymbol::SymType HtmlEntityMapper::name2sym(const QCString &symName) const return it!=m_name2sym.end() ? it->second : DocSymbol::Sym_Unknown; } -void HtmlEntityMapper::writeXMLSchema(FTextStream &t) +void HtmlEntityMapper::writeXMLSchema(std::ostream &t) { for (int i=0;i<g_numHtmlEntities - g_numberHtmlMappedCmds;i++) { diff --git a/src/htmlentity.h b/src/htmlentity.h index 5337280..7d0a822 100644 --- a/src/htmlentity.h +++ b/src/htmlentity.h @@ -17,11 +17,10 @@ #include <unordered_map> #include <string> +#include <iostream> #include "docparser.h" -class FTextStream; - /** @brief Singleton helper class to map html entities to other formats */ class HtmlEntityMapper { @@ -37,7 +36,7 @@ class HtmlEntityMapper const char *man(DocSymbol::SymType symb) const; const char *rtf(DocSymbol::SymType symb) const; const DocSymbol::PerlSymb *perl(DocSymbol::SymType symb) const; - void writeXMLSchema(FTextStream &t); + void writeXMLSchema(std::ostream &t); private: void validate(); HtmlEntityMapper(); diff --git a/src/htmlgen.cpp b/src/htmlgen.cpp index 79bda74..2a7155a 100644 --- a/src/htmlgen.cpp +++ b/src/htmlgen.cpp @@ -1,8 +1,6 @@ /****************************************************************************** * - * - * - * Copyright (C) 1997-2015 by Dimitri van Heesch. + * Copyright (C) 1997-2021 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its * documentation under the terms of the GNU General Public License is hereby @@ -19,6 +17,7 @@ #include <assert.h> #include <mutex> +#include <sstream> #include "message.h" #include "htmlgen.h" @@ -64,11 +63,12 @@ static const char *hex="0123456789ABCDEF"; // note: this is only active if DISABLE_INDEX=YES, if DISABLE_INDEX is disabled, this // part will be rendered inside menu.js -static void writeClientSearchBox(FTextStream &t,const char *relPath) +static void writeClientSearchBox(std::ostream &t,const char *relPath) { + const char *rp = relPath ? relPath : ""; t << " <div id=\"MSearchBox\" class=\"MSearchBoxInactive\">\n"; t << " <span class=\"left\">\n"; - t << " <img id=\"MSearchSelect\" src=\"" << relPath << "search/mag_sel.svg\"\n"; + t << " <img id=\"MSearchSelect\" src=\"" << rp << "search/mag_sel.svg\"\n"; t << " onmouseover=\"return searchBox.OnSearchSelectShow()\"\n"; t << " onmouseout=\"return searchBox.OnSearchSelectHide()\"\n"; t << " alt=\"\"/>\n"; @@ -79,19 +79,20 @@ static void writeClientSearchBox(FTextStream &t,const char *relPath) t << " onkeyup=\"searchBox.OnSearchFieldChange(event)\"/>\n"; t << " </span><span class=\"right\">\n"; t << " <a id=\"MSearchClose\" href=\"javascript:searchBox.CloseResultsWindow()\">" - << "<img id=\"MSearchCloseImg\" border=\"0\" src=\"" << relPath << "search/close.svg\" alt=\"\"/></a>\n"; + << "<img id=\"MSearchCloseImg\" border=\"0\" src=\"" << rp << "search/close.svg\" alt=\"\"/></a>\n"; t << " </span>\n"; t << " </div>\n"; } // note: this is only active if DISABLE_INDEX=YES. if DISABLE_INDEX is disabled, this // part will be rendered inside menu.js -static void writeServerSearchBox(FTextStream &t,const char *relPath,bool highlightSearch) +static void writeServerSearchBox(std::ostream &t,const char *relPath,bool highlightSearch) { + const char *rp = relPath ? relPath : ""; bool externalSearch = Config_getBool(EXTERNAL_SEARCH); t << " <div id=\"MSearchBox\" class=\"MSearchBoxInactive\">\n"; t << " <div class=\"left\">\n"; - t << " <form id=\"FSearchBox\" action=\"" << relPath; + t << " <form id=\"FSearchBox\" action=\"" << rp; if (externalSearch) { t << "search" << Doxygen::htmlFileExtension; @@ -101,7 +102,7 @@ static void writeServerSearchBox(FTextStream &t,const char *relPath,bool highlig t << "search.php"; } t << "\" method=\"get\">\n"; - t << " <img id=\"MSearchSelect\" src=\"" << relPath << "search/mag.svg\" alt=\"\"/>\n"; + t << " <img id=\"MSearchSelect\" src=\"" << rp << "search/mag.svg\" alt=\"\"/>\n"; if (!highlightSearch) { t << " <input type=\"text\" id=\"MSearchField\" name=\"query\" value=\"" @@ -299,8 +300,7 @@ static QCString getConvertLatexMacro() static QCString getSearchBox(bool serverSide, QCString relPath, bool highlightSearch) { - QGString result; - FTextStream t(&result); + std::stringstream t; if (serverSide) { writeServerSearchBox(t, relPath, highlightSearch); @@ -309,7 +309,7 @@ static QCString getSearchBox(bool serverSide, QCString relPath, bool highlightSe { writeClientSearchBox(t, relPath); } - return QCString(result); + return t.str(); } static QCString substituteHtmlKeywords(const QCString &str, @@ -510,20 +510,20 @@ static QCString substituteHtmlKeywords(const QCString &str, //-------------------------------------------------------------------------- -HtmlCodeGenerator::HtmlCodeGenerator() +HtmlCodeGenerator::HtmlCodeGenerator() : m_t(nullptr) { } -HtmlCodeGenerator::HtmlCodeGenerator(FTextStream &t,const QCString &relPath) - : m_relPath(relPath) +HtmlCodeGenerator::HtmlCodeGenerator(std::ostream &t,const QCString &relPath) + : m_t(nullptr), m_relPath(relPath) { setTextStream(t); } -void HtmlCodeGenerator::setTextStream(FTextStream &t) +void HtmlCodeGenerator::setTextStream(std::ostream &t) { - m_streamSet = t.device()!=0; - m_t.setDevice(t.device()); + m_t.rdbuf(t.rdbuf()); + m_streamSet=true; } void HtmlCodeGenerator::setRelativePath(const QCString &path) @@ -785,7 +785,7 @@ void HtmlCodeGenerator::writeTooltip(const char *id, const DocLinkInfo &docInfo, } m_t << "</div>"; } - m_t << "</div>" << endl; + m_t << "</div>\n"; } @@ -936,15 +936,14 @@ void HtmlGenerator::init() } { - QFile f(dname+"/dynsections.js"); - if (f.open(IO_WriteOnly)) + std::ofstream t(dname+"/dynsections.js",std::ofstream::out); + if (t.is_open()) { - FTextStream t(&f); t << mgr.getAsString("dynsections.js"); if (Config_getBool(SOURCE_BROWSER) && Config_getBool(SOURCE_TOOLTIPS)) { - t << endl << - "$(document).ready(function() {\n" + t << + "\n$(document).ready(function() {\n" " $('.code,.codeRef').each(function() {\n" " $(this).data('powertip',$('#a'+$(this).attr('href').replace(/.*\\//,'').replace(/[^a-z_A-Z0-9]/g,'_')).html());\n" " $(this).powerTip({ placement: 's', smartPlacement: true, mouseOnToPopup: true });\n" @@ -1011,10 +1010,9 @@ void HtmlGenerator::writeSearchData(const char *dname) } QCString searchDirName = dname; - QFile f(searchDirName+"/search.css"); - if (f.open(IO_WriteOnly)) + std::ofstream t(searchDirName.str()+"/search.css",std::ofstream::out); + if (t.is_open()) { - FTextStream t(&f); QCString searchCss; if (Config_getBool(DISABLE_INDEX)) { @@ -1034,23 +1032,20 @@ void HtmlGenerator::writeSearchData(const char *dname) } } -void HtmlGenerator::writeStyleSheetFile(QFile &file) +void HtmlGenerator::writeStyleSheetFile(std::ostream &t) { - FTextStream t(&file); t << replaceColorMarkers(substitute(ResourceMgr::instance().getAsString("doxygen.css"),"$doxygenversion",getDoxygenVersion())); } -void HtmlGenerator::writeHeaderFile(QFile &file, const char * /*cssname*/) +void HtmlGenerator::writeHeaderFile(std::ostream &t, const char * /*cssname*/) { - FTextStream t(&file); - t << "<!-- HTML header for doxygen " << getDoxygenVersion() << "-->" << endl; + t << "<!-- HTML header for doxygen " << getDoxygenVersion() << "-->\n"; t << ResourceMgr::instance().getAsString("header.html"); } -void HtmlGenerator::writeFooterFile(QFile &file) +void HtmlGenerator::writeFooterFile(std::ostream &t) { - FTextStream t(&file); - t << "<!-- HTML footer for doxygen " << getDoxygenVersion() << "-->" << endl; + t << "<!-- HTML footer for doxygen " << getDoxygenVersion() << "-->\n"; t << ResourceMgr::instance().getAsString("footer.html"); } @@ -1077,7 +1072,7 @@ void HtmlGenerator::startFile(const char *name,const char *, t << substituteHtmlKeywords(g_header,convertToHtml(filterTitle(title?title:"")),m_relPath); t << "<!-- " << theTranslator->trGeneratedBy() << " Doxygen " - << getDoxygenVersion() << " -->" << endl; + << getDoxygenVersion() << " -->\n"; //bool generateTreeView = Config_getBool(GENERATE_TREEVIEW); bool searchEngine = Config_getBool(SEARCHENGINE); if (searchEngine /*&& !generateTreeView*/) @@ -1093,7 +1088,7 @@ void HtmlGenerator::startFile(const char *name,const char *, m_sectionCount=0; } -void HtmlGenerator::writeSearchInfo(FTextStream &t,const QCString &) +void HtmlGenerator::writeSearchInfo(std::ostream &t,const QCString &) { bool searchEngine = Config_getBool(SEARCHENGINE); bool serverBasedSearch = Config_getBool(SERVER_BASED_SEARCH); @@ -1151,7 +1146,7 @@ void HtmlGenerator::writeLogo() t << writeLogoAsString(m_relPath); } -void HtmlGenerator::writePageFooter(FTextStream &t,const QCString &lastTitle, +void HtmlGenerator::writePageFooter(std::ostream &t,const QCString &lastTitle, const QCString &relPath,const QCString &navPath) { t << substituteHtmlKeywords(g_footer,convertToHtml(lastTitle),relPath,navPath); @@ -1188,8 +1183,8 @@ void HtmlGenerator::writeStyleInfo(int part) startPlainFile("doxygen.css"); // alternative, cooler looking titles - //t << "H1 { text-align: center; border-width: thin none thin none;" << endl; - //t << " border-style : double; border-color : blue; padding-left : 1em; padding-right : 1em }" << endl; + //t << "H1 { text-align: center; border-width: thin none thin none;\n"; + //t << " border-style : double; border-color : blue; padding-left : 1em; padding-right : 1em }\n"; t << replaceColorMarkers(substitute(ResourceMgr::instance().getAsString("doxygen.css"),"$doxygenversion",getDoxygenVersion())); endPlainFile(); @@ -1249,20 +1244,20 @@ void HtmlGenerator::endDoxyAnchor(const char *,const char *) //void HtmlGenerator::newParagraph() //{ -// t << endl << "<p>" << endl; +// t << "\n<p>\n"; //} void HtmlGenerator::startParagraph(const char *classDef) { if (classDef) - t << endl << "<p class=\"" << classDef << "\">"; + t << "\n<p class=\"" << classDef << "\">"; else - t << endl << "<p>"; + t << "\n<p>"; } void HtmlGenerator::endParagraph() { - t << "</p>" << endl; + t << "</p>\n"; } void HtmlGenerator::writeString(const char *text) @@ -1277,7 +1272,7 @@ void HtmlGenerator::startIndexListItem() void HtmlGenerator::endIndexListItem() { - t << "</li>" << endl; + t << "</li>\n"; } void HtmlGenerator::startIndexItem(const char *ref,const char *f) @@ -1397,15 +1392,15 @@ void HtmlGenerator::endGroupHeader(int extraIndentLevel) { if (extraIndentLevel==2) { - t << "</h4>" << endl; + t << "</h4>\n"; } else if (extraIndentLevel==1) { - t << "</h3>" << endl; + t << "</h3>\n"; } else { - t << "</h2>" << endl; + t << "</h2>\n"; } } @@ -1485,7 +1480,7 @@ void HtmlGenerator::writeChar(char c) //--- helper function for dynamic sections ------------------------- -static void startSectionHeader(FTextStream &t, +static void startSectionHeader(std::ostream &t, const QCString &relPath,int sectionCount) { //t << "<!-- startSectionHeader -->"; @@ -1495,23 +1490,23 @@ static void startSectionHeader(FTextStream &t, t << "<div id=\"dynsection-" << sectionCount << "\" " "onclick=\"return toggleVisibility(this)\" " "class=\"dynheader closed\" " - "style=\"cursor:pointer;\">" << endl; + "style=\"cursor:pointer;\">\n"; t << " <img id=\"dynsection-" << sectionCount << "-trigger\" src=\"" << relPath << "closed.png\" alt=\"+\"/> "; } else { - t << "<div class=\"dynheader\">" << endl; + t << "<div class=\"dynheader\">\n"; } } -static void endSectionHeader(FTextStream &t) +static void endSectionHeader(std::ostream &t) { //t << "<!-- endSectionHeader -->"; - t << "</div>" << endl; + t << "</div>\n"; } -static void startSectionSummary(FTextStream &t,int sectionCount) +static void startSectionSummary(std::ostream &t,int sectionCount) { //t << "<!-- startSectionSummary -->"; bool dynamicSections = Config_getBool(HTML_DYNAMIC_SECTIONS); @@ -1519,21 +1514,21 @@ static void startSectionSummary(FTextStream &t,int sectionCount) { t << "<div id=\"dynsection-" << sectionCount << "-summary\" " "class=\"dynsummary\" " - "style=\"display:block;\">" << endl; + "style=\"display:block;\">\n"; } } -static void endSectionSummary(FTextStream &t) +static void endSectionSummary(std::ostream &t) { //t << "<!-- endSectionSummary -->"; bool dynamicSections = Config_getBool(HTML_DYNAMIC_SECTIONS); if (dynamicSections) { - t << "</div>" << endl; + t << "</div>\n"; } } -static void startSectionContent(FTextStream &t,int sectionCount) +static void startSectionContent(std::ostream &t,int sectionCount) { //t << "<!-- startSectionContent -->"; bool dynamicSections = Config_getBool(HTML_DYNAMIC_SECTIONS); @@ -1541,18 +1536,18 @@ static void startSectionContent(FTextStream &t,int sectionCount) { t << "<div id=\"dynsection-" << sectionCount << "-content\" " "class=\"dyncontent\" " - "style=\"display:none;\">" << endl; + "style=\"display:none;\">\n"; } else { - t << "<div class=\"dyncontent\">" << endl; + t << "<div class=\"dyncontent\">\n"; } } -static void endSectionContent(FTextStream &t) +static void endSectionContent(std::ostream &t) { //t << "<!-- endSectionContent -->"; - t << "</div>" << endl; + t << "</div>\n"; } //---------------------------- @@ -1565,32 +1560,30 @@ void HtmlGenerator::startClassDiagram() void HtmlGenerator::endClassDiagram(const ClassDiagram &d, const char *fileName,const char *name) { - QGString result; - FTextStream tt(&result); - endSectionHeader(t); startSectionSummary(t,m_sectionCount); endSectionSummary(t); startSectionContent(t,m_sectionCount); + std::stringstream tt; d.writeImage(tt,dir(),m_relPath,fileName); - if (!result.isEmpty()) + if (tt.tellg()>0) { - t << " <div class=\"center\">" << endl; + t << " <div class=\"center\">\n"; t << " <img src=\""; t << m_relPath << fileName << ".png\" usemap=\"#" << convertToId(name); - t << "_map\" alt=\"\"/>" << endl; + t << "_map\" alt=\"\"/>\n"; t << " <map id=\"" << convertToId(name); t << "_map\" name=\"" << convertToId(name); - t << "_map\">" << endl; - t << result; - t << " </map>" << endl; + t << "_map\">\n"; + t << tt.str(); + t << " </map>\n"; t << "</div>"; } else { - t << " <div class=\"center\">" << endl; + t << " <div class=\"center\">\n"; t << " <img src=\""; - t << m_relPath << fileName << ".png\" alt=\"\"/>" << endl; + t << m_relPath << fileName << ".png\" alt=\"\"/>\n"; t << " </div>"; } endSectionContent(t); @@ -1600,12 +1593,12 @@ void HtmlGenerator::endClassDiagram(const ClassDiagram &d, void HtmlGenerator::startMemberList() { - DBG_HTML(t << "<!-- startMemberList -->" << endl) + DBG_HTML(t << "<!-- startMemberList -->\n") } void HtmlGenerator::endMemberList() { - DBG_HTML(t << "<!-- endMemberList -->" << endl) + DBG_HTML(t << "<!-- endMemberList -->\n") } // anonymous type: @@ -1614,13 +1607,13 @@ void HtmlGenerator::endMemberList() // 2 = single column left aligned void HtmlGenerator::startMemberItem(const char *anchor,int annoType,const char *inheritId) { - DBG_HTML(t << "<!-- startMemberItem() -->" << endl) + DBG_HTML(t << "<!-- startMemberItem() -->\n") if (m_emptySection) { - t << "<table class=\"memberdecls\">" << endl; + t << "<table class=\"memberdecls\">\n"; m_emptySection=FALSE; } - t << "<tr class=\"memitem:" << anchor; + t << "<tr class=\"memitem:" << (anchor?anchor:""); if (inheritId) { t << " inherit " << inheritId; @@ -1631,8 +1624,7 @@ void HtmlGenerator::startMemberItem(const char *anchor,int annoType,const char * void HtmlGenerator::endMemberItem() { - t << "</td></tr>"; - t << endl; + t << "</td></tr>\n"; } void HtmlGenerator::startMemberTemplateParams() @@ -1641,8 +1633,8 @@ void HtmlGenerator::startMemberTemplateParams() void HtmlGenerator::endMemberTemplateParams(const char *anchor,const char *inheritId) { - t << "</td></tr>" << endl; - t << "<tr class=\"memitem:" << anchor; + t << "</td></tr>\n"; + t << "<tr class=\"memitem:" << (anchor?anchor:""); if (inheritId) { t << " inherit " << inheritId; @@ -1653,7 +1645,7 @@ void HtmlGenerator::endMemberTemplateParams(const char *anchor,const char *inher void HtmlGenerator::insertMemberAlign(bool templ) { - DBG_HTML(t << "<!-- insertMemberAlign -->" << endl) + DBG_HTML(t << "<!-- insertMemberAlign -->\n") QCString className = templ ? "memTemplItemRight" : "memItemRight"; t << " </td><td class=\"" << className << "\" valign=\"bottom\">"; } @@ -1672,13 +1664,13 @@ void HtmlGenerator::insertMemberAlignLeft(int annoType, bool initTag) void HtmlGenerator::startMemberDescription(const char *anchor,const char *inheritId, bool typ) { - DBG_HTML(t << "<!-- startMemberDescription -->" << endl) + DBG_HTML(t << "<!-- startMemberDescription -->\n") if (m_emptySection) { - t << "<table class=\"memberdecls\">" << endl; + t << "<table class=\"memberdecls\">\n"; m_emptySection=FALSE; } - t << "<tr class=\"memdesc:" << anchor; + t << "<tr class=\"memdesc:" << (anchor?anchor:""); if (inheritId) { t << " inherit " << inheritId; @@ -1691,13 +1683,13 @@ void HtmlGenerator::startMemberDescription(const char *anchor,const char *inheri void HtmlGenerator::endMemberDescription() { - DBG_HTML(t << "<!-- endMemberDescription -->" << endl) - t << "<br /></td></tr>" << endl; + DBG_HTML(t << "<!-- endMemberDescription -->\n") + t << "<br /></td></tr>\n"; } void HtmlGenerator::startMemberSections() { - DBG_HTML(t << "<!-- startMemberSections -->" << endl) + DBG_HTML(t << "<!-- startMemberSections -->\n") m_emptySection=TRUE; // we postpone writing <table> until we actually // write a row to prevent empty tables, which // are not valid XHTML! @@ -1705,16 +1697,16 @@ void HtmlGenerator::startMemberSections() void HtmlGenerator::endMemberSections() { - DBG_HTML(t << "<!-- endMemberSections -->" << endl) + DBG_HTML(t << "<!-- endMemberSections -->\n") if (!m_emptySection) { - t << "</table>" << endl; + t << "</table>\n"; } } void HtmlGenerator::startMemberHeader(const char *anchor, int typ) { - DBG_HTML(t << "<!-- startMemberHeader -->" << endl) + DBG_HTML(t << "<!-- startMemberHeader -->\n") if (!m_emptySection) { t << "</table>"; @@ -1722,42 +1714,42 @@ void HtmlGenerator::startMemberHeader(const char *anchor, int typ) } if (m_emptySection) { - t << "<table class=\"memberdecls\">" << endl; + t << "<table class=\"memberdecls\">\n"; m_emptySection=FALSE; } t << "<tr class=\"heading\"><td colspan=\"" << typ << "\"><h2 class=\"groupheader\">"; if (anchor) { - t << "<a name=\"" << anchor << "\"></a>" << endl; + t << "<a name=\"" << anchor << "\"></a>\n"; } } void HtmlGenerator::endMemberHeader() { - DBG_HTML(t << "<!-- endMemberHeader -->" << endl) - t << "</h2></td></tr>" << endl; + DBG_HTML(t << "<!-- endMemberHeader -->\n") + t << "</h2></td></tr>\n"; } void HtmlGenerator::startMemberSubtitle() { - DBG_HTML(t << "<!-- startMemberSubtitle -->" << endl) + DBG_HTML(t << "<!-- startMemberSubtitle -->\n") t << "<tr><td class=\"ititle\" colspan=\"2\">"; } void HtmlGenerator::endMemberSubtitle() { - DBG_HTML(t << "<!-- endMemberSubtitle -->" << endl) - t << "</td></tr>" << endl; + DBG_HTML(t << "<!-- endMemberSubtitle -->\n") + t << "</td></tr>\n"; } void HtmlGenerator::startIndexList() { - t << "<table>" << endl; + t << "<table>\n"; } void HtmlGenerator::endIndexList() { - t << "</table>" << endl; + t << "</table>\n"; } void HtmlGenerator::startIndexKey() @@ -1779,24 +1771,24 @@ void HtmlGenerator::startIndexValue(bool) void HtmlGenerator::endIndexValue(const char *,bool) { - t << "</td></tr>" << endl; + t << "</td></tr>\n"; } void HtmlGenerator::startMemberDocList() { - DBG_HTML(t << "<!-- startMemberDocList -->" << endl;) + DBG_HTML(t << "<!-- startMemberDocList -->\n";) } void HtmlGenerator::endMemberDocList() { - DBG_HTML(t << "<!-- endMemberDocList -->" << endl;) + DBG_HTML(t << "<!-- endMemberDocList -->\n";) } void HtmlGenerator::startMemberDoc( const char *clName, const char *memName, const char *anchor, const char *title, int memCount, int memTotal, bool showInline) { - DBG_HTML(t << "<!-- startMemberDoc -->" << endl;) + DBG_HTML(t << "<!-- startMemberDoc -->\n";) t << "\n<h2 class=\"memtitle\">" << "<span class=\"permalink\"><a href=\"#" << anchor << "\">◆ </a></span>"; docify(title); @@ -1804,122 +1796,121 @@ void HtmlGenerator::startMemberDoc( const char *clName, const char *memName, { t << " <span class=\"overload\">[" << memCount << "/" << memTotal <<"]</span>"; } - t << "</h2>" - << endl; - t << "\n<div class=\"memitem\">" << endl; - t << "<div class=\"memproto\">" << endl; + t << "</h2>\n"; + t << "\n<div class=\"memitem\">\n"; + t << "<div class=\"memproto\">\n"; } void HtmlGenerator::startMemberDocPrefixItem() { - DBG_HTML(t << "<!-- startMemberDocPrefixItem -->" << endl;) - t << "<div class=\"memtemplate\">" << endl; + DBG_HTML(t << "<!-- startMemberDocPrefixItem -->\n";) + t << "<div class=\"memtemplate\">\n"; } void HtmlGenerator::endMemberDocPrefixItem() { - DBG_HTML(t << "<!-- endMemberDocPrefixItem -->" << endl;) - t << "</div>" << endl; + DBG_HTML(t << "<!-- endMemberDocPrefixItem -->\n";) + t << "</div>\n"; } void HtmlGenerator::startMemberDocName(bool /*align*/) { - DBG_HTML(t << "<!-- startMemberDocName -->" << endl;) + DBG_HTML(t << "<!-- startMemberDocName -->\n";) - t << " <table class=\"memname\">" << endl; + t << " <table class=\"memname\">\n"; - t << " <tr>" << endl; + t << " <tr>\n"; t << " <td class=\"memname\">"; } void HtmlGenerator::endMemberDocName() { - DBG_HTML(t << "<!-- endMemberDocName -->" << endl;) - t << "</td>" << endl; + DBG_HTML(t << "<!-- endMemberDocName -->\n";) + t << "</td>\n"; } void HtmlGenerator::startParameterList(bool openBracket) { - DBG_HTML(t << "<!-- startParameterList -->" << endl;) + DBG_HTML(t << "<!-- startParameterList -->\n";) t << " <td>"; if (openBracket) t << "("; - t << "</td>" << endl; + t << "</td>\n"; } void HtmlGenerator::startParameterType(bool first,const char *key) { if (first) { - DBG_HTML(t << "<!-- startFirstParameterType -->" << endl;) + DBG_HTML(t << "<!-- startFirstParameterType -->\n";) t << " <td class=\"paramtype\">"; } else { - DBG_HTML(t << "<!-- startParameterType -->" << endl;) - t << " <tr>" << endl; + DBG_HTML(t << "<!-- startParameterType -->\n";) + t << " <tr>\n"; t << " <td class=\"paramkey\">"; if (key) t << key; - t << "</td>" << endl; - t << " <td></td>" << endl; + t << "</td>\n"; + t << " <td></td>\n"; t << " <td class=\"paramtype\">"; } } void HtmlGenerator::endParameterType() { - DBG_HTML(t << "<!-- endParameterType -->" << endl;) - t << " </td>" << endl; + DBG_HTML(t << "<!-- endParameterType -->\n";) + t << " </td>\n"; } void HtmlGenerator::startParameterName(bool /*oneArgOnly*/) { - DBG_HTML(t << "<!-- startParameterName -->" << endl;) + DBG_HTML(t << "<!-- startParameterName -->\n";) t << " <td class=\"paramname\">"; } void HtmlGenerator::endParameterName(bool last,bool emptyList,bool closeBracket) { - DBG_HTML(t << "<!-- endParameterName -->" << endl;) + DBG_HTML(t << "<!-- endParameterName -->\n";) if (last) { if (emptyList) { if (closeBracket) t << "</td><td>)"; - t << "</td>" << endl; + t << "</td>\n"; t << " <td>"; } else { - t << " </td>" << endl; - t << " </tr>" << endl; - t << " <tr>" << endl; - t << " <td></td>" << endl; + t << " </td>\n"; + t << " </tr>\n"; + t << " <tr>\n"; + t << " <td></td>\n"; t << " <td>"; if (closeBracket) t << ")"; - t << "</td>" << endl; + t << "</td>\n"; t << " <td></td><td>"; } } else { - t << "</td>" << endl; - t << " </tr>" << endl; + t << "</td>\n"; + t << " </tr>\n"; } } void HtmlGenerator::endParameterList() { - DBG_HTML(t << "<!-- endParameterList -->" << endl;) - t << "</td>" << endl; - t << " </tr>" << endl; + DBG_HTML(t << "<!-- endParameterList -->\n";) + t << "</td>\n"; + t << " </tr>\n"; } void HtmlGenerator::exceptionEntry(const char* prefix,bool closeBracket) { - DBG_HTML(t << "<!-- exceptionEntry -->" << endl;) - t << "</td>" << endl; - t << " </tr>" << endl; - t << " <tr>" << endl; + DBG_HTML(t << "<!-- exceptionEntry -->\n";) + t << "</td>\n"; + t << " </tr>\n"; + t << " <tr>\n"; t << " <td align=\"right\">"; // colspan 2 so it gets both parameter type and parameter name columns if (prefix) @@ -1932,13 +1923,13 @@ void HtmlGenerator::exceptionEntry(const char* prefix,bool closeBracket) void HtmlGenerator::endMemberDoc(bool hasArgs) { - DBG_HTML(t << "<!-- endMemberDoc -->" << endl;) + DBG_HTML(t << "<!-- endMemberDoc -->\n";) if (!hasArgs) { - t << " </tr>" << endl; + t << " </tr>\n"; } - t << " </table>" << endl; - // t << "</div>" << endl; + t << " </table>\n"; + // t << "</div>\n"; } void HtmlGenerator::startDotGraph() @@ -2053,7 +2044,7 @@ void HtmlGenerator::startMemberGroupHeader(bool) void HtmlGenerator::endMemberGroupHeader() { - t << "</div></td></tr>" << endl; + t << "</div></td></tr>\n"; } void HtmlGenerator::startMemberGroupDocs() @@ -2063,7 +2054,7 @@ void HtmlGenerator::startMemberGroupDocs() void HtmlGenerator::endMemberGroupDocs() { - t << "</div></td></tr>" << endl; + t << "</div></td></tr>\n"; } void HtmlGenerator::startMemberGroup() @@ -2076,15 +2067,15 @@ void HtmlGenerator::endMemberGroup(bool) void HtmlGenerator::startIndent() { - DBG_HTML(t << "<!-- startIndent -->" << endl;) + DBG_HTML(t << "<!-- startIndent -->\n";) t << "<div class=\"memdoc\">\n"; } void HtmlGenerator::endIndent() { - DBG_HTML(t << "<!-- endIndent -->" << endl;) - t << endl << "</div>" << endl << "</div>" << endl; + DBG_HTML(t << "<!-- endIndent -->\n";) + t << "\n</div>\n" << "</div>\n"; } void HtmlGenerator::addIndexItem(const char *,const char *) @@ -2102,12 +2093,12 @@ void HtmlGenerator::writeNonBreakableSpace(int n) void HtmlGenerator::startDescTable(const char *title) { - t << "<table class=\"fieldtable\">" << endl + t << "<table class=\"fieldtable\">\n" << "<tr><th colspan=\"2\">" << title << "</th></tr>"; } void HtmlGenerator::endDescTable() { - t << "</table>" << endl; + t << "</table>\n"; } void HtmlGenerator::startDescTableRow() @@ -2117,7 +2108,7 @@ void HtmlGenerator::startDescTableRow() void HtmlGenerator::endDescTableRow() { - t << "</tr>" << endl; + t << "</tr>\n"; } void HtmlGenerator::startDescTableTitle() @@ -2149,7 +2140,7 @@ void HtmlGenerator::startExamples() void HtmlGenerator::endExamples() { - t << "</dl>" << endl; + t << "</dl>\n"; } void HtmlGenerator::startParamList(ParamListTypes, @@ -2175,7 +2166,7 @@ void HtmlGenerator::writeDoc(DocNode *n,const Definition *ctx,const MemberDef *, //---------------- helpers for index generation ----------------------------- -static void startQuickIndexList(FTextStream &t,bool compact,bool topLevel=TRUE) +static void startQuickIndexList(std::ostream &t,bool compact,bool topLevel=TRUE) { if (compact) { @@ -2195,7 +2186,7 @@ static void startQuickIndexList(FTextStream &t,bool compact,bool topLevel=TRUE) } } -static void endQuickIndexList(FTextStream &t,bool compact) +static void endQuickIndexList(std::ostream &t,bool compact) { if (compact) { @@ -2208,7 +2199,7 @@ static void endQuickIndexList(FTextStream &t,bool compact) } } -static void startQuickIndexItem(FTextStream &t,const char *l, +static void startQuickIndexItem(std::ostream &t,const char *l, bool hl,bool /*compact*/, const QCString &relPath) { @@ -2222,7 +2213,7 @@ static void startQuickIndexItem(FTextStream &t,const char *l, t << "<span>"; } -static void endQuickIndexItem(FTextStream &t,const char *l) +static void endQuickIndexItem(std::ostream &t,const char *l) { t << "</span>"; if (l) t << "</a>"; @@ -2270,7 +2261,7 @@ static bool quickLinkVisible(LayoutNavEntry::Kind kind) return FALSE; } -static void renderQuickLinksAsTree(FTextStream &t,const QCString &relPath,LayoutNavEntry *root) +static void renderQuickLinksAsTree(std::ostream &t,const QCString &relPath,LayoutNavEntry *root) { int count=0; @@ -2299,7 +2290,7 @@ static void renderQuickLinksAsTree(FTextStream &t,const QCString &relPath,Layout } -static void renderQuickLinksAsTabs(FTextStream &t,const QCString &relPath, +static void renderQuickLinksAsTabs(std::ostream &t,const QCString &relPath, LayoutNavEntry *hlEntry,LayoutNavEntry::Kind kind, bool highlightParent,bool highlightSearch) { @@ -2368,7 +2359,7 @@ static void renderQuickLinksAsTabs(FTextStream &t,const QCString &relPath, } } -static void writeDefaultQuickLinks(FTextStream &t,bool compact, +static void writeDefaultQuickLinks(std::ostream &t,bool compact, HighlightedItem hli, const char *file, const QCString &relPath) @@ -2431,16 +2422,16 @@ static void writeDefaultQuickLinks(FTextStream &t,bool compact, { searchPage = "search.php"; } - t << "<script type=\"text/javascript\" src=\"" << relPath << "menudata.js\"></script>" << endl; - t << "<script type=\"text/javascript\" src=\"" << relPath << "menu.js\"></script>" << endl; - t << "<script type=\"text/javascript\">" << endl; + t << "<script type=\"text/javascript\" src=\"" << relPath << "menudata.js\"></script>\n"; + t << "<script type=\"text/javascript\" src=\"" << relPath << "menu.js\"></script>\n"; + t << "<script type=\"text/javascript\">\n"; t << "/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */\n"; - t << "$(function() {" << endl; + t << "$(function() {\n"; t << " initMenu('" << relPath << "'," << (searchEngine?"true":"false") << "," << (serverBasedSearch?"true":"false") << ",'" << searchPage << "','" - << theTranslator->trSearch() << "');" << endl; + << theTranslator->trSearch() << "');\n"; if (Config_getBool(SEARCHENGINE)) { if (!serverBasedSearch) @@ -2455,10 +2446,10 @@ static void writeDefaultQuickLinks(FTextStream &t,bool compact, << " });\n"; } } - t << "});" << endl; + t << "});\n"; t << "/* @license-end */"; - t << "</script>" << endl; - t << "<div id=\"main-nav\"></div>" << endl; + t << "</script>\n"; + t << "<div id=\"main-nav\"></div>\n"; } else if (compact) // && !Config_getBool(HTML_DYNAMIC_MENUS) { @@ -2492,7 +2483,7 @@ static void writeDefaultQuickLinks(FTextStream &t,bool compact, void HtmlGenerator::endQuickIndices() { - t << "</div><!-- top -->" << endl; + t << "</div><!-- top -->\n"; } QCString HtmlGenerator::writeSplitBarAsString(const char *name,const char *relpath) @@ -2538,12 +2529,12 @@ void HtmlGenerator::writeNavigationPath(const char *s) void HtmlGenerator::startContents() { - t << "<div class=\"contents\">" << endl; + t << "<div class=\"contents\">\n"; } void HtmlGenerator::endContents() { - t << "</div><!-- contents -->" << endl; + t << "</div><!-- contents -->\n"; } void HtmlGenerator::startPageDoc(const char *pageTitle) @@ -2553,7 +2544,7 @@ void HtmlGenerator::startPageDoc(const char *pageTitle) void HtmlGenerator::endPageDoc() { - t << "</div><!-- PageDoc -->" << endl; + t << "</div><!-- PageDoc -->\n"; } void HtmlGenerator::writeQuickLinks(bool compact,HighlightedItem hli,const char *file) @@ -2571,10 +2562,9 @@ void HtmlGenerator::writeSearchPage() // OPENSEARCH_PROVIDER { QCString configFileName = htmlOutput+"/search_config.php"; - QFile cf(configFileName); - if (cf.open(IO_WriteOnly)) + std::ofstream t(configFileName.str(),std::ofstream::out); + if (t.is_open()) { - FTextStream t(&cf); t << "<?php\n\n"; t << "$config = array(\n"; t << " 'PROJECT_NAME' => \"" << convertToHtml(projectName) << "\",\n"; @@ -2595,20 +2585,20 @@ void HtmlGenerator::writeSearchPage() t << ");\n\n"; t << "?>\n"; } + t.close(); ResourceMgr::instance().copyResource("search_functions.php",htmlOutput); ResourceMgr::instance().copyResource("search_opensearch.php",htmlOutput); // OPENSEARCH_PROVIDER } QCString fileName = htmlOutput+"/search.php"; - QFile f(fileName); - if (f.open(IO_WriteOnly)) + t.open(fileName.str(),std::ofstream::out); + if (t.is_open()) { - FTextStream t(&f); t << substituteHtmlKeywords(g_header,"Search",""); t << "<!-- " << theTranslator->trGeneratedBy() << " Doxygen " - << getDoxygenVersion() << " -->" << endl; + << getDoxygenVersion() << " -->\n"; t << "<script type=\"text/javascript\">\n"; t << "/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */\n"; t << "var searchBox = new SearchBox(\"searchBox\", \"" @@ -2621,7 +2611,7 @@ void HtmlGenerator::writeSearchPage() } else { - t << "</div>" << endl; + t << "</div>\n"; } t << "<?php\n"; @@ -2637,11 +2627,12 @@ void HtmlGenerator::writeSearchPage() writePageFooter(t,"Search","",""); } + t.close(); + QCString scriptName = htmlOutput+"/search/search.js"; - QFile sf(scriptName); - if (sf.open(IO_WriteOnly)) + t.open(scriptName.str(),std::ofstream::out); + if (t.is_open()) { - FTextStream t(&sf); t << ResourceMgr::instance().getAsString("extsearch.js"); } else @@ -2655,14 +2646,13 @@ void HtmlGenerator::writeExternalSearchPage() bool generateTreeView = Config_getBool(GENERATE_TREEVIEW); QCString dname = Config_getString(HTML_OUTPUT); QCString fileName = dname+"/search"+Doxygen::htmlFileExtension; - QFile f(fileName); - if (f.open(IO_WriteOnly)) + std::ofstream t(fileName.str(),std::ofstream::out); + if (t.is_open()) { - FTextStream t(&f); t << substituteHtmlKeywords(g_header,"Search",""); t << "<!-- " << theTranslator->trGeneratedBy() << " Doxygen " - << getDoxygenVersion() << " -->" << endl; + << getDoxygenVersion() << " -->\n"; t << "<script type=\"text/javascript\">\n"; t << "/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */\n"; t << "var searchBox = new SearchBox(\"searchBox\", \"" @@ -2683,38 +2673,39 @@ void HtmlGenerator::writeExternalSearchPage() } else { - t << "</div>" << endl; + t << "</div>\n"; } t << writeSplitBarAsString("search",""); - t << "<div class=\"header\">" << endl; - t << " <div class=\"headertitle\">" << endl; - t << " <div class=\"title\">" << theTranslator->trSearchResultsTitle() << "</div>" << endl; - t << " </div>" << endl; - t << "</div>" << endl; - t << "<div class=\"contents\">" << endl; + t << "<div class=\"header\">\n"; + t << " <div class=\"headertitle\">\n"; + t << " <div class=\"title\">" << theTranslator->trSearchResultsTitle() << "</div>\n"; + t << " </div>\n"; + t << "</div>\n"; + t << "<div class=\"contents\">\n"; - t << "<div id=\"searchresults\"></div>" << endl; - t << "</div>" << endl; + t << "<div id=\"searchresults\"></div>\n"; + t << "</div>\n"; if (generateTreeView) { - t << "</div><!-- doc-content -->" << endl; + t << "</div><!-- doc-content -->\n"; } writePageFooter(t,"Search","",""); } + t.close(); + QCString scriptName = dname+"/search/search.js"; - QFile sf(scriptName); - if (sf.open(IO_WriteOnly)) + t.open(scriptName.str(),std::ofstream::out); + if (t.is_open()) { - FTextStream t(&sf); t << "var searchResultsText=[" << "\"" << theTranslator->trSearchResults(0) << "\"," << "\"" << theTranslator->trSearchResults(1) << "\"," - << "\"" << theTranslator->trSearchResults(2) << "\"];" << endl; - t << "var serverUrl=\"" << Config_getString(SEARCHENGINE_URL) << "\";" << endl; - t << "var tagMap = {" << endl; + << "\"" << theTranslator->trSearchResults(2) << "\"];\n"; + t << "var serverUrl=\"" << Config_getString(SEARCHENGINE_URL) << "\";\n"; + t << "var tagMap = {\n"; bool first=TRUE; // add search mappings const StringVector &extraSearchMappings = Config_getList(EXTRA_SEARCH_MAPPINGS); @@ -2728,25 +2719,25 @@ void HtmlGenerator::writeExternalSearchPage() QCString destName = mapLine.right(mapLine.length()-eqPos-1).stripWhiteSpace(); if (!tagName.isEmpty()) { - if (!first) t << "," << endl; + if (!first) t << ",\n"; t << " \"" << tagName << "\": \"" << destName << "\""; first=FALSE; } } } - if (!first) t << endl; - t << "};" << endl << endl; + if (!first) t << "\n"; + t << "};\n\n"; t << ResourceMgr::instance().getAsString("extsearch.js"); - t << endl; - t << "$(document).ready(function() {" << endl; - t << " var query = trim(getURLParameter('query'));" << endl; - t << " if (query) {" << endl; - t << " searchFor(query,0,20);" << endl; - t << " } else {" << endl; - t << " var results = $('#results');" << endl; - t << " results.html('<p>" << theTranslator->trSearchResults(0) << "</p>');" << endl; - t << " }" << endl; - t << "});" << endl; + t << "\n"; + t << "$(document).ready(function() {\n"; + t << " var query = trim(getURLParameter('query'));\n"; + t << " if (query) {\n"; + t << " searchFor(query,0,20);\n"; + t << " } else {\n"; + t << " var results = $('#results');\n"; + t << " results.html('<p>" << theTranslator->trSearchResults(0) << "</p>');\n"; + t << " }\n"; + t << "});\n"; } else { @@ -2756,9 +2747,9 @@ void HtmlGenerator::writeExternalSearchPage() void HtmlGenerator::startConstraintList(const char *header) { - t << "<div class=\"typeconstraint\">" << endl; - t << "<dl><dt><b>" << header << "</b></dt><dd>" << endl; - t << "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\">" << endl; + t << "<div class=\"typeconstraint\">\n"; + t << "<dl><dt><b>" << header << "</b></dt><dd>\n"; + t << "<table border=\"0\" cellspacing=\"2\" cellpadding=\"0\">\n"; } void HtmlGenerator::startConstraintParam() @@ -2788,56 +2779,56 @@ void HtmlGenerator::startConstraintDocs() void HtmlGenerator::endConstraintDocs() { - t << "</td></tr>" << endl; + t << "</td></tr>\n"; } void HtmlGenerator::endConstraintList() { - t << "</table>" << endl; - t << "</dd>" << endl; - t << "</dl>" << endl; - t << "</div>" << endl; + t << "</table>\n"; + t << "</dd>\n"; + t << "</dl>\n"; + t << "</div>\n"; } void HtmlGenerator::lineBreak(const char *style) { if (style) { - t << "<br class=\"" << style << "\" />" << endl; + t << "<br class=\"" << style << "\" />\n"; } else { - t << "<br />" << endl; + t << "<br />\n"; } } void HtmlGenerator::startHeaderSection() { - t << "<div class=\"header\">" << endl; + t << "<div class=\"header\">\n"; } void HtmlGenerator::startTitleHead(const char *) { - t << " <div class=\"headertitle\">" << endl; + t << " <div class=\"headertitle\">\n"; startTitle(); } void HtmlGenerator::endTitleHead(const char *,const char *) { endTitle(); - t << " </div>" << endl; + t << " </div>\n"; } void HtmlGenerator::endHeaderSection() { - t << "</div><!--header-->" << endl; + t << "</div><!--header-->\n"; } void HtmlGenerator::startInlineHeader() { if (m_emptySection) { - t << "<table class=\"memberdecls\">" << endl; + t << "<table class=\"memberdecls\">\n"; m_emptySection=FALSE; } t << "<tr><td colspan=\"2\"><h3>"; @@ -2845,69 +2836,69 @@ void HtmlGenerator::startInlineHeader() void HtmlGenerator::endInlineHeader() { - t << "</h3></td></tr>" << endl; + t << "</h3></td></tr>\n"; } void HtmlGenerator::startMemberDocSimple(bool isEnum) { - DBG_HTML(t << "<!-- startMemberDocSimple -->" << endl;) - t << "<table class=\"fieldtable\">" << endl; + DBG_HTML(t << "<!-- startMemberDocSimple -->\n";) + t << "<table class=\"fieldtable\">\n"; t << "<tr><th colspan=\"" << (isEnum?"2":"3") << "\">"; t << (isEnum? theTranslator->trEnumerationValues() : - theTranslator->trCompoundMembers()) << "</th></tr>" << endl; + theTranslator->trCompoundMembers()) << "</th></tr>\n"; } void HtmlGenerator::endMemberDocSimple(bool) { - DBG_HTML(t << "<!-- endMemberDocSimple -->" << endl;) - t << "</table>" << endl; + DBG_HTML(t << "<!-- endMemberDocSimple -->\n";) + t << "</table>\n"; } void HtmlGenerator::startInlineMemberType() { - DBG_HTML(t << "<!-- startInlineMemberType -->" << endl;) - t << "<tr><td class=\"fieldtype\">" << endl; + DBG_HTML(t << "<!-- startInlineMemberType -->\n";) + t << "<tr><td class=\"fieldtype\">\n"; } void HtmlGenerator::endInlineMemberType() { - DBG_HTML(t << "<!-- endInlineMemberType -->" << endl;) - t << "</td>" << endl; + DBG_HTML(t << "<!-- endInlineMemberType -->\n";) + t << "</td>\n"; } void HtmlGenerator::startInlineMemberName() { - DBG_HTML(t << "<!-- startInlineMemberName -->" << endl;) - t << "<td class=\"fieldname\">" << endl; + DBG_HTML(t << "<!-- startInlineMemberName -->\n";) + t << "<td class=\"fieldname\">\n"; } void HtmlGenerator::endInlineMemberName() { - DBG_HTML(t << "<!-- endInlineMemberName -->" << endl;) - t << "</td>" << endl; + DBG_HTML(t << "<!-- endInlineMemberName -->\n";) + t << "</td>\n"; } void HtmlGenerator::startInlineMemberDoc() { - DBG_HTML(t << "<!-- startInlineMemberDoc -->" << endl;) - t << "<td class=\"fielddoc\">" << endl; + DBG_HTML(t << "<!-- startInlineMemberDoc -->\n";) + t << "<td class=\"fielddoc\">\n"; } void HtmlGenerator::endInlineMemberDoc() { - DBG_HTML(t << "<!-- endInlineMemberDoc -->" << endl;) - t << "</td></tr>" << endl; + DBG_HTML(t << "<!-- endInlineMemberDoc -->\n";) + t << "</td></tr>\n"; } void HtmlGenerator::startLabels() { - DBG_HTML(t << "<!-- startLabels -->" << endl;) + DBG_HTML(t << "<!-- startLabels -->\n";) t << "<span class=\"mlabels\">"; } void HtmlGenerator::writeLabel(const char *l,bool /*isLast*/) { - DBG_HTML(t << "<!-- writeLabel(" << l << ") -->" << endl;) + DBG_HTML(t << "<!-- writeLabel(" << l << ") -->\n";) //t << "<tt>[" << l << "]</tt>"; //if (!isLast) t << ", "; t << "<span class=\"mlabel\">" << l << "</span>"; @@ -2915,7 +2906,7 @@ void HtmlGenerator::writeLabel(const char *l,bool /*isLast*/) void HtmlGenerator::endLabels() { - DBG_HTML(t << "<!-- endLabels -->" << endl;) + DBG_HTML(t << "<!-- endLabels -->\n";) t << "</span>"; } @@ -2924,7 +2915,7 @@ void HtmlGenerator::writeInheritedSectionTitle( const char *file, const char *anchor, const char *title, const char *name) { - DBG_HTML(t << "<!-- writeInheritedSectionTitle -->" << endl;) + DBG_HTML(t << "<!-- writeInheritedSectionTitle -->\n";) QCString a = anchor; if (!a.isEmpty()) a.prepend("#"); QCString classLink = QCString("<a class=\"el\" "); @@ -2945,7 +2936,7 @@ void HtmlGenerator::writeInheritedSectionTitle( << "<td colspan=\"2\" onclick=\"javascript:toggleInherit('" << id << "')\">" << "<img src=\"" << m_relPath << "closed.png\" alt=\"-\"/> " << theTranslator->trInheritedFrom(convertToHtml(title,FALSE),classLink) - << "</td></tr>" << endl; + << "</td></tr>\n"; } void HtmlGenerator::writeSummaryLink(const char *file,const char *anchor,const char *title,bool first) @@ -2963,7 +2954,7 @@ void HtmlGenerator::writeSummaryLink(const char *file,const char *anchor,const c { t << m_relPath << addHtmlExtensionIfMissing(file); } - else + else if (anchor) { t << "#"; t << anchor; @@ -2975,7 +2966,7 @@ void HtmlGenerator::writeSummaryLink(const char *file,const char *anchor,const c void HtmlGenerator::endMemberDeclaration(const char *anchor,const char *inheritId) { - t << "<tr class=\"separator:" << anchor; + t << "<tr class=\"separator:" << (anchor?anchor:""); if (inheritId) { t << " inherit " << inheritId; diff --git a/src/htmlgen.h b/src/htmlgen.h index 659a69e..df9bc0c 100644 --- a/src/htmlgen.h +++ b/src/htmlgen.h @@ -17,18 +17,15 @@ #define HTMLGEN_H #include "outputgen.h" -#include "ftextstream.h" - -class QFile; class HtmlCodeGenerator : public CodeOutputInterface { public: - HtmlCodeGenerator(FTextStream &t,const QCString &relPath); + HtmlCodeGenerator(std::ostream &t,const QCString &relPath); HtmlCodeGenerator(); int id() const { return m_id; } void setId(int id) { m_id = id; } - void setTextStream(FTextStream &t); + void setTextStream(std::ostream &t); void setRelativePath(const QCString &path); void codify(const char *text); void writeCodeLink(const char *ref,const char *file, @@ -59,7 +56,7 @@ class HtmlCodeGenerator : public CodeOutputInterface const char *tooltip); void docify(const char *str); bool m_streamSet = false; - FTextStream m_t; + std::ostream m_t; int m_col = 0; QCString m_relPath; bool m_lineOpen = false; @@ -78,11 +75,11 @@ class HtmlGenerator : public OutputGenerator virtual OutputType type() const { return Html; } static void init(); - static void writeStyleSheetFile(QFile &f); - static void writeHeaderFile(QFile &f, const char *cssname); - static void writeFooterFile(QFile &f); + static void writeStyleSheetFile(std::ostream &t); + static void writeHeaderFile(std::ostream &t, const char *cssname); + static void writeFooterFile(std::ostream &t); static void writeTabData(); - static void writeSearchInfo(FTextStream &t,const QCString &relPath); + static void writeSearchInfo(std::ostream &t,const QCString &relPath); static void writeSearchData(const char *dir); static void writeSearchPage(); static void writeExternalSearchPage(); @@ -150,8 +147,8 @@ class HtmlGenerator : public OutputGenerator void endIndexKey(); void startIndexValue(bool); void endIndexValue(const char *,bool); - void startItemList() { t << "<ul>" << endl; } - void endItemList() { t << "</ul>" << endl; } + void startItemList() { t << "<ul>\n"; } + void endItemList() { t << "</ul>\n"; } void startIndexItem(const char *ref,const char *file); void endIndexItem(const char *ref,const char *file); void docify(const char *text); @@ -215,8 +212,8 @@ class HtmlGenerator : public OutputGenerator void endEmphasis() { t << "</em>"; } void startBold() { t << "<b>"; } void endBold() { t << "</b>"; } - void startDescription() { t << endl << "<dl>" << endl; } - void endDescription() { t << endl << "</dl>\n" << endl; } + void startDescription() { t << "\n<dl>\n"; } + void endDescription() { t << "\n</dl>\n\n"; } void startDescItem() { t << "<dt>"; } void endDescItem() { t << "</dt>"; } void startDescForItem() { t << "<dd>"; } @@ -234,15 +231,15 @@ class HtmlGenerator : public OutputGenerator void writeLatexSpacing() {} void writeStartAnnoItem(const char *type,const char *file, const char *path,const char *name); - void writeEndAnnoItem(const char *) { t << endl; } + void writeEndAnnoItem(const char *) { t << "\n"; } void startSubsection() { t << "<h2>"; } - void endSubsection() { t << "</h2>" << endl; } + void endSubsection() { t << "</h2>\n"; } void startSubsubsection() { t << "<h3>"; } - void endSubsubsection() { t << "</h3>" << endl; } - void startCenter() { t << "<center>" << endl; } - void endCenter() { t << "</center>" << endl; } - void startSmall() { t << "<small>" << endl; } - void endSmall() { t << "</small>" << endl; } + void endSubsubsection() { t << "</h3>\n"; } + void startCenter() { t << "<center>\n"; } + void endCenter() { t << "</center>\n"; } + void startSmall() { t << "<small>\n"; } + void endSmall() { t << "</small>\n"; } void startExamples(); void endExamples(); void startParamList(ParamListTypes,const char *); @@ -332,7 +329,7 @@ class HtmlGenerator : public OutputGenerator void endLabels(); private: - static void writePageFooter(FTextStream &t,const QCString &,const QCString &,const QCString &); + static void writePageFooter(std::ostream &t,const QCString &,const QCString &,const QCString &); QCString m_lastTitle; QCString m_lastFile; QCString m_relPath; diff --git a/src/htmlhelp.cpp b/src/htmlhelp.cpp index 49aee3f..b6816b8 100644 --- a/src/htmlhelp.cpp +++ b/src/htmlhelp.cpp @@ -19,7 +19,6 @@ #include <stdio.h> #include <stdlib.h> -#include <qfile.h> #include "htmlhelp.h" #include "config.h" @@ -120,7 +119,7 @@ class HtmlHelpIndex void addItem(const char *first,const char *second, const char *url, const char *anchor, bool hasLink,bool reversed); - void writeFields(FTextStream &t); + void writeFields(std::ostream &t); size_t size() const { return m_map.size(); } private: LinkedMap<IndexField> m_map; @@ -210,7 +209,7 @@ static QCString field2URL(const IndexField *f,bool checkReversed) * b1 -> link to url#anchor * </pre> */ -void HtmlHelpIndex::writeFields(FTextStream &t) +void HtmlHelpIndex::writeFields(std::ostream &t) { std::sort(std::begin(m_map), std::end(m_map), @@ -234,7 +233,7 @@ void HtmlHelpIndex::writeFields(FTextStream &t) } { // finish old list at level 2 - if (level2Started) t << " </UL>" << endl; + if (level2Started) t << " </UL>\n"; level2Started=FALSE; // <Antony> @@ -287,12 +286,12 @@ void HtmlHelpIndex::writeFields(FTextStream &t) } if (!level2Started && !level2.isEmpty()) { // start new list at level 2 - t << " <UL>" << endl; + t << " <UL>\n"; level2Started=TRUE; } else if (level2Started && level2.isEmpty()) { // end list at level 2 - t << " </UL>" << endl; + t << " </UL>\n"; level2Started=FALSE; } if (level2Started) @@ -304,7 +303,7 @@ void HtmlHelpIndex::writeFields(FTextStream &t) "</OBJECT>\n"; } } - if (level2Started) t << " </UL>" << endl; + if (level2Started) t << " </UL>\n"; } //---------------------------------------------------------------------------- @@ -314,9 +313,7 @@ class HtmlHelp::Private public: Private() : index(recoder) {} void createProjectFile(); - QFile cf; - QFile kf; - FTextStream cts,kts; + std::ofstream cts,kts; bool ctsItemPresent = false; int dc = 0; StringSet indexFiles; @@ -447,13 +444,12 @@ void HtmlHelp::initialize() /* open the contents file */ QCString fName = Config_getString(HTML_OUTPUT) + "/index.hhc"; - p->cf.setName(fName); - if (!p->cf.open(IO_WriteOnly)) + p->cts.open(fName.str(),std::ofstream::out | std::ofstream::binary); + if (!p->cts.is_open()) { term("Could not open file %s for writing\n",fName.data()); } /* Write the header of the contents file */ - p->cts.setDevice(&p->cf); p->cts << "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n" "<HTML><HEAD></HEAD><BODY>\n" "<OBJECT type=\"text/site properties\">\n" @@ -463,13 +459,12 @@ void HtmlHelp::initialize() /* open the contents file */ fName = Config_getString(HTML_OUTPUT) + "/index.hhk"; - p->kf.setName(fName); - if (!p->kf.open(IO_WriteOnly)) + p->kts.open(fName.str(),std::ofstream::out | std::ofstream::binary); + if (!p->kts.is_open()) { term("Could not open file %s for writing\n",fName.data()); } /* Write the header of the contents file */ - p->kts.setDevice(&p->kf); p->kts << "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n" "<HTML><HEAD></HEAD><BODY>\n" "<OBJECT type=\"text/site properties\">\n" @@ -500,11 +495,9 @@ void HtmlHelp::Private::createProjectFile() { /* Write the project file */ QCString fName = Config_getString(HTML_OUTPUT) + "/index.hhp"; - QFile f(fName); - if (f.open(IO_WriteOnly)) + std::ofstream t(fName.str(),std::ofstream::out | std::ofstream::binary); + if (t.is_open()) { - FTextStream t(&f); - const char *hhcFile = "\"index.hhc\""; const char *hhkFile = "\"index.hhk\""; bool hhkPresent = index.size()>0; @@ -523,12 +516,12 @@ void HtmlHelp::Private::createProjectFile() t << "Default Window=main\n" "Default topic=" << indexName << "\n"; if (hhkPresent) t << "Index file=index.hhk\n"; - t << "Language=" << getLanguageString() << endl; + t << "Language=" << getLanguageString() << "\n"; if (Config_getBool(BINARY_TOC)) t << "Binary TOC=YES\n"; if (Config_getBool(GENERATE_CHI)) t << "Create CHI file=YES\n"; - t << "Title=" << recoder.recode(Config_getString(PROJECT_NAME)) << endl << endl; + t << "Title=" << recoder.recode(Config_getString(PROJECT_NAME)) << "\n\n"; - t << "[WINDOWS]" << endl; + t << "[WINDOWS]\n"; // NOTE: the 0x10387e number is a set of bits specifying the buttons // which should appear in the CHM viewer; that specific value @@ -544,25 +537,25 @@ void HtmlHelp::Private::createProjectFile() { t << "main=\"" << recoder.recode(Config_getString(PROJECT_NAME)) << "\"," << hhcFile << "," << hhkFile << ",\"" << indexName << "\",\"" << - indexName << "\",,,,,0x23520,,0x70387e,,,,,,,,0" << endl << endl; + indexName << "\",,,,,0x23520,,0x70387e,,,,,,,,0\n\n"; } else { t << "main=\"" << recoder.recode(Config_getString(PROJECT_NAME)) << "\"," << hhcFile << "," << hhkFile << ",\"" << indexName << "\",\"" << - indexName << "\",,,,,0x23520,,0x10387e,,,,,,,,0" << endl << endl; + indexName << "\",,,,,0x23520,,0x10387e,,,,,,,,0\n\n"; } - t << "[FILES]" << endl; + t << "[FILES]\n"; for (auto &s : indexFiles) { - t << s.c_str() << endl; + t << s.c_str() << "\n"; } for (auto &s : imageFiles) { - t << FileInfo(s).fileName() << endl; + t << FileInfo(s).fileName() << "\n"; } - f.close(); + t.close(); } else { @@ -585,8 +578,7 @@ void HtmlHelp::finalize() p->cts << "</UL>\n"; p->cts << "</BODY>\n"; p->cts << "</HTML>\n"; - p->cts.unsetDevice(); - p->cf.close(); + p->cts.close(); p->index.writeFields(p->kts); @@ -594,8 +586,7 @@ void HtmlHelp::finalize() p->kts << "</UL>\n"; p->kts << "</BODY>\n"; p->kts << "</HTML>\n"; - p->kts.unsetDevice(); - p->kf.close(); + p->kts.close(); p->createProjectFile(); diff --git a/src/image.cpp b/src/image.cpp index 2a8108b..033332f 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -1,13 +1,13 @@ /****************************************************************************** * - * + * * * * Copyright (C) 1997-2015 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its - * documentation under the terms of the GNU General Public License is hereby - * granted. No representations are made about the suitability of this software + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * @@ -17,7 +17,6 @@ */ #include "image.h" -#include <qfile.h> #include <math.h> #include "lodepng.h" #include "config.h" @@ -37,10 +36,10 @@ const int charSetWidth=80; const int charHeight=12; const int numChars=96; -unsigned short charPos[numChars] = - { - 0, 5, 8, 13, 20, 27, 38, 47, - 50, 54, 58, 65, 72, 76, 83, 87, +unsigned short charPos[numChars] = + { + 0, 5, 8, 13, 20, 27, 38, 47, + 50, 54, 58, 65, 72, 76, 83, 87, 91, 98,105,112,119,126,133,140, 147,154,161,164,167,174,181,188, 195,207,216,224,233,242,250,258, @@ -53,7 +52,7 @@ unsigned short charPos[numChars] = 594,600,607,613,617,620,624,631 }; -unsigned char charWidth[numChars] = +unsigned char charWidth[numChars] = { 5, 3, 5, 7, 7,11, 9, 3, 4, 4, 7, 7, 4, 7, 4, 4, @@ -67,7 +66,7 @@ unsigned char charWidth[numChars] = 3, 7, 7, 7, 7, 7, 4, 7, 7, 3, 3, 6, 3, 9, 7, 7, 7, 6, 5, 6, 3, 7, 7, 9, - 6, 7, 6, 4, 3, 4, 7, 5 + 6, 7, 6, 4, 3, 4, 7, 5 }; unsigned char fontRaw[charSetWidth*charHeight] = { @@ -261,7 +260,7 @@ uchar Image::getPixel(uint x,uint y) const return 0; } -void Image::writeChar(uint x,uint y,char c,uchar fg) +void Image::writeChar(uint x,uint y,char c,uchar fg) { if (c>=' ') { @@ -279,8 +278,8 @@ void Image::writeChar(uint x,uint y,char c,uchar fg) while (bitsLeft>0) { uint bits=8-bitOffset; - if (bits>bitsLeft) bits=bitsLeft; - bitPattern<<=bits; + if (bits>bitsLeft) bits=bitsLeft; + bitPattern<<=bits; bitPattern|=((fontRaw[byteOffset]<<bitOffset)&0xff)>>(8-bits); bitsLeft-=bits; bitOffset=0; @@ -295,10 +294,10 @@ void Image::writeChar(uint x,uint y,char c,uchar fg) } rowOffset+=charSetWidth; } - } + } } -void Image::writeString(uint x,uint y,const char *s,uchar fg) +void Image::writeString(uint x,uint y,const char *s,uchar fg) { if (s) { @@ -311,7 +310,7 @@ void Image::writeString(uint x,uint y,const char *s,uchar fg) } } -uint Image::stringLength(const char *s) +uint Image::stringLength(const char *s) { uint w=0; if (s) @@ -325,12 +324,12 @@ uint Image::stringLength(const char *s) void Image::drawHorzLine(uint y,uint xs,uint xe,uchar colIndex,uint mask) { uint x,i=0,j=0; - for (x=xs;x<=xe;x++,j++) + for (x=xs;x<=xe;x++,j++) { if (j&1) i++; if (mask&(1<<(i&0x1f))) setPixel(x,y,colIndex); } -} +} void Image::drawHorzArrow(uint y,uint xs,uint xe,uchar colIndex,uint mask) { @@ -341,12 +340,12 @@ void Image::drawHorzArrow(uint y,uint xs,uint xe,uchar colIndex,uint mask) uint h=i>>1; drawVertLine(xe-i,y-h,y+h,colIndex,0xffffffff); } -} +} void Image::drawVertLine(uint x,uint ys,uint ye,uchar colIndex,uint mask) { uint y,i=0; - for (y=ys;y<=ye;y++,i++) + for (y=ys;y<=ye;y++,i++) { if (mask&(1<<(i&0x1f))) setPixel(x,y,colIndex); } @@ -376,7 +375,7 @@ void Image::fillRect(uint x,uint y,uint width,uint height,uchar colIndex,uint ma uint xp,yp,xi,yi; for (yp=y,yi=0;yp<y+height;yp++,yi++) for (xp=x,xi=0;xp<x+width;xp++,xi++) - if (mask&(1<<((xi+yi)&0x1f))) + if (mask&(1<<((xi+yi)&0x1f))) setPixel(xp,yp,colIndex); } @@ -388,8 +387,8 @@ bool Image::save(const char *fileName,int mode) LodePNG_Encoder encoder; LodePNG_Encoder_init(&encoder); uint numCols = mode==0 ? 8 : 16; - Color *pPal = mode==0 ? palette : - useTransparency ? palette2 : + Color *pPal = mode==0 ? palette : + useTransparency ? palette2 : palette3 ; uint i; for (i=0;i<numCols;i++,pPal++) @@ -397,7 +396,7 @@ bool Image::save(const char *fileName,int mode) LodePNG_InfoColor_addPalette(&encoder.infoPng.color, pPal->red,pPal->green,pPal->blue,pPal->alpha); } - encoder.infoPng.color.colorType = 3; + encoder.infoPng.color.colorType = 3; encoder.infoRaw.color.colorType = 3; LodePNG_encode(&encoder, &buffer, &bufferSize, m_data, m_width, m_height); LodePNG_saveFile(buffer, bufferSize, fileName); diff --git a/src/index.cpp b/src/index.cpp index 7a31f0f..9e91b3a 100644 --- a/src/index.cpp +++ b/src/index.cpp @@ -1,8 +1,6 @@ /****************************************************************************** * - * - * - * Copyright (C) 1997-2015 by Dimitri van Heesch. + * Copyright (C) 1997-2021 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its * documentation under the terms of the GNU General Public License is hereby @@ -19,12 +17,11 @@ * @brief This file contains functions for the various index pages. */ -#include <stdlib.h> - +#include <cstdlib> +#include <sstream> #include <array> #include <assert.h> -#include <qdir.h> #include "message.h" #include "index.h" @@ -991,12 +988,11 @@ static void writeHierarchicalIndex(OutputList &ol) } FTVHelp* ftv = new FTVHelp(FALSE); writeClassHierarchy(ol,ftv,addToIndex,ClassDef::Class); - QGString outStr; - FTextStream t(&outStr); + std::stringstream t; ftv->generateTreeViewInline(t); ol.pushGeneratorState(); ol.disableAllBut(OutputGenerator::Html); - ol.writeString(outStr); + ol.writeString(t.str().c_str()); ol.popGeneratorState(); delete ftv; } @@ -1098,12 +1094,11 @@ static void writeHierarchicalInterfaceIndex(OutputList &ol) } FTVHelp* ftv = new FTVHelp(FALSE); writeClassHierarchy(ol,ftv,addToIndex,ClassDef::Interface); - QGString outStr; - FTextStream t(&outStr); + std::stringstream t; ftv->generateTreeViewInline(t); ol.pushGeneratorState(); ol.disableAllBut(OutputGenerator::Html); - ol.writeString(outStr); + ol.writeString(t.str().c_str()); ol.popGeneratorState(); delete ftv; } @@ -1205,12 +1200,11 @@ static void writeHierarchicalExceptionIndex(OutputList &ol) } FTVHelp* ftv = new FTVHelp(FALSE); writeClassHierarchy(ol,ftv,addToIndex,ClassDef::Exception); - QGString outStr; - FTextStream t(&outStr); + std::stringstream t; ftv->generateTreeViewInline(t); ol.pushGeneratorState(); ol.disableAllBut(OutputGenerator::Html); - ol.writeString(outStr); + ol.writeString(t.str().c_str()); ol.popGeneratorState(); delete ftv; } @@ -1462,10 +1456,9 @@ static void writeFileIndex(OutputList &ol) FTVHelp* ftv = new FTVHelp(FALSE); writeDirHierarchy(ol,ftv,addToIndex); - QGString outStr; - FTextStream t(&outStr); + std::stringstream t; ftv->generateTreeViewInline(t); - ol.writeString(outStr); + ol.writeString(t.str().c_str()); delete ftv; ol.popGeneratorState(); @@ -1870,10 +1863,9 @@ static void writeNamespaceIndex(OutputList &ol) } FTVHelp* ftv = new FTVHelp(FALSE); writeNamespaceTree(*Doxygen::namespaceLinkedMap,ftv,TRUE,addToIndex); - QGString outStr; - FTextStream t(&outStr); + std::stringstream t; ftv->generateTreeViewInline(t); - ol.writeString(outStr); + ol.writeString(t.str().c_str()); delete ftv; if (addToIndex) { @@ -2397,10 +2389,9 @@ static void writeAnnotatedIndexGeneric(OutputList &ol,const AnnotatedIndexContex FTVHelp ftv(false); writeClassTreeInsideNamespace(*Doxygen::namespaceLinkedMap,&ftv,TRUE,addToIndex,ctx.compoundType); writeClassTree(*Doxygen::classLinkedMap,&ftv,addToIndex,TRUE,ctx.compoundType); - QGString outStr; - FTextStream t(&outStr); + std::stringstream t; ftv.generateTreeViewInline(t); - ol.writeString(outStr); + ol.writeString(t.str().c_str()); if (addToIndex) { Doxygen::indexList->decContentsDepth(); @@ -3607,10 +3598,9 @@ static void writePageIndex(OutputList &ol) writePages(pd.get(),ftv); } } - QGString outStr; - FTextStream t(&outStr); + std::stringstream t; ftv->generateTreeViewInline(t); - ol.writeString(outStr); + ol.writeString(t.str().c_str()); delete ftv; } @@ -4003,11 +3993,10 @@ static void writeGroupIndex(OutputList &ol) } FTVHelp* ftv = new FTVHelp(FALSE); writeGroupHierarchy(ol,ftv,addToIndex); - QGString outStr; - FTextStream t(&outStr); + std::stringstream t; ftv->generateTreeViewInline(t); ol.disableAllBut(OutputGenerator::Html); - ol.writeString(outStr); + ol.writeString(t.str().c_str()); delete ftv; if (addToIndex) { @@ -4783,7 +4772,7 @@ static bool quickLinkVisible(LayoutNavEntry::Kind kind) } template<class T,std::size_t total> -void renderMemberIndicesAsJs(FTextStream &t, +void renderMemberIndicesAsJs(std::ostream &t, const int *numDocumented, const std::array<MemberIndexMap,total> &memberLists, const T *(*getInfo)(size_t hl)) @@ -4800,7 +4789,7 @@ void renderMemberIndicesAsJs(FTextStream &t, t << "children:["; firstMember=FALSE; } - t << endl << "{text:\"" << convertToJSString(getInfo(i)->title) << "\",url:\"" + t << "\n{text:\"" << convertToJSString(getInfo(i)->title) << "\",url:\"" << convertToJSString(getInfo(i)->fname+Doxygen::htmlFileExtension) << "\""; // Check if we have many members, then add sub entries per letter... @@ -4813,11 +4802,11 @@ void renderMemberIndicesAsJs(FTextStream &t, { multiPageIndex=TRUE; } - t << ",children:[" << endl; + t << ",children:[\n"; bool firstLetter=TRUE; for (const auto &kv : memberLists[i]) { - if (!firstLetter) t << "," << endl; + if (!firstLetter) t << ",\n"; std::string letter = kv.first; QCString ci = letter; QCString is = letterToLabel(ci); @@ -4843,7 +4832,7 @@ void renderMemberIndicesAsJs(FTextStream &t, } } -static bool renderQuickLinksAsJs(FTextStream &t,LayoutNavEntry *root,bool first) +static bool renderQuickLinksAsJs(std::ostream &t,LayoutNavEntry *root,bool first) { int count=0; for (const auto &entry : root->children()) @@ -4854,12 +4843,12 @@ static bool renderQuickLinksAsJs(FTextStream &t,LayoutNavEntry *root,bool first) { bool firstChild = TRUE; if (!first) t << ","; - t << "children:[" << endl; + t << "children:[\n"; for (const auto &entry : root->children()) { if (entry->visible() && quickLinkVisible(entry->kind())) { - if (!firstChild) t << "," << endl; + if (!firstChild) t << ",\n"; firstChild=FALSE; QCString url = entry->url(); t << "{text:\"" << convertToJSString(entry->title()) << "\",url:\"" @@ -4896,16 +4885,15 @@ static void writeMenuData() { if (!Config_getBool(GENERATE_HTML) || Config_getBool(DISABLE_INDEX)) return; QCString outputDir = Config_getBool(HTML_OUTPUT); - QFile f(outputDir+"/menudata.js"); LayoutNavEntry *root = LayoutDocManager::instance().rootNavEntry(); - if (f.open(IO_WriteOnly)) + std::ofstream t(outputDir.str()+"/menudata.js",std::ofstream::out | std::ofstream::binary); + if (t.is_open()) { - FTextStream t(&f); t << JAVASCRIPT_LICENSE_TEXT; t << "var menudata={"; bool hasChildren = renderQuickLinksAsJs(t,root,TRUE); if (hasChildren) t << "]"; - t << "}" << endl; + t << "}\n"; } } diff --git a/src/index.h b/src/index.h index e11304e..042d3ee 100644 --- a/src/index.h +++ b/src/index.h @@ -26,7 +26,6 @@ class Definition; class DefinitionMutable; class MemberDef; class OutputList; -class FTextStream; /** \brief Abstract interface for index generators. */ class IndexIntf diff --git a/src/latexdocvisitor.cpp b/src/latexdocvisitor.cpp index 6d3ced1..9ead3fc 100644 --- a/src/latexdocvisitor.cpp +++ b/src/latexdocvisitor.cpp @@ -49,7 +49,7 @@ static const char *getSectionName(int level) return secLabels[QMIN(maxLevels-1,l)]; } -static void visitPreStart(FTextStream &t, bool hasCaption, QCString name, QCString width, QCString height, bool inlineImage = FALSE) +static void visitPreStart(std::ostream &t, bool hasCaption, QCString name, QCString width, QCString height, bool inlineImage = FALSE) { if (inlineImage) { @@ -119,7 +119,7 @@ static void visitPreStart(FTextStream &t, bool hasCaption, QCString name, QCStr -static void visitPostEnd(FTextStream &t, bool hasCaption, bool inlineImage = FALSE) +static void visitPostEnd(std::ostream &t, bool hasCaption, bool inlineImage = FALSE) { if (inlineImage) { @@ -173,7 +173,7 @@ QCString LatexDocVisitor::escapeMakeIndexChars(const char *s) } -LatexDocVisitor::LatexDocVisitor(FTextStream &t,LatexCodeGenerator &ci, +LatexDocVisitor::LatexDocVisitor(std::ostream &t,LatexCodeGenerator &ci, const char *langExt,bool insideTabbing) : DocVisitor(DocVisitor_Latex), m_t(t), m_ci(ci), m_insidePre(FALSE), m_insideItem(FALSE), m_hide(FALSE), m_hideCaption(FALSE), m_insideTabbing(insideTabbing), @@ -379,21 +379,21 @@ void LatexDocVisitor::visit(DocVerbatim *s) dotindex++, ".dot" ); - QFile file(fileName); - if (!file.open(IO_WriteOnly)) + std::ofstream file(fileName.str(),std::ofstream::out | std::ofstream::binary); + if (!file.is_open()) { err("Could not open file %s for writing\n",fileName.data()); } else { - file.writeBlock( s->text(), s->text().length() ); + file.write( s->text().data(), s->text().length() ); file.close(); startDotFile(fileName,s->width(),s->height(),s->hasCaption()); visitCaption(this, s->children()); endDotFile(s->hasCaption()); - if (Config_getBool(DOT_CLEANUP)) file.remove(); + if (Config_getBool(DOT_CLEANUP)) Dir().remove(fileName.str()); } } break; @@ -406,22 +406,23 @@ void LatexDocVisitor::visit(DocVerbatim *s) (Config_getString(LATEX_OUTPUT)+"/inline_mscgraph_").data(), mscindex++ ); - QFile file(baseName+".msc"); - if (!file.open(IO_WriteOnly)) + std::string fileName = baseName.str()+".msc"; + std::ofstream file(fileName,std::ofstream::out | std::ofstream::binary); + if (!file.is_open()) { - err("Could not open file %s.msc for writing\n",baseName.data()); + err("Could not open file %s for writing\n",fileName.c_str()); } else { QCString text = "msc {"; text+=s->text(); text+="}"; - file.writeBlock( text, text.length() ); + file.write( text.data(), text.length() ); file.close(); writeMscFile(baseName, s); - if (Config_getBool(DOT_CLEANUP)) file.remove(); + if (Config_getBool(DOT_CLEANUP)) Dir().remove(fileName); } } break; @@ -439,11 +440,11 @@ void LatexDocVisitor::visit(DocVerbatim *s) void LatexDocVisitor::visit(DocAnchor *anc) { if (m_hide) return; - m_t << "\\label{" << stripPath(anc->file()) << "_" << anc->anchor() << "}%" << endl; + m_t << "\\label{" << stripPath(anc->file()) << "_" << anc->anchor() << "}%\n"; if (!anc->file().isEmpty() && Config_getBool(PDF_HYPERLINKS)) { m_t << "\\Hypertarget{" << stripPath(anc->file()) << "_" << anc->anchor() - << "}%" << endl; + << "}%\n"; } } @@ -595,7 +596,7 @@ void LatexDocVisitor::visit(DocIncOperator *op) } else { - if (!m_hide) m_t << endl; + if (!m_hide) m_t << "\n"; } } @@ -702,7 +703,7 @@ void LatexDocVisitor::visitPost(DocPara *p) !(p->parent() && // and for parameter sections p->parent()->kind()==DocNode::Kind_ParamSect ) - ) m_t << endl << endl; + ) m_t << "\n\n"; } void LatexDocVisitor::visitPre(DocRoot *) @@ -873,13 +874,13 @@ void LatexDocVisitor::visitPost(DocTitle *) void LatexDocVisitor::visitPre(DocSimpleList *) { if (m_hide) return; - m_t << "\\begin{DoxyItemize}" << endl; + m_t << "\\begin{DoxyItemize}\n"; } void LatexDocVisitor::visitPost(DocSimpleList *) { if (m_hide) return; - m_t << "\\end{DoxyItemize}" << endl; + m_t << "\\end{DoxyItemize}\n"; } void LatexDocVisitor::visitPre(DocSimpleListItem *) @@ -901,7 +902,7 @@ void LatexDocVisitor::visitPre(DocSection *s) } m_t << "\\" << getSectionName(s->level()) << "{"; filter(convertCharEntitiesToUTF8(s->title().data())); - m_t << "}\\label{" << stripPath(s->file()) << "_" << s->anchor() << "}" << endl; + m_t << "}\\label{" << stripPath(s->file()) << "_" << s->anchor() << "}\n"; } void LatexDocVisitor::visitPost(DocSection *) @@ -945,7 +946,7 @@ void LatexDocVisitor::visitPost(DocHtmlListItem *) //void LatexDocVisitor::visitPost(DocHtmlPre *) //{ // m_insidePre=FALSE; -// m_t << "\\end{alltt}\\normalsize " << endl; +// m_t << "\\end{alltt}\\normalsize \n"; //} @@ -1041,7 +1042,7 @@ static bool tableIsNested(const DocNode *n) return isNested; } -static void writeStartTableCommand(FTextStream &t,const DocNode *n,int cols) +static void writeStartTableCommand(std::ostream &t,const DocNode *n,int cols) { if (tableIsNested(n)) { @@ -1054,7 +1055,7 @@ static void writeStartTableCommand(FTextStream &t,const DocNode *n,int cols) //return isNested ? "TabularNC" : "TabularC"; } -static void writeEndTableCommand(FTextStream &t,const DocNode *n) +static void writeEndTableCommand(std::ostream &t,const DocNode *n) { if (tableIsNested(n)) { @@ -1080,7 +1081,7 @@ void LatexDocVisitor::visitPre(DocHtmlTable *t) m_t << "\\hypertarget{" << stripPath(c->file()) << "_" << c->anchor() << "}{}"; } - m_t << endl; + m_t << "\n"; } writeStartTableCommand(m_t,t->parent(),(uint)t->numColumns()); @@ -1199,14 +1200,14 @@ void LatexDocVisitor::visitPost(DocHtmlRow *row) { if (firstRow()) { - m_t << "\\endfirsthead" << endl; - m_t << "\\hline" << endl; - m_t << "\\endfoot" << endl; - m_t << "\\hline" << endl; + m_t << "\\endfirsthead\n"; + m_t << "\\hline\n"; + m_t << "\\endfoot\n"; + m_t << "\\hline\n"; } else { - m_t << "\\endhead" << endl; + m_t << "\\endhead\n"; } } } @@ -1328,7 +1329,7 @@ void LatexDocVisitor::visitPre(DocInternal *) void LatexDocVisitor::visitPost(DocInternal *) { if (m_hide) return; - //m_t << "\\end{DoxyInternal}" << endl; + //m_t << "\\end{DoxyInternal}\n"; } void LatexDocVisitor::visitPre(DocHRef *href) @@ -1487,23 +1488,23 @@ void LatexDocVisitor::visitPost(DocSecRefItem *ref) { m_t << "}}"; } - m_t << "}{\\ref{" << ref->file() << "_" << ref->anchor() << "}}{}" << endl; + m_t << "}{\\ref{" << ref->file() << "_" << ref->anchor() << "}}{}\n"; } void LatexDocVisitor::visitPre(DocSecRefList *) { if (m_hide) return; - m_t << "\\footnotesize" << endl; - m_t << "\\begin{multicols}{2}" << endl; - m_t << "\\begin{DoxyCompactList}" << endl; + m_t << "\\footnotesize\n"; + m_t << "\\begin{multicols}{2}\n"; + m_t << "\\begin{DoxyCompactList}\n"; } void LatexDocVisitor::visitPost(DocSecRefList *) { if (m_hide) return; - m_t << "\\end{DoxyCompactList}" << endl; - m_t << "\\end{multicols}" << endl; - m_t << "\\normalsize" << endl; + m_t << "\\end{DoxyCompactList}\n"; + m_t << "\\end{multicols}\n"; + m_t << "\\normalsize\n"; } void LatexDocVisitor::visitPre(DocParamSect *s) @@ -1661,8 +1662,8 @@ void LatexDocVisitor::visitPost(DocParamList *pl) parentType==DocParamSect::TemplateParam; if (useTable) { - m_t << "\\\\" << endl - << "\\hline" << endl; + m_t << "\\\\\n" + << "\\hline\n"; } } @@ -1673,7 +1674,7 @@ void LatexDocVisitor::visitPre(DocXRefItem *x) if (x->title().isEmpty()) return; m_t << "\\begin{DoxyRefDesc}{"; filter(x->title()); - m_t << "}" << endl; + m_t << "}\n"; bool anonymousEnum = x->file()=="@"; m_t << "\\item["; if (pdfHyperlinks && !anonymousEnum) @@ -1698,7 +1699,7 @@ void LatexDocVisitor::visitPost(DocXRefItem *x) { if (m_hide) return; if (x->title().isEmpty()) return; - m_t << "\\end{DoxyRefDesc}" << endl; + m_t << "\\end{DoxyRefDesc}\n"; } void LatexDocVisitor::visitPre(DocInternalRef *ref) @@ -1724,13 +1725,13 @@ void LatexDocVisitor::visitPost(DocText *) void LatexDocVisitor::visitPre(DocHtmlBlockQuote *) { if (m_hide) return; - m_t << "\\begin{quote}" << endl; + m_t << "\\begin{quote}\n"; } void LatexDocVisitor::visitPost(DocHtmlBlockQuote *) { if (m_hide) return; - m_t << "\\end{quote}" << endl; + m_t << "\\end{quote}\n"; } void LatexDocVisitor::visitPre(DocVhdlFlow *) diff --git a/src/latexdocvisitor.h b/src/latexdocvisitor.h index cd6c442..2e2faa6 100644 --- a/src/latexdocvisitor.h +++ b/src/latexdocvisitor.h @@ -21,14 +21,13 @@ #include "docvisitor.h" #include <qcstring.h> -class FTextStream; class LatexCodeGenerator; /*! @brief Concrete visitor implementation for LaTeX output. */ class LatexDocVisitor : public DocVisitor { public: - LatexDocVisitor(FTextStream &t,LatexCodeGenerator &ci, + LatexDocVisitor(std::ostream &t,LatexCodeGenerator &ci, const char *langExt,bool insideTabbing); //-------------------------------------- @@ -177,7 +176,7 @@ class LatexDocVisitor : public DocVisitor // state variables //-------------------------------------- - FTextStream &m_t; + std::ostream &m_t; LatexCodeGenerator &m_ci; bool m_insidePre; bool m_insideItem; diff --git a/src/latexgen.cpp b/src/latexgen.cpp index a74e3ed..f9b78f0 100644 --- a/src/latexgen.cpp +++ b/src/latexgen.cpp @@ -15,9 +15,9 @@ * */ -#include <stdlib.h> +#include <cstdlib> +#include <sstream> -#include <qdir.h> #include "latexgen.h" #include "config.h" #include "message.h" @@ -48,22 +48,21 @@ static QCString g_header; static QCString g_footer; -LatexCodeGenerator::LatexCodeGenerator(FTextStream &t,const QCString &relPath,const QCString &sourceFileName) - : m_relPath(relPath), m_sourceFileName(sourceFileName) +LatexCodeGenerator::LatexCodeGenerator(std::ostream &t,const QCString &relPath,const QCString &sourceFileName) + : m_t(nullptr), m_relPath(relPath), m_sourceFileName(sourceFileName) { m_prettyCode=Config_getBool(LATEX_SOURCE_CODE); setTextStream(t); } -LatexCodeGenerator::LatexCodeGenerator() +LatexCodeGenerator::LatexCodeGenerator() : m_t(nullptr) { m_prettyCode=Config_getBool(LATEX_SOURCE_CODE); } -void LatexCodeGenerator::setTextStream(FTextStream &t) +void LatexCodeGenerator::setTextStream(std::ostream &t) { - m_streamSet = t.device()!=0; - m_t.setDevice(t.device()); + m_t.rdbuf(t.rdbuf()); } void LatexCodeGenerator::setRelativePath(const QCString &path) @@ -303,8 +302,8 @@ static void writeLatexMakefile() { bool generateBib = !CitationManager::instance().isEmpty(); QCString fileName=Config_getString(LATEX_OUTPUT)+"/Makefile"; - QFile file(fileName); - if (!file.open(IO_WriteOnly)) + std::ofstream t(fileName.str(),std::ofstream::out | std::ofstream::binary); + if (!t.is_open()) { term("Could not open file %s for writing\n",fileName.data()); } @@ -312,85 +311,84 @@ static void writeLatexMakefile() QCString latex_command = theTranslator->latexCommandName(); QCString mkidx_command = Config_getString(MAKEINDEX_CMD_NAME); // end insertion by KONNO Akihisa <konno@researchers.jp> 2002-03-05 - FTextStream t(&file); if (!Config_getBool(USE_PDFLATEX)) // use plain old latex { - t << "LATEX_CMD=" << latex_command << endl - << endl - << "all: refman.dvi" << endl - << endl - << "ps: refman.ps" << endl - << endl - << "pdf: refman.pdf" << endl - << endl - << "ps_2on1: refman_2on1.ps" << endl - << endl - << "pdf_2on1: refman_2on1.pdf" << endl - << endl - << "refman.ps: refman.dvi" << endl - << "\tdvips -o refman.ps refman.dvi" << endl - << endl; - t << "refman.pdf: refman.ps" << endl; - t << "\tps2pdf refman.ps refman.pdf" << endl << endl; - t << "refman.dvi: clean refman.tex doxygen.sty" << endl - << "\techo \"Running latex...\"" << endl - << "\t$(LATEX_CMD) refman.tex" << endl - << "\techo \"Running makeindex...\"" << endl - << "\t" << mkidx_command << " refman.idx" << endl; + t << "LATEX_CMD=" << latex_command << "\n" + << "\n" + << "all: refman.dvi\n" + << "\n" + << "ps: refman.ps\n" + << "\n" + << "pdf: refman.pdf\n" + << "\n" + << "ps_2on1: refman_2on1.ps\n" + << "\n" + << "pdf_2on1: refman_2on1.pdf\n" + << "\n" + << "refman.ps: refman.dvi\n" + << "\tdvips -o refman.ps refman.dvi\n" + << "\n"; + t << "refman.pdf: refman.ps\n"; + t << "\tps2pdf refman.ps refman.pdf\n\n"; + t << "refman.dvi: clean refman.tex doxygen.sty\n" + << "\techo \"Running latex...\"\n" + << "\t$(LATEX_CMD) refman.tex\n" + << "\techo \"Running makeindex...\"\n" + << "\t" << mkidx_command << " refman.idx\n"; if (generateBib) { - t << "\techo \"Running bibtex...\"" << endl; - t << "\tbibtex refman" << endl; - t << "\techo \"Rerunning latex....\"" << endl; - t << "\t$(LATEX_CMD) refman.tex" << endl; + t << "\techo \"Running bibtex...\"\n"; + t << "\tbibtex refman\n"; + t << "\techo \"Rerunning latex....\"\n"; + t << "\t$(LATEX_CMD) refman.tex\n"; } - t << "\techo \"Rerunning latex....\"" << endl - << "\t$(LATEX_CMD) refman.tex" << endl - << "\tlatex_count=8 ; \\" << endl - << "\twhile egrep -s 'Rerun (LaTeX|to get cross-references right)' refman.log && [ $$latex_count -gt 0 ] ;\\" << endl - << "\t do \\" << endl - << "\t echo \"Rerunning latex....\" ;\\" << endl - << "\t $(LATEX_CMD) refman.tex ; \\" << endl - << "\t latex_count=`expr $$latex_count - 1` ;\\" << endl - << "\t done" << endl - << "\t" << mkidx_command << " refman.idx" << endl - << "\t$(LATEX_CMD) refman.tex" << endl << endl - << "refman_2on1.ps: refman.ps" << endl - << "\tpsnup -2 refman.ps >refman_2on1.ps" << endl - << endl - << "refman_2on1.pdf: refman_2on1.ps" << endl - << "\tps2pdf refman_2on1.ps refman_2on1.pdf" << endl; + t << "\techo \"Rerunning latex....\"\n" + << "\t$(LATEX_CMD) refman.tex\n" + << "\tlatex_count=8 ; \\\n" + << "\twhile egrep -s 'Rerun (LaTeX|to get cross-references right)' refman.log && [ $$latex_count -gt 0 ] ;\\\n" + << "\t do \\\n" + << "\t echo \"Rerunning latex....\" ;\\\n" + << "\t $(LATEX_CMD) refman.tex ; \\\n" + << "\t latex_count=`expr $$latex_count - 1` ;\\\n" + << "\t done\n" + << "\t" << mkidx_command << " refman.idx\n" + << "\t$(LATEX_CMD) refman.tex\n\n" + << "refman_2on1.ps: refman.ps\n" + << "\tpsnup -2 refman.ps >refman_2on1.ps\n" + << "\n" + << "refman_2on1.pdf: refman_2on1.ps\n" + << "\tps2pdf refman_2on1.ps refman_2on1.pdf\n"; } else // use pdflatex for higher quality output { - t << "LATEX_CMD=" << latex_command << endl - << endl; - t << "all: refman.pdf" << endl << endl - << "pdf: refman.pdf" << endl << endl; - t << "refman.pdf: clean refman.tex" << endl; - t << "\t$(LATEX_CMD) refman" << endl; - t << "\t" << mkidx_command << " refman.idx" << endl; + t << "LATEX_CMD=" << latex_command << "\n" + << "\n"; + t << "all: refman.pdf\n\n" + << "pdf: refman.pdf\n\n"; + t << "refman.pdf: clean refman.tex\n"; + t << "\t$(LATEX_CMD) refman\n"; + t << "\t" << mkidx_command << " refman.idx\n"; if (generateBib) { - t << "\tbibtex refman" << endl; - t << "\t$(LATEX_CMD) refman" << endl; + t << "\tbibtex refman\n"; + t << "\t$(LATEX_CMD) refman\n"; } - t << "\t$(LATEX_CMD) refman" << endl - << "\tlatex_count=8 ; \\" << endl - << "\twhile egrep -s 'Rerun (LaTeX|to get cross-references right)' refman.log && [ $$latex_count -gt 0 ] ;\\" << endl - << "\t do \\" << endl - << "\t echo \"Rerunning latex....\" ;\\" << endl - << "\t $(LATEX_CMD) refman ;\\" << endl - << "\t latex_count=`expr $$latex_count - 1` ;\\" << endl - << "\t done" << endl - << "\t" << mkidx_command << " refman.idx" << endl - << "\t$(LATEX_CMD) refman" << endl << endl; - } - - t << endl - << "clean:" << endl + t << "\t$(LATEX_CMD) refman\n" + << "\tlatex_count=8 ; \\\n" + << "\twhile egrep -s 'Rerun (LaTeX|to get cross-references right)' refman.log && [ $$latex_count -gt 0 ] ;\\\n" + << "\t do \\\n" + << "\t echo \"Rerunning latex....\" ;\\\n" + << "\t $(LATEX_CMD) refman ;\\\n" + << "\t latex_count=`expr $$latex_count - 1` ;\\\n" + << "\t done\n" + << "\t" << mkidx_command << " refman.idx\n" + << "\t$(LATEX_CMD) refman\n\n"; + } + + t << "\n" + << "clean:\n" << "\trm -f " - << "*.ps *.dvi *.aux *.toc *.idx *.ind *.ilg *.log *.out *.brf *.blg *.bbl refman.pdf" << endl; + << "*.ps *.dvi *.aux *.toc *.idx *.ind *.ilg *.log *.out *.brf *.blg *.bbl refman.pdf\n"; } static void writeMakeBat() @@ -400,80 +398,79 @@ static void writeMakeBat() QCString fileName=dir+"/make.bat"; QCString latex_command = theTranslator->latexCommandName(); QCString mkidx_command = Config_getString(MAKEINDEX_CMD_NAME); - QFile file(fileName); bool generateBib = !CitationManager::instance().isEmpty(); - if (!file.open(IO_WriteOnly)) + std::ofstream t(fileName.str(),std::ofstream::out | std::ofstream::binary); + if (!t.is_open()) { term("Could not open file %s for writing\n",fileName.data()); } - FTextStream t(&file); - t << "set Dir_Old=%cd%\n"; - t << "cd /D %~dp0\n\n"; - t << "del /s /f *.ps *.dvi *.aux *.toc *.idx *.ind *.ilg *.log *.out *.brf *.blg *.bbl refman.pdf\n\n"; + t << "set Dir_Old=%cd%\r\n"; + t << "cd /D %~dp0\r\n\r\n"; + t << "del /s /f *.ps *.dvi *.aux *.toc *.idx *.ind *.ilg *.log *.out *.brf *.blg *.bbl refman.pdf\r\n\r\n"; if (!Config_getBool(USE_PDFLATEX)) // use plain old latex { - t << "set LATEX_CMD=" << latex_command << "\n"; - t << "%LATEX_CMD% refman.tex\n"; - t << "echo ----\n"; - t << mkidx_command << " refman.idx\n"; + t << "set LATEX_CMD=" << latex_command << "\r\n"; + t << "%LATEX_CMD% refman.tex\r\n"; + t << "echo ----\r\n"; + t << mkidx_command << " refman.idx\r\n"; if (generateBib) { - t << "bibtex refman\n"; - t << "echo ----\n"; - t << "\t%LATEX_CMD% refman.tex\n"; + t << "bibtex refman\r\n"; + t << "echo ----\r\n"; + t << "\t%LATEX_CMD% refman.tex\r\n"; } - t << "setlocal enabledelayedexpansion\n"; - t << "set count=8\n"; - t << ":repeat\n"; - t << "set content=X\n"; - t << "for /F \"tokens=*\" %%T in ( 'findstr /C:\"Rerun LaTeX\" refman.log' ) do set content=\"%%~T\"\n"; - t << "if !content! == X for /F \"tokens=*\" %%T in ( 'findstr /C:\"Rerun to get cross-references right\" refman.log' ) do set content=\"%%~T\"\n"; - t << "if !content! == X goto :skip\n"; - t << "set /a count-=1\n"; - t << "if !count! EQU 0 goto :skip\n\n"; - t << "echo ----\n"; - t << "%LATEX_CMD% refman.tex\n"; - t << "goto :repeat\n"; - t << ":skip\n"; - t << "endlocal\n"; - t << mkidx_command << " refman.idx\n"; - t << "%LATEX_CMD% refman.tex\n"; - t << "dvips -o refman.ps refman.dvi\n"; + t << "setlocal enabledelayedexpansion\r\n"; + t << "set count=8\r\n"; + t << ":repeat\r\n"; + t << "set content=X\r\n"; + t << "for /F \"tokens=*\" %%T in ( 'findstr /C:\"Rerun LaTeX\" refman.log' ) do set content=\"%%~T\"\r\n"; + t << "if !content! == X for /F \"tokens=*\" %%T in ( 'findstr /C:\"Rerun to get cross-references right\" refman.log' ) do set content=\"%%~T\"\r\n"; + t << "if !content! == X goto :skip\r\n"; + t << "set /a count-=1\r\n"; + t << "if !count! EQU 0 goto :skip\r\n\r\n"; + t << "echo ----\r\n"; + t << "%LATEX_CMD% refman.tex\r\n"; + t << "goto :repeat\r\n"; + t << ":skip\r\n"; + t << "endlocal\r\n"; + t << mkidx_command << " refman.idx\r\n"; + t << "%LATEX_CMD% refman.tex\r\n"; + t << "dvips -o refman.ps refman.dvi\r\n"; t << Portable::ghostScriptCommand(); t << " -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite " - "-sOutputFile=refman.pdf -c save pop -f refman.ps\n"; + "-sOutputFile=refman.pdf -c save pop -f refman.ps\r\n"; } else // use pdflatex { - t << "set LATEX_CMD=" << latex_command << "\n"; - t << "%LATEX_CMD% refman\n"; - t << "echo ----\n"; - t << mkidx_command << " refman.idx\n"; + t << "set LATEX_CMD=" << latex_command << "\r\n"; + t << "%LATEX_CMD% refman\r\n"; + t << "echo ----\r\n"; + t << mkidx_command << " refman.idx\r\n"; if (generateBib) { - t << "bibtex refman" << endl; - t << "%LATEX_CMD% refman" << endl; + t << "bibtex refman\r\n"; + t << "%LATEX_CMD% refman\r\n"; } - t << "echo ----\n"; - t << "%LATEX_CMD% refman\n\n"; - t << "setlocal enabledelayedexpansion\n"; - t << "set count=8\n"; - t << ":repeat\n"; - t << "set content=X\n"; - t << "for /F \"tokens=*\" %%T in ( 'findstr /C:\"Rerun LaTeX\" refman.log' ) do set content=\"%%~T\"\n"; - t << "if !content! == X for /F \"tokens=*\" %%T in ( 'findstr /C:\"Rerun to get cross-references right\" refman.log' ) do set content=\"%%~T\"\n"; - t << "if !content! == X goto :skip\n"; - t << "set /a count-=1\n"; - t << "if !count! EQU 0 goto :skip\n\n"; - t << "echo ----\n"; - t << "%LATEX_CMD% refman\n"; - t << "goto :repeat\n"; - t << ":skip\n"; - t << "endlocal\n"; - t << mkidx_command << " refman.idx\n"; - t << "%LATEX_CMD% refman\n"; - t << "cd /D %Dir_Old%\n"; - t << "set Dir_Old=\n"; + t << "echo ----\r\n"; + t << "%LATEX_CMD% refman\r\n\r\n"; + t << "setlocal enabledelayedexpansion\r\n"; + t << "set count=8\r\n"; + t << ":repeat\r\n"; + t << "set content=X\r\n"; + t << "for /F \"tokens=*\" %%T in ( 'findstr /C:\"Rerun LaTeX\" refman.log' ) do set content=\"%%~T\"\r\n"; + t << "if !content! == X for /F \"tokens=*\" %%T in ( 'findstr /C:\"Rerun to get cross-references right\" refman.log' ) do set content=\"%%~T\"\r\n"; + t << "if !content! == X goto :skip\r\n"; + t << "set /a count-=1\r\n"; + t << "if !count! EQU 0 goto :skip\r\n\r\n"; + t << "echo ----\r\n"; + t << "%LATEX_CMD% refman\r\n"; + t << "goto :repeat\r\n"; + t << ":skip\r\n"; + t << "endlocal\r\n"; + t << mkidx_command << " refman.idx\r\n"; + t << "%LATEX_CMD% refman\r\n"; + t << "cd /D %Dir_Old%\r\n"; + t << "set Dir_Old=\r\n"; } #endif } @@ -512,29 +509,26 @@ void LatexGenerator::init() createSubDirs(d); } -static void writeDefaultStyleSheet(FTextStream &t) +static void writeDefaultStyleSheet(std::ostream &t) { t << ResourceMgr::instance().getAsString("doxygen.sty"); } -void LatexGenerator::writeHeaderFile(QFile &f) +void LatexGenerator::writeHeaderFile(std::ostream &t) { - FTextStream t(&f); - t << "% Latex header for doxygen " << getDoxygenVersion() << endl; + t << "% Latex header for doxygen " << getDoxygenVersion() << "\n"; t << ResourceMgr::instance().getAsString("header.tex"); } -void LatexGenerator::writeFooterFile(QFile &f) +void LatexGenerator::writeFooterFile(std::ostream &t) { - FTextStream t(&f); - t << "% Latex footer for doxygen " << getDoxygenVersion() << endl; + t << "% Latex footer for doxygen " << getDoxygenVersion() << "\n"; t << ResourceMgr::instance().getAsString("footer.tex"); } -void LatexGenerator::writeStyleSheetFile(QFile &f) +void LatexGenerator::writeStyleSheetFile(std::ostream &t) { - FTextStream t(&f); - t << "% stylesheet for doxygen " << getDoxygenVersion() << endl; + t << "% stylesheet for doxygen " << getDoxygenVersion() << "\n"; writeDefaultStyleSheet(t); } @@ -629,10 +623,9 @@ static QCString substituteLatexKeywords(const QCString &str, style="plain"; } - QGString genString; - FTextStream tg(&genString); - QCString generatedBy; + std::stringstream tg; bool timeStamp = Config_getBool(LATEX_TIMESTAMP); + QCString generatedBy; if (timeStamp) { generatedBy = theTranslator->trGeneratedAt(dateToString(TRUE), Config_getString(PROJECT_NAME)); @@ -648,7 +641,7 @@ static QCString substituteLatexKeywords(const QCString &str, false, // insideTable false // keepSpaces ); - generatedBy = genString; + generatedBy = tg.str(); QCString latexFontenc = theTranslator->latexFontenc(); @@ -656,17 +649,13 @@ static QCString substituteLatexKeywords(const QCString &str, if (latexEmojiDirectory.isEmpty()) latexEmojiDirectory = "."; latexEmojiDirectory = substitute(latexEmojiDirectory,"\\","/"); - QGString genExtraLatexPackages; - FTextStream tg1(&genExtraLatexPackages); + std::stringstream tg1; writeExtraLatexPackages(tg1); - QCString extraLatexPackages; - extraLatexPackages = genExtraLatexPackages; + QCString extraLatexPackages = tg1.str(); - QGString genLatexSpecialFormulaChars; - FTextStream tg2(&genLatexSpecialFormulaChars); + std::stringstream tg2; writeLatexSpecialFormulaChars(tg2); - QCString latexSpecialFormulaChars; - latexSpecialFormulaChars = genLatexSpecialFormulaChars; + QCString latexSpecialFormulaChars = tg2.str(); QCString formulaMacrofile = Config_getString(FORMULA_MACROFILE); if (!formulaMacrofile.isEmpty()) @@ -1063,17 +1052,17 @@ void LatexGenerator::writeStyleInfo(int part) void LatexGenerator::newParagraph() { - t << endl << endl; + t << "\n" << "\n"; } void LatexGenerator::startParagraph(const char *) { - t << endl << endl; + t << "\n" << "\n"; } void LatexGenerator::endParagraph() { - t << endl << endl; + t << "\n" << "\n"; } void LatexGenerator::writeString(const char *text) @@ -1094,7 +1083,7 @@ void LatexGenerator::endIndexItem(const char *ref,const char *fn) { if (!ref && fn) { - t << "}{\\pageref{" << stripPath(fn) << "}}{}" << endl; + t << "}{\\pageref{" << stripPath(fn) << "}}{}\n"; } } @@ -1102,7 +1091,7 @@ void LatexGenerator::endIndexItem(const char *ref,const char *fn) //{ // t << "\\item\\contentsline{section}{"; // docify(text); -// t << "}{\\pageref{" << stripPath(text) << "}}" << endl; +// t << "}{\\pageref{" << stripPath(text) << "}}\n"; //} @@ -1146,7 +1135,7 @@ void LatexGenerator::writeStartAnnoItem(const char *,const char *, void LatexGenerator::writeEndAnnoItem(const char *name) { - t << "}{\\pageref{" << stripPath(name) << "}}{}" << endl; + t << "}{\\pageref{" << stripPath(name) << "}}{}\n"; } void LatexGenerator::startIndexKey() @@ -1167,7 +1156,7 @@ void LatexGenerator::startIndexValue(bool hasBrief) void LatexGenerator::endIndexValue(const char *name,bool /*hasBrief*/) { //if (hasBrief) t << ")"; - t << "}{\\pageref{" << stripPath(name) << "}}{}" << endl; + t << "}{\\pageref{" << stripPath(name) << "}}{}\n"; } //void LatexGenerator::writeClassLink(const char *,const char *, @@ -1260,14 +1249,14 @@ void LatexGenerator::startTitleHead(const char *fileName) void LatexGenerator::endTitleHead(const char *fileName,const char *name) { - t << "}" << endl; + t << "}\n"; if (name) { t << "\\label{" << stripPath(fileName) << "}\\index{"; t << latexEscapeLabelName(name); t << "@{"; t << latexEscapeIndexChars(name); - t << "}}" << endl; + t << "}}\n"; } } @@ -1312,7 +1301,7 @@ void LatexGenerator::startGroupHeader(int extraIndentLevel) void LatexGenerator::endGroupHeader(int) { m_disableLinks=FALSE; - t << "}" << endl; + t << "}\n"; } void LatexGenerator::startMemberHeader(const char *,int) @@ -1331,7 +1320,7 @@ void LatexGenerator::startMemberHeader(const char *,int) void LatexGenerator::endMemberHeader() { m_disableLinks=FALSE; - t << "}" << endl; + t << "}\n"; } void LatexGenerator::startMemberDoc(const char *clname, @@ -1355,7 +1344,7 @@ void LatexGenerator::startMemberDoc(const char *clname, t << latexEscapeLabelName(memname); t << "@{"; t << latexEscapeIndexChars(memname); - t << "}}" << endl; + t << "}}\n"; t << "\\index{"; t << latexEscapeLabelName(memname); @@ -1370,7 +1359,7 @@ void LatexGenerator::startMemberDoc(const char *clname, t << latexEscapeIndexChars(clname); t << "}"; } - t << "}" << endl; + t << "}\n"; } static const char *levelLab[] = { "doxysubsubsection","doxyparagraph","doxysubparagraph", "doxysubparagraph" }; bool compactLatex = Config_getBool(COMPACT_LATEX); @@ -1423,7 +1412,7 @@ void LatexGenerator::startDoxyAnchor(const char *fName,const char *, t << "\\label{"; if (fName) t << stripPath(fName); if (anchor) t << "_" << anchor; - t << "}} " << endl; + t << "}} \n"; } void LatexGenerator::endDoxyAnchor(const char *fName,const char *anchor) @@ -1433,18 +1422,18 @@ void LatexGenerator::endDoxyAnchor(const char *fName,const char *anchor) void LatexGenerator::writeAnchor(const char *fName,const char *name) { //printf("LatexGenerator::writeAnchor(%s,%s)\n",fName,name); - t << "\\label{" << stripPath(name) << "}" << endl; + t << "\\label{" << stripPath(name) << "}\n"; bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS); bool usePDFLatex = Config_getBool(USE_PDFLATEX); if (usePDFLatex && pdfHyperlinks) { if (fName) { - t << "\\Hypertarget{" << stripPath(fName) << "_" << stripPath(name) << "}" << endl; + t << "\\Hypertarget{" << stripPath(fName) << "_" << stripPath(name) << "}\n"; } else { - t << "\\Hypertarget{" << stripPath(name) << "}" << endl; + t << "\\Hypertarget{" << stripPath(name) << "}\n"; } } } @@ -1516,7 +1505,7 @@ void LatexGenerator::startSection(const char *lab,const char *,SectionType type) void LatexGenerator::endSection(const char *lab,SectionType) { - t << "}\\label{" << lab << "}" << endl; + t << "}\\label{" << lab << "}\n"; } @@ -1556,8 +1545,8 @@ void LatexGenerator::startAnonTypeScope(int indent) { if (indent==0) { - t << "\\begin{tabbing}" << endl; - t << "xx\\=xx\\=xx\\=xx\\=xx\\=xx\\=xx\\=xx\\=xx\\=\\kill" << endl; + t << "\\begin{tabbing}\n"; + t << "xx\\=xx\\=xx\\=xx\\=xx\\=xx\\=xx\\=xx\\=xx\\=\\kill\n"; m_insideTabbing=TRUE; } m_indent=indent; @@ -1567,7 +1556,7 @@ void LatexGenerator::endAnonTypeScope(int indent) { if (indent==0) { - t << endl << "\\end{tabbing}"; + t << "\n" << "\\end{tabbing}"; m_insideTabbing=FALSE; } m_indent=indent; @@ -1594,7 +1583,7 @@ void LatexGenerator::startMemberItem(const char *,int annoType,const char *) //printf("LatexGenerator::startMemberItem(%d)\n",annType); if (!m_insideTabbing) { - t << "\\item " << endl; + t << "\\item \n"; templateMemberItem = (annoType == 3); } } @@ -1606,7 +1595,7 @@ void LatexGenerator::endMemberItem() t << "\\\\"; } templateMemberItem = FALSE; - t << endl; + t << "\n"; } void LatexGenerator::startMemberDescription(const char *,const char *,bool) @@ -1666,13 +1655,13 @@ void LatexGenerator::writeNonBreakableSpace(int) void LatexGenerator::startDescTable(const char *title) { m_codeGen.incUsedTableLevel(); - t << "\\begin{DoxyEnumFields}{" << title << "}" << endl; + t << "\\begin{DoxyEnumFields}{" << title << "}\n"; } void LatexGenerator::endDescTable() { m_codeGen.decUsedTableLevel(); - t << "\\end{DoxyEnumFields}" << endl; + t << "\\end{DoxyEnumFields}\n"; } void LatexGenerator::startDescTableRow() @@ -1702,7 +1691,7 @@ void LatexGenerator::startDescTableData() void LatexGenerator::endDescTableData() { - t << "\\\\\n\\hline\n" << endl; + t << "\\\\\n\\hline\n\n"; } void LatexGenerator::lastIndexPage() @@ -1714,7 +1703,7 @@ void LatexGenerator::startMemberList() { if (!m_insideTabbing) { - t << "\\begin{DoxyCompactItemize}" << endl; + t << "\\begin{DoxyCompactItemize}\n"; } } @@ -1723,7 +1712,7 @@ void LatexGenerator::endMemberList() //printf("LatexGenerator::endMemberList(%d)\n",m_insideTabbing); if (!m_insideTabbing) { - t << "\\end{DoxyCompactItemize}" << endl; + t << "\\end{DoxyCompactItemize}\n"; } } @@ -1746,8 +1735,8 @@ void LatexGenerator::startMemberGroupHeader(bool hasHeader) void LatexGenerator::endMemberGroupHeader() { // changed back to rev 756 due to bug 660501 - t << "}\\par" << endl; - //t << "}" << endl; + t << "}\\par\n"; + //t << "}\n"; } void LatexGenerator::startMemberGroupDocs() @@ -1767,7 +1756,7 @@ void LatexGenerator::startMemberGroup() void LatexGenerator::endMemberGroup(bool hasHeader) { if (hasHeader)t << "\\end{Indent}"; - t << endl; + t << "\n"; } void LatexGenerator::startDotGraph() @@ -1818,12 +1807,12 @@ void LatexGenerator::endDirDepGraph(DotDirDeps &g) void LatexGenerator::startDescription() { - t << "\\begin{description}" << endl; + t << "\\begin{description}\n"; } void LatexGenerator::endDescription() { - t << "\\end{description}" << endl; + t << "\\end{description}\n"; m_firstDescItem=TRUE; } @@ -1837,7 +1826,7 @@ void LatexGenerator::endDescItem() { if (m_firstDescItem) { - t << "]" << endl; + t << "]\n"; m_firstDescItem=FALSE; } else @@ -1855,7 +1844,7 @@ void LatexGenerator::startExamples() void LatexGenerator::endExamples() { - t << "\\end{Desc}" << endl; + t << "\\end{Desc}\n"; } void LatexGenerator::startParamList(ParamListTypes,const char *title) @@ -1867,7 +1856,7 @@ void LatexGenerator::startParamList(ParamListTypes,const char *title) void LatexGenerator::endParamList() { - t << "\\end{Desc}" << endl; + t << "\\end{Desc}\n"; } void LatexGenerator::startParameterList(bool openBracket) @@ -1929,7 +1918,7 @@ void LatexGenerator::startConstraintList(const char *header) t << "\\begin{Desc}\n\\item["; docify(header); t << "]"; - t << "\\begin{description}" << endl; + t << "\\begin{description}\n"; } void LatexGenerator::startConstraintParam() @@ -1961,8 +1950,8 @@ void LatexGenerator::endConstraintDocs() void LatexGenerator::endConstraintList() { - t << "\\end{description}" << endl; - t << "\\end{Desc}" << endl; + t << "\\end{description}\n"; + t << "\\end{Desc}\n"; } void LatexGenerator::startInlineHeader() @@ -1979,7 +1968,7 @@ void LatexGenerator::startInlineHeader() void LatexGenerator::endInlineHeader() { - t << "}" << endl; + t << "}\n"; } void LatexGenerator::lineBreak(const char *) @@ -2007,7 +1996,7 @@ void LatexGenerator::startMemberDocSimple(bool isEnum) t << "\\begin{DoxyFields}{"; docify(theTranslator->trCompoundMembers()); } - t << "}" << endl; + t << "}\n"; } void LatexGenerator::endMemberDocSimple(bool isEnum) @@ -2015,11 +2004,11 @@ void LatexGenerator::endMemberDocSimple(bool isEnum) m_codeGen.decUsedTableLevel(); if (isEnum) { - t << "\\end{DoxyEnumFields}" << endl; + t << "\\end{DoxyEnumFields}\n"; } else { - t << "\\end{DoxyFields}" << endl; + t << "\\end{DoxyFields}\n"; } } @@ -2030,7 +2019,7 @@ void LatexGenerator::startInlineMemberType() void LatexGenerator::endInlineMemberType() { - t << "&" << endl; + t << "&\n"; m_insideTabbing = FALSE; } @@ -2041,7 +2030,7 @@ void LatexGenerator::startInlineMemberName() void LatexGenerator::endInlineMemberName() { - t << "&" << endl; + t << "&\n"; m_insideTabbing = FALSE; } @@ -2051,7 +2040,7 @@ void LatexGenerator::startInlineMemberDoc() void LatexGenerator::endInlineMemberDoc() { - t << "\\\\\n\\hline\n" << endl; + t << "\\\\\n\\hline\n\n"; } void LatexGenerator::startLabels() diff --git a/src/latexgen.h b/src/latexgen.h index 6be5de7..0a6309c 100644 --- a/src/latexgen.h +++ b/src/latexgen.h @@ -21,16 +21,14 @@ #include "config.h" #include "outputgen.h" -class QFile; - #define LATEX_STYLE_EXTENSION ".sty" class LatexCodeGenerator : public CodeOutputInterface { public: - LatexCodeGenerator(FTextStream &t,const QCString &relPath,const QCString &sourceFile); + LatexCodeGenerator(std::ostream &t,const QCString &relPath,const QCString &sourceFile); LatexCodeGenerator(); - void setTextStream(FTextStream &t); + void setTextStream(std::ostream &t); void setRelativePath(const QCString &path); void setSourceFileName(const QCString &sourceFileName); void codify(const char *text); @@ -67,7 +65,7 @@ class LatexCodeGenerator : public CodeOutputInterface const char *tooltip); void docify(const char *str); bool m_streamSet = false; - FTextStream m_t; + std::ostream m_t; QCString m_relPath; QCString m_sourceFileName; int m_col = 0; @@ -87,9 +85,9 @@ class LatexGenerator : public OutputGenerator virtual std::unique_ptr<OutputGenerator> clone() const; static void init(); - static void writeStyleSheetFile(QFile &f); - static void writeHeaderFile(QFile &f); - static void writeFooterFile(QFile &f); + static void writeStyleSheetFile(std::ostream &t); + static void writeHeaderFile(std::ostream &t); + static void writeFooterFile(std::ostream &t); virtual OutputType type() const { return Latex; } @@ -148,14 +146,14 @@ class LatexGenerator : public OutputGenerator void writeString(const char *text); void startIndexListItem() {} void endIndexListItem() {} - void startIndexList() { t << "\\begin{DoxyCompactList}" << endl; } - void endIndexList() { t << "\\end{DoxyCompactList}" << endl; } + void startIndexList() { t << "\\begin{DoxyCompactList}\n"; } + void endIndexList() { t << "\\end{DoxyCompactList}\n"; } void startIndexKey(); void endIndexKey(); void startIndexValue(bool); void endIndexValue(const char *,bool); - void startItemList() { t << "\\begin{DoxyCompactItemize}" << endl; } - void endItemList() { t << "\\end{DoxyCompactItemize}" << endl; } + void startItemList() { t << "\\begin{DoxyCompactItemize}\n"; } + void endItemList() { t << "\\end{DoxyCompactItemize}\n"; } void startIndexItem(const char *ref,const char *file); void endIndexItem(const char *ref,const char *file); void docify(const char *text); @@ -170,7 +168,7 @@ class LatexGenerator : public OutputGenerator void endTypewriter() { t << "}"; } void startGroupHeader(int); void endGroupHeader(int); - void startItemListItem() { t << "\\item " << endl; } + void startItemListItem() { t << "\\item \n"; } void endItemListItem() {} void startMemberSections() {} @@ -204,7 +202,7 @@ class LatexGenerator : public OutputGenerator void insertMemberAlign(bool) {} void insertMemberAlignLeft(int,bool){} - void writeRuler() { t << endl << endl; } + void writeRuler() { t << "\n\n"; } void writeAnchor(const char *fileName,const char *name); void startEmphasis() { t << "{\\em "; } void endEmphasis() { t << "}"; } @@ -225,11 +223,11 @@ class LatexGenerator : public OutputGenerator const char *path,const char *name); void writeEndAnnoItem(const char *name); void startSubsection() { t << "\\subsection*{"; } - void endSubsection() { t << "}" << endl; } + void endSubsection() { t << "}\n"; } void startSubsubsection() { t << "\\subsubsection*{"; } - void endSubsubsection() { t << "}" << endl; } - void startCenter() { t << "\\begin{center}" << endl; } - void endCenter() { t << "\\end{center}" << endl; } + void endSubsubsection() { t << "}\n"; } + void startCenter() { t << "\\begin{center}\n"; } + void endCenter() { t << "\\end{center}\n"; } void startSmall() { t << "\\footnotesize "; } void endSmall() { t << "\\normalsize "; } void startMemberDescription(const char *,const char *,bool); @@ -239,12 +237,12 @@ class LatexGenerator : public OutputGenerator void writeInheritedSectionTitle(const char *,const char *,const char *, const char *,const char *,const char *) {} void startDescList(SectionTypes) { t << "\\begin{Desc}\n\\item["; } - void endDescList() { t << "\\end{Desc}" << endl; } + void endDescList() { t << "\\end{Desc}\n"; } void startExamples(); void endExamples(); void startParamList(ParamListTypes,const char *title); void endParamList(); - void startDescForItem() { t << "\\par" << endl; } + void startDescForItem() { t << "\\par\n"; } void endDescForItem() {} void startSection(const char *,const char *,SectionType); void endSection(const char *,SectionType); @@ -293,7 +291,7 @@ class LatexGenerator : public OutputGenerator void endTextBlock(bool) {} void startMemberDocPrefixItem() {} - void endMemberDocPrefixItem() { t << "\\\\" << endl; } + void endMemberDocPrefixItem() { t << "\\\\\n"; } void startMemberDocName(bool) {} void endMemberDocName() {} void startParameterType(bool,const char *); diff --git a/src/layout.cpp b/src/layout.cpp index fe448f2..a01fb59 100644 --- a/src/layout.cpp +++ b/src/layout.cpp @@ -19,7 +19,6 @@ #include <array> #include <assert.h> -#include <qfile.h> #include "layout.h" #include "message.h" @@ -1553,14 +1552,13 @@ void LayoutDocManager::parse(const char *fileName) void writeDefaultLayoutFile(const char *fileName) { - QFile f(fileName); - bool ok = openOutputFile(fileName,f); + std::ofstream t(fileName,std::ofstream::out); + bool ok = openOutputFile(fileName,t); if (!ok) { err("Failed to open file %s for writing!\n",fileName); return; } - FTextStream t(&f); QCString layout_default = ResourceMgr::instance().getAsString("layout_default.xml"); t << substitute(layout_default,"$doxygenversion",getDoxygenVersion()); } diff --git a/src/mandocvisitor.cpp b/src/mandocvisitor.cpp index 0184e26..3839510 100644 --- a/src/mandocvisitor.cpp +++ b/src/mandocvisitor.cpp @@ -28,7 +28,7 @@ #include "emoji.h" #include "fileinfo.h" -ManDocVisitor::ManDocVisitor(FTextStream &t,CodeOutputInterface &ci, +ManDocVisitor::ManDocVisitor(std::ostream &t,CodeOutputInterface &ci, const char *langExt) : DocVisitor(DocVisitor_Man), m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE), m_firstCol(FALSE), m_indent(0), m_langExt(langExt) @@ -111,15 +111,15 @@ void ManDocVisitor::visit(DocURL *u) void ManDocVisitor::visit(DocLineBreak *) { if (m_hide) return; - m_t << endl << ".br" << endl; + m_t << "\n.br\n"; m_firstCol=TRUE; } void ManDocVisitor::visit(DocHorRuler *) { if (m_hide) return; - if (!m_firstCol) m_t << endl; - m_t << ".PP" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".PP\n"; m_firstCol=TRUE; } @@ -167,17 +167,17 @@ void ManDocVisitor::visit(DocStyleChange *s) case DocStyleChange::Preformatted: if (s->enable()) { - if (!m_firstCol) m_t << endl; - m_t << ".PP" << endl; - m_t << ".nf" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".PP\n"; + m_t << ".nf\n"; m_insidePre=TRUE; } else { m_insidePre=FALSE; - if (!m_firstCol) m_t << endl; - m_t << ".fi" << endl; - m_t << ".PP" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".fi\n"; + m_t << ".PP\n"; m_firstCol=TRUE; } break; @@ -198,25 +198,25 @@ void ManDocVisitor::visit(DocVerbatim *s) switch (s->type()) { case DocVerbatim::Code: // fall though - if (!m_firstCol) m_t << endl; - m_t << ".PP" << endl; - m_t << ".nf" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".PP\n"; + m_t << ".nf\n"; getCodeParser(lang).parseCode(m_ci,s->context(),s->text(), langExt, s->isExample(),s->exampleFile()); - if (!m_firstCol) m_t << endl; - m_t << ".fi" << endl; - m_t << ".PP" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".fi\n"; + m_t << ".PP\n"; m_firstCol=TRUE; break; case DocVerbatim::Verbatim: - if (!m_firstCol) m_t << endl; - m_t << ".PP" << endl; - m_t << ".nf" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".PP\n"; + m_t << ".nf\n"; m_t << s->text(); - if (!m_firstCol) m_t << endl; - m_t << ".fi" << endl; - m_t << ".PP" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".fi\n"; + m_t << ".PP\n"; m_firstCol=TRUE; break; case DocVerbatim::ManOnly: @@ -248,9 +248,9 @@ void ManDocVisitor::visit(DocInclude *inc) { case DocInclude::IncWithLines: { - if (!m_firstCol) m_t << endl; - m_t << ".PP" << endl; - m_t << ".nf" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".PP\n"; + m_t << ".nf\n"; FileInfo cfi( inc->file().str() ); FileDef *fd = createFileDef( cfi.dirPath(), cfi.fileName() ); getCodeParser(inc->extension()).parseCode(m_ci,inc->context(), @@ -266,16 +266,16 @@ void ManDocVisitor::visit(DocInclude *inc) TRUE ); delete fd; - if (!m_firstCol) m_t << endl; - m_t << ".fi" << endl; - m_t << ".PP" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".fi\n"; + m_t << ".PP\n"; m_firstCol=TRUE; } break; case DocInclude::Include: - if (!m_firstCol) m_t << endl; - m_t << ".PP" << endl; - m_t << ".nf" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".PP\n"; + m_t << ".nf\n"; getCodeParser(inc->extension()).parseCode(m_ci,inc->context(), inc->text(), langExt, @@ -288,9 +288,9 @@ void ManDocVisitor::visit(DocInclude *inc) 0, // memberDef FALSE ); - if (!m_firstCol) m_t << endl; - m_t << ".fi" << endl; - m_t << ".PP" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".fi\n"; + m_t << ".PP\n"; m_firstCol=TRUE; break; case DocInclude::DontInclude: @@ -305,19 +305,19 @@ void ManDocVisitor::visit(DocInclude *inc) m_t << inc->text(); break; case DocInclude::VerbInclude: - if (!m_firstCol) m_t << endl; - m_t << ".PP" << endl; - m_t << ".nf" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".PP\n"; + m_t << ".nf\n"; m_t << inc->text(); - if (!m_firstCol) m_t << endl; - m_t << ".fi" << endl; - m_t << ".PP" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".fi\n"; + m_t << ".PP\n"; m_firstCol=TRUE; break; case DocInclude::Snippet: - if (!m_firstCol) m_t << endl; - m_t << ".PP" << endl; - m_t << ".nf" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".PP\n"; + m_t << ".nf\n"; getCodeParser(inc->extension()).parseCode(m_ci, inc->context(), extractBlock(inc->text(),inc->blockId()), @@ -325,16 +325,16 @@ void ManDocVisitor::visit(DocInclude *inc) inc->isExample(), inc->exampleFile() ); - if (!m_firstCol) m_t << endl; - m_t << ".fi" << endl; - m_t << ".PP" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".fi\n"; + m_t << ".PP\n"; m_firstCol=TRUE; break; case DocInclude::SnipWithLines: { - if (!m_firstCol) m_t << endl; - m_t << ".PP" << endl; - m_t << ".nf" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".PP\n"; + m_t << ".nf\n"; FileInfo cfi( inc->file().str() ); FileDef *fd = createFileDef( cfi.dirPath(), cfi.fileName() ); getCodeParser(inc->extension()).parseCode(m_ci, @@ -351,9 +351,9 @@ void ManDocVisitor::visit(DocInclude *inc) TRUE // show line number ); delete fd; - if (!m_firstCol) m_t << endl; - m_t << ".fi" << endl; - m_t << ".PP" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".fi\n"; + m_t << ".PP\n"; m_firstCol=TRUE; } break; @@ -376,9 +376,9 @@ void ManDocVisitor::visit(DocIncOperator *op) { if (!m_hide) { - if (!m_firstCol) m_t << endl; - m_t << ".PP" << endl; - m_t << ".nf" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".PP\n"; + m_t << ".nf\n"; } pushHidden(m_hide); m_hide = TRUE; @@ -414,15 +414,15 @@ void ManDocVisitor::visit(DocIncOperator *op) m_hide = popHidden(); if (!m_hide) { - if (!m_firstCol) m_t << endl; - m_t << ".fi" << endl; - m_t << ".PP" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".fi\n"; + m_t << ".PP\n"; m_firstCol=TRUE; } } else { - if (!m_hide) m_t << endl; + if (!m_hide) m_t << "\n"; } } @@ -465,7 +465,7 @@ void ManDocVisitor::visitPost(DocAutoList *) { if (m_hide) return; m_indent-=2; - m_t << ".PP" << endl; + m_t << ".PP\n"; } void ManDocVisitor::visitPre(DocAutoListItem *li) @@ -473,7 +473,7 @@ void ManDocVisitor::visitPre(DocAutoListItem *li) if (m_hide) return; QCString ws; ws.fill(' ',m_indent-2); - if (!m_firstCol) m_t << endl; + if (!m_firstCol) m_t << "\n"; m_t << ".IP \"" << ws; if (((DocAutoList *)li->parent())->isEnumList()) { @@ -483,14 +483,14 @@ void ManDocVisitor::visitPre(DocAutoListItem *li) { m_t << "\\(bu\" " << m_indent; } - m_t << endl; + m_t << "\n"; m_firstCol=TRUE; } void ManDocVisitor::visitPost(DocAutoListItem *) { if (m_hide) return; - m_t << endl; + m_t << "\n"; m_firstCol=TRUE; } @@ -507,8 +507,8 @@ void ManDocVisitor::visitPost(DocPara *p) ) ) { - if (!m_firstCol) m_t << endl; - m_t << ".PP" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".PP\n"; m_firstCol=TRUE; } } @@ -526,8 +526,8 @@ void ManDocVisitor::visitPre(DocSimpleSect *s) if (m_hide) return; if (!m_firstCol) { - m_t << endl; - m_t << ".PP" << endl; + m_t << "\n"; + m_t << ".PP\n"; } m_t << "\\fB"; switch(s->type()) @@ -570,17 +570,17 @@ void ManDocVisitor::visitPre(DocSimpleSect *s) // special case 1: user defined title if (s->type()!=DocSimpleSect::User && s->type()!=DocSimpleSect::Rcs) { - m_t << "\\fP" << endl; - m_t << ".RS 4" << endl; + m_t << "\\fP\n"; + m_t << ".RS 4\n"; } } void ManDocVisitor::visitPost(DocSimpleSect *) { if (m_hide) return; - if (!m_firstCol) m_t << endl; - m_t << ".RE" << endl; - m_t << ".PP" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".RE\n"; + m_t << ".PP\n"; m_firstCol=TRUE; } @@ -591,23 +591,23 @@ void ManDocVisitor::visitPre(DocTitle *) void ManDocVisitor::visitPost(DocTitle *) { if (m_hide) return; - m_t << "\\fP" << endl; - m_t << ".RS 4" << endl; + m_t << "\\fP\n"; + m_t << ".RS 4\n"; } void ManDocVisitor::visitPre(DocSimpleList *) { if (m_hide) return; m_indent+=2; - if (!m_firstCol) m_t << endl; - m_t << ".PD 0" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".PD 0\n"; } void ManDocVisitor::visitPost(DocSimpleList *) { if (m_hide) return; m_indent-=2; - m_t << ".PP" << endl; + m_t << ".PP\n"; } void ManDocVisitor::visitPre(DocSimpleListItem *) @@ -615,27 +615,27 @@ void ManDocVisitor::visitPre(DocSimpleListItem *) if (m_hide) return; QCString ws; ws.fill(' ',m_indent-2); - if (!m_firstCol) m_t << endl; - m_t << ".IP \"" << ws << "\\(bu\" " << m_indent << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".IP \"" << ws << "\\(bu\" " << m_indent << "\n"; m_firstCol=TRUE; } void ManDocVisitor::visitPost(DocSimpleListItem *) { if (m_hide) return; - m_t << endl; + m_t << "\n"; m_firstCol=TRUE; } void ManDocVisitor::visitPre(DocSection *s) { if (m_hide) return; - if (!m_firstCol) m_t << endl; + if (!m_firstCol) m_t << "\n"; if (s->level()==1) m_t << ".SH"; else m_t << ".SS"; m_t << " \""; filter(s->title()); - m_t << "\"" << endl; - if (s->level()==1) m_t << ".PP" << endl; + m_t << "\"\n"; + if (s->level()==1) m_t << ".PP\n"; m_firstCol=TRUE; } @@ -647,16 +647,16 @@ void ManDocVisitor::visitPre(DocHtmlList *) { if (m_hide) return; m_indent+=2; - if (!m_firstCol) m_t << endl; - m_t << ".PD 0" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".PD 0\n"; } void ManDocVisitor::visitPost(DocHtmlList *) { if (m_hide) return; m_indent-=2; - if (!m_firstCol) m_t << endl; - m_t << ".PP" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".PP\n"; } void ManDocVisitor::visitPre(DocHtmlListItem *li) @@ -664,7 +664,7 @@ void ManDocVisitor::visitPre(DocHtmlListItem *li) if (m_hide) return; QCString ws; ws.fill(' ',m_indent-2); - if (!m_firstCol) m_t << endl; + if (!m_firstCol) m_t << "\n"; m_t << ".IP \"" << ws; if (((DocHtmlList *)li->parent())->type()==DocHtmlList::Ordered) { @@ -674,31 +674,31 @@ void ManDocVisitor::visitPre(DocHtmlListItem *li) { m_t << "\\(bu\" " << m_indent; } - m_t << endl; + m_t << "\n"; m_firstCol=TRUE; } void ManDocVisitor::visitPost(DocHtmlListItem *) { if (m_hide) return; - m_t << endl; + m_t << "\n"; m_firstCol=TRUE; } //void ManDocVisitor::visitPre(DocHtmlPre *) //{ -// if (!m_firstCol) m_t << endl; -// m_t << ".PP" << endl; -// m_t << ".nf" << endl; +// if (!m_firstCol) m_t << "\n"; +// m_t << ".PP\n"; +// m_t << ".nf\n"; // m_insidePre=TRUE; //} // //void ManDocVisitor::visitPost(DocHtmlPre *) //{ // m_insidePre=FALSE; -// if (!m_firstCol) m_t << endl; -// m_t << ".fi" << endl; -// m_t << ".PP" << endl; +// if (!m_firstCol) m_t << "\n"; +// m_t << ".fi\n"; +// m_t << ".PP\n"; // m_firstCol=TRUE; //} @@ -709,15 +709,15 @@ void ManDocVisitor::visitPre(DocHtmlDescList *) void ManDocVisitor::visitPost(DocHtmlDescList *) { if (m_hide) return; - if (!m_firstCol) m_t << endl; - m_t << ".PP" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".PP\n"; m_firstCol=TRUE; } void ManDocVisitor::visitPre(DocHtmlDescTitle *) { if (m_hide) return; - if (!m_firstCol) m_t << endl; + if (!m_firstCol) m_t << "\n"; m_t << ".IP \"\\fB"; m_firstCol=FALSE; } @@ -725,7 +725,7 @@ void ManDocVisitor::visitPre(DocHtmlDescTitle *) void ManDocVisitor::visitPost(DocHtmlDescTitle *) { if (m_hide) return; - m_t << "\\fP\" 1c" << endl; + m_t << "\\fP\" 1c\n"; m_firstCol=TRUE; } @@ -772,18 +772,18 @@ void ManDocVisitor::visitPost(DocHtmlCell *) void ManDocVisitor::visitPre(DocInternal *) { if (m_hide) return; - //if (!m_firstCol) m_t << endl; - //m_t << ".PP" << endl; - //m_t << "\\fB" << theTranslator->trForInternalUseOnly() << "\\fP" << endl; - //m_t << ".RS 4" << endl; + //if (!m_firstCol) m_t << "\n"; + //m_t << ".PP\n"; + //m_t << "\\fB" << theTranslator->trForInternalUseOnly() << "\\fP\n"; + //m_t << ".RS 4\n"; } void ManDocVisitor::visitPost(DocInternal *) { if (m_hide) return; - //if (!m_firstCol) m_t << endl; - //m_t << ".RE" << endl; - //m_t << ".PP" << endl; + //if (!m_firstCol) m_t << "\n"; + //m_t << ".RE\n"; + //m_t << ".PP\n"; //m_firstCol=TRUE; } @@ -802,7 +802,7 @@ void ManDocVisitor::visitPost(DocHRef *) void ManDocVisitor::visitPre(DocHtmlHeader *header) { if (m_hide) return; - if (!m_firstCol) m_t << endl; + if (!m_firstCol) m_t << "\n"; if (header->level()==1) m_t << ".SH"; else m_t << ".SS"; m_t << " \""; } @@ -810,8 +810,8 @@ void ManDocVisitor::visitPre(DocHtmlHeader *header) void ManDocVisitor::visitPost(DocHtmlHeader *header) { if (m_hide) return; - m_t << "\"" << endl; - if (header->level()==1) m_t << ".PP" << endl; + m_t << "\"\n"; + if (header->level()==1) m_t << ".PP\n"; m_firstCol=TRUE; } @@ -876,15 +876,15 @@ void ManDocVisitor::visitPre(DocSecRefItem *) if (m_hide) return; QCString ws; ws.fill(' ',m_indent-2); - if (!m_firstCol) m_t << endl; - m_t << ".IP \"" << ws << "\\(bu\" " << m_indent << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".IP \"" << ws << "\\(bu\" " << m_indent << "\n"; m_firstCol=TRUE; } void ManDocVisitor::visitPost(DocSecRefItem *) { if (m_hide) return; - m_t << endl; + m_t << "\n"; m_firstCol=TRUE; } @@ -898,8 +898,8 @@ void ManDocVisitor::visitPost(DocSecRefList *) { if (m_hide) return; m_indent-=2; - if (!m_firstCol) m_t << endl; - m_t << ".PP" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".PP\n"; } void ManDocVisitor::visitPre(DocParamSect *s) @@ -907,8 +907,8 @@ void ManDocVisitor::visitPre(DocParamSect *s) if (m_hide) return; if (!m_firstCol) { - m_t << endl; - m_t << ".PP" << endl; + m_t << "\n"; + m_t << ".PP\n"; } m_t << "\\fB"; switch(s->type()) @@ -924,16 +924,16 @@ void ManDocVisitor::visitPre(DocParamSect *s) default: ASSERT(0); } - m_t << "\\fP" << endl; - m_t << ".RS 4" << endl; + m_t << "\\fP\n"; + m_t << ".RS 4\n"; } void ManDocVisitor::visitPost(DocParamSect *) { if (m_hide) return; - if (!m_firstCol) m_t << endl; - m_t << ".RE" << endl; - m_t << ".PP" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".RE\n"; + m_t << ".PP\n"; m_firstCol=TRUE; } @@ -962,8 +962,8 @@ void ManDocVisitor::visitPost(DocParamList *pl) if (m_hide) return; if (!pl->isLast()) { - if (!m_firstCol) m_t << endl; - m_t << ".br" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".br\n"; } } @@ -973,22 +973,22 @@ void ManDocVisitor::visitPre(DocXRefItem *x) if (x->title().isEmpty()) return; if (!m_firstCol) { - m_t << endl; - m_t << ".PP" << endl; + m_t << "\n"; + m_t << ".PP\n"; } m_t << "\\fB"; filter(x->title()); - m_t << "\\fP" << endl; - m_t << ".RS 4" << endl; + m_t << "\\fP\n"; + m_t << ".RS 4\n"; } void ManDocVisitor::visitPost(DocXRefItem *x) { if (m_hide) return; if (x->title().isEmpty()) return; - if (!m_firstCol) m_t << endl; - m_t << ".RE" << endl; - m_t << ".PP" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".RE\n"; + m_t << ".PP\n"; m_firstCol=TRUE; } @@ -1017,18 +1017,18 @@ void ManDocVisitor::visitPre(DocHtmlBlockQuote *) if (m_hide) return; if (!m_firstCol) { - m_t << endl; - m_t << ".PP" << endl; + m_t << "\n"; + m_t << ".PP\n"; } - m_t << ".RS 4" << endl; // TODO: add support for nested block quotes + m_t << ".RS 4\n"; // TODO: add support for nested block quotes } void ManDocVisitor::visitPost(DocHtmlBlockQuote *) { if (m_hide) return; - if (!m_firstCol) m_t << endl; - m_t << ".RE" << endl; - m_t << ".PP" << endl; + if (!m_firstCol) m_t << "\n"; + m_t << ".RE\n"; + m_t << ".PP\n"; m_firstCol=TRUE; } diff --git a/src/mandocvisitor.h b/src/mandocvisitor.h index 7c5dc8d..61f7ee8 100644 --- a/src/mandocvisitor.h +++ b/src/mandocvisitor.h @@ -21,15 +21,15 @@ #include "docvisitor.h" #include <qcstring.h> +#include <iostream> -class FTextStream; class CodeOutputInterface; /*! @brief Concrete visitor implementation for LaTeX output. */ class ManDocVisitor : public DocVisitor { public: - ManDocVisitor(FTextStream &t,CodeOutputInterface &ci,const char *langExt); + ManDocVisitor(std::ostream &t,CodeOutputInterface &ci,const char *langExt); //-------------------------------------- // visitor functions for leaf nodes @@ -148,7 +148,7 @@ class ManDocVisitor : public DocVisitor // state variables //-------------------------------------- - FTextStream &m_t; + std::ostream &m_t; CodeOutputInterface &m_ci; bool m_insidePre; bool m_hide; diff --git a/src/mangen.cpp b/src/mangen.cpp index 09f20a7..51fc598 100644 --- a/src/mangen.cpp +++ b/src/mangen.cpp @@ -163,7 +163,7 @@ void ManGenerator::startFile(const char *,const char *manName,const char *,int) void ManGenerator::endFile() { - t << endl; + t << "\n"; endPlainFile(); } @@ -177,10 +177,10 @@ void ManGenerator::endTitleHead(const char *,const char *name) t << "Doxygen"; else t << Config_getString(PROJECT_NAME); - t << "\" \\\" -*- nroff -*-" << endl; - t << ".ad l" << endl; - t << ".nh" << endl; - t << ".SH NAME" << endl; + t << "\" \\\" -*- nroff -*-\n"; + t << ".ad l\n"; + t << ".nh\n"; + t << ".SH NAME\n"; t << name; m_firstCol=FALSE; m_paragraph=TRUE; @@ -191,8 +191,8 @@ void ManGenerator::newParagraph() { if (!m_paragraph) { - if (!m_firstCol) t << endl; - t << ".PP" << endl; + if (!m_firstCol) t << "\n"; + t << ".PP\n"; m_firstCol=TRUE; } m_paragraph=TRUE; @@ -202,8 +202,8 @@ void ManGenerator::startParagraph(const char *) { if (!m_paragraph) { - if (!m_firstCol) t << endl; - t << ".PP" << endl; + if (!m_firstCol) t << "\n"; + t << ".PP\n"; m_firstCol=TRUE; } m_paragraph=TRUE; @@ -259,7 +259,7 @@ void ManGenerator::endHtmlLink() void ManGenerator::startGroupHeader(int) { - if (!m_firstCol) t << endl; + if (!m_firstCol) t << "\n"; t << ".SH \""; m_upperCase=TRUE; m_firstCol=FALSE; @@ -267,7 +267,7 @@ void ManGenerator::startGroupHeader(int) void ManGenerator::endGroupHeader(int) { - t << "\"\n.PP " << endl; + t << "\"\n.PP \n"; m_firstCol=TRUE; m_paragraph=TRUE; m_upperCase=FALSE; @@ -275,7 +275,7 @@ void ManGenerator::endGroupHeader(int) void ManGenerator::startMemberHeader(const char *,int) { - if (!m_firstCol) t << endl; + if (!m_firstCol) t << "\n"; t << ".SS \""; } @@ -357,7 +357,7 @@ void ManGenerator::writeChar(char c) void ManGenerator::startDescList(SectionTypes) { if (!m_firstCol) - { t << endl << ".PP" << endl; + { t << "\n" << ".PP\n"; m_firstCol=TRUE; m_paragraph=TRUE; m_col=0; } @@ -367,7 +367,7 @@ void ManGenerator::startDescList(SectionTypes) void ManGenerator::startTitle() { - if (!m_firstCol) t << endl; + if (!m_firstCol) t << "\n"; t << ".SH \""; m_firstCol=FALSE; m_paragraph=FALSE; @@ -380,8 +380,8 @@ void ManGenerator::endTitle() void ManGenerator::startItemListItem() { - if (!m_firstCol) t << endl; - t << ".TP" << endl; + if (!m_firstCol) t << "\n"; + t << ".TP\n"; m_firstCol=TRUE; m_paragraph=FALSE; m_col=0; @@ -394,15 +394,15 @@ void ManGenerator::endItemListItem() void ManGenerator::startCodeFragment(const char *) { newParagraph(); - t << ".nf" << endl; + t << ".nf\n"; m_firstCol=TRUE; m_paragraph=FALSE; } void ManGenerator::endCodeFragment(const char *) { - if (!m_firstCol) t << endl; - t << ".fi" << endl; + if (!m_firstCol) t << "\n"; + t << ".fi\n"; m_firstCol=TRUE; m_paragraph=FALSE; m_col=0; @@ -410,7 +410,7 @@ void ManGenerator::endCodeFragment(const char *) void ManGenerator::startMemberDoc(const char *,const char *,const char *,const char *,int,int,bool) { - if (!m_firstCol) t << endl; + if (!m_firstCol) t << "\n"; t << ".SS \""; m_firstCol=FALSE; m_paragraph=FALSE; @@ -437,18 +437,15 @@ void ManGenerator::startDoxyAnchor(const char *,const char *manName, // - remove dangerous characters and append suffix, then add dir prefix QCString fileName=dir()+"/"+buildFileName( baseName ); - QFile linkfile( fileName ); - // - only create file if it doesn't exist already - if ( !linkfile.open( IO_ReadOnly ) ) + FileInfo fi(fileName.str()); + if (!fi.exists()) { - if ( linkfile.open( IO_WriteOnly ) ) - { - FTextStream linkstream; - linkstream.setDevice(&linkfile); - linkstream << ".so " << getSubdir() << "/" << buildFileName( manName ) << endl; - } + std::ofstream linkStream(fileName.str(),std::ofstream::out | std::ofstream::binary); + if (linkStream.is_open()) + { + linkStream << ".so " << getSubdir() << "/" << buildFileName( manName ) << "\n"; + } } - linkfile.close(); } void ManGenerator::endMemberDoc(bool) @@ -458,7 +455,7 @@ void ManGenerator::endMemberDoc(bool) void ManGenerator::startSubsection() { - if (!m_firstCol) t << endl; + if (!m_firstCol) t << "\n"; t << ".SS \""; m_firstCol=FALSE; m_paragraph=FALSE; @@ -472,7 +469,7 @@ void ManGenerator::endSubsection() void ManGenerator::startSubsubsection() { - if (!m_firstCol) t << endl; + if (!m_firstCol) t << "\n"; t << "\n.SS \""; m_firstCol=FALSE; m_paragraph=FALSE; @@ -485,7 +482,7 @@ void ManGenerator::endSubsubsection() void ManGenerator::writeSynopsis() { - if (!m_firstCol) t << endl; + if (!m_firstCol) t << "\n"; t << ".SH SYNOPSIS\n.br\n.PP\n"; m_firstCol=TRUE; m_paragraph=FALSE; @@ -493,7 +490,7 @@ void ManGenerator::writeSynopsis() void ManGenerator::startDescItem() { - if (!m_firstCol) t << endl; + if (!m_firstCol) t << "\n"; t << ".IP \""; m_firstCol=FALSE; } @@ -506,9 +503,9 @@ void ManGenerator::startDescItem() void ManGenerator::startDescForItem() { - if (!m_firstCol) t << endl; - if (!m_paragraph) t << ".in -1c" << endl; - t << ".in +1c" << endl; + if (!m_firstCol) t << "\n"; + if (!m_paragraph) t << ".in -1c\n"; + t << ".in +1c\n"; m_firstCol=TRUE; m_paragraph=FALSE; m_col=0; @@ -520,7 +517,7 @@ void ManGenerator::endDescForItem() void ManGenerator::endDescItem() { - t << "\" 1c" << endl; + t << "\" 1c\n"; m_firstCol=TRUE; } @@ -642,7 +639,7 @@ void ManGenerator::endSection(const char *,SectionType type) void ManGenerator::startExamples() { if (!m_firstCol) - { t << endl << ".PP" << endl; + { t << "\n" << ".PP\n"; m_firstCol=TRUE; m_paragraph=TRUE; m_col=0; } @@ -660,7 +657,7 @@ void ManGenerator::endExamples() void ManGenerator::startDescTable(const char *title) { if (!m_firstCol) - { t << endl << ".PP" << endl; + { t << "\n.PP\n"; m_firstCol=TRUE; m_paragraph=TRUE; m_col=0; } @@ -680,7 +677,7 @@ void ManGenerator::endDescTable() void ManGenerator::startParamList(ParamListTypes,const char *title) { if (!m_firstCol) - { t << endl << ".PP" << endl; + { t << "\n.PP\n"; m_firstCol=TRUE; m_paragraph=TRUE; m_col=0; } @@ -707,7 +704,7 @@ void ManGenerator::writeDoc(DocNode *n,const Definition *ctx,const MemberDef *,i void ManGenerator::startConstraintList(const char *header) { if (!m_firstCol) - { t << endl << ".PP" << endl; + { t << "\n.PP\n"; m_firstCol=TRUE; m_paragraph=TRUE; m_col=0; } @@ -747,7 +744,7 @@ void ManGenerator::startConstraintDocs() void ManGenerator::endConstraintDocs() { - t << endl; m_firstCol=TRUE; + t << "\n"; m_firstCol=TRUE; } void ManGenerator::endConstraintList() @@ -759,14 +756,14 @@ void ManGenerator::startInlineHeader() { if (!m_firstCol) { - t << endl << ".PP" << endl << ".in -1c" << endl; + t << "\n.PP\n" << ".in -1c\n"; } t << ".RI \"\\fB"; } void ManGenerator::endInlineHeader() { - t << "\\fP\"" << endl << ".in +1c" << endl; + t << "\\fP\"\n" << ".in +1c\n"; m_firstCol = FALSE; } @@ -774,7 +771,7 @@ void ManGenerator::startMemberDocSimple(bool isEnum) { if (!m_firstCol) { - t << endl << ".PP" << endl; + t << "\n.PP\n"; } t << "\\fB"; if (isEnum) @@ -785,15 +782,15 @@ void ManGenerator::startMemberDocSimple(bool isEnum) { docify(theTranslator->trCompoundMembers()); } - t << ":\\fP" << endl; - t << ".RS 4" << endl; + t << ":\\fP\n"; + t << ".RS 4\n"; } void ManGenerator::endMemberDocSimple(bool) { - if (!m_firstCol) t << endl; - t << ".RE" << endl; - t << ".PP" << endl; + if (!m_firstCol) t << "\n"; + t << ".RE\n"; + t << ".PP\n"; m_firstCol=TRUE; } @@ -822,9 +819,9 @@ void ManGenerator::startInlineMemberDoc() void ManGenerator::endInlineMemberDoc() { - if (!m_firstCol) t << endl; - t << ".br" << endl; - t << ".PP" << endl; + if (!m_firstCol) t << "\n"; + t << ".br\n"; + t << ".PP\n"; m_firstCol=TRUE; } diff --git a/src/mangen.h b/src/mangen.h index 052c5ee..d35e61c 100644 --- a/src/mangen.h +++ b/src/mangen.h @@ -20,8 +20,6 @@ #include "outputgen.h" -class QFile; - /** Generator for Man page output. */ class ManGenerator : public OutputGenerator { @@ -136,7 +134,7 @@ class ManGenerator : public OutputGenerator void endDescription() {} void startDescItem(); void endDescItem(); - void lineBreak(const char *) { t << "\n.br" << endl; } + void lineBreak(const char *) { t << "\n.br\n"; } void writeChar(char c); void startMemberDoc(const char *,const char *,const char *,const char *,int,int,bool); void endMemberDoc(bool); @@ -145,7 +143,7 @@ class ManGenerator : public OutputGenerator void writeLatexSpacing() {} void writeStartAnnoItem(const char *type,const char *file, const char *path,const char *name); - void writeEndAnnoItem(const char *) { t << endl; m_firstCol=TRUE; } + void writeEndAnnoItem(const char *) { t << "\n"; m_firstCol=TRUE; } void startSubsection(); void endSubsection(); void startSubsubsection(); @@ -196,7 +194,7 @@ class ManGenerator : public OutputGenerator void endDescTableRow() {} void startDescTableTitle() { startItemListItem(); startBold(); startEmphasis(); endItemListItem(); } void endDescTableTitle() { endEmphasis(); endBold(); } - void startDescTableData() { t << endl; m_firstCol=TRUE; } + void startDescTableData() { t << "\n"; m_firstCol=TRUE; } void endDescTableData() {} void startDotGraph() {} diff --git a/src/markdown.cpp b/src/markdown.cpp index 702f39b..ceba79d 100644 --- a/src/markdown.cpp +++ b/src/markdown.cpp @@ -1076,7 +1076,7 @@ int Markdown::processLink(const char *data,int,int size) else if (!(forg.exists() && forg.isReadable())) { FileInfo fi(m_fileName.str()); - QCString mdFile = m_fileName.left(m_fileName.length()-fi.fileName().length()) + link; + QCString mdFile = m_fileName.left(m_fileName.length()-(uint)fi.fileName().length()) + link; FileInfo fmd(mdFile.str()); if (fmd.exists() && fmd.isReadable()) { diff --git a/src/memberdef.cpp b/src/memberdef.cpp index 11547c8..26b997c 100644 --- a/src/memberdef.cpp +++ b/src/memberdef.cpp @@ -315,7 +315,7 @@ class MemberDefImpl : public DefinitionMixin<MemberDefMutable> virtual void writeMemberDocSimple(OutputList &ol,const Definition *container) const; virtual void writeEnumDeclaration(OutputList &typeDecl, const ClassDef *cd,const NamespaceDef *nd,const FileDef *fd,const GroupDef *gd) const; - virtual void writeTagFile(FTextStream &) const; + virtual void writeTagFile(std::ostream &) const; virtual void warnIfUndocumented() const; virtual void warnIfUndocumentedParams() const; virtual void detectUndocumentedParams(bool hasParamCommand,bool hasReturnCommand) const; @@ -4258,7 +4258,7 @@ Specifier MemberDefImpl::virtualness(int count) const return v; } -void MemberDefImpl::writeTagFile(FTextStream &tagFile) const +void MemberDefImpl::writeTagFile(std::ostream &tagFile) const { if (!isLinkableInProject()) return; tagFile << " <member kind=\""; @@ -4298,20 +4298,20 @@ void MemberDefImpl::writeTagFile(FTextStream &tagFile) const { tagFile << "\" static=\"yes"; } - tagFile << "\">" << endl; + tagFile << "\">\n"; if (typeString()!=QCString("@")) { - tagFile << " <type>" << convertToXML(typeString()) << "</type>" << endl; + tagFile << " <type>" << convertToXML(typeString()) << "</type>\n"; } - tagFile << " <name>" << convertToXML(name()) << "</name>" << endl; - tagFile << " <anchorfile>" << convertToXML(getOutputFileBase()) << Doxygen::htmlFileExtension << "</anchorfile>" << endl; - tagFile << " <anchor>" << convertToXML(anchor()) << "</anchor>" << endl; + tagFile << " <name>" << convertToXML(name()) << "</name>\n"; + tagFile << " <anchorfile>" << convertToXML(getOutputFileBase()) << Doxygen::htmlFileExtension << "</anchorfile>\n"; + tagFile << " <anchor>" << convertToXML(anchor()) << "</anchor>\n"; QCString idStr = id(); if (!idStr.isEmpty()) { - tagFile << " <clangid>" << convertToXML(idStr) << "</clangid>" << endl; + tagFile << " <clangid>" << convertToXML(idStr) << "</clangid>\n"; } - tagFile << " <arglist>" << convertToXML(argsString()) << "</arglist>" << endl; + tagFile << " <arglist>" << convertToXML(argsString()) << "</arglist>\n"; if (isStrong()) { for (const auto &fmd : m_impl->enumFields) @@ -4325,12 +4325,12 @@ void MemberDefImpl::writeTagFile(FTextStream &tagFile) const { tagFile << "\" clangid=\"" << convertToXML(idStr); } - tagFile << "\">" << convertToXML(fmd->name()) << "</enumvalue>" << endl; + tagFile << "\">" << convertToXML(fmd->name()) << "</enumvalue>\n"; } } } writeDocAnchorsToTagFile(tagFile); - tagFile << " </member>" << endl; + tagFile << " </member>\n"; } void MemberDefImpl::_computeIsConstructor() diff --git a/src/memberdef.h b/src/memberdef.h index e6afcb3..3f9fb92 100644 --- a/src/memberdef.h +++ b/src/memberdef.h @@ -409,7 +409,7 @@ class MemberDefMutable : public DefinitionMutable, public MemberDef bool inGroup,bool showEnumValues=FALSE,bool showInline=FALSE) const = 0; virtual void writeMemberDocSimple(OutputList &ol,const Definition *container) const = 0; - virtual void writeTagFile(FTextStream &) const = 0; + virtual void writeTagFile(std::ostream &) const = 0; virtual void writeLink(OutputList &ol, const ClassDef *cd,const NamespaceDef *nd,const FileDef *fd,const GroupDef *gd, bool onlyText=FALSE) const = 0; diff --git a/src/membergroup.cpp b/src/membergroup.cpp index 77f5842..38d5503 100644 --- a/src/membergroup.cpp +++ b/src/membergroup.cpp @@ -295,7 +295,7 @@ void MemberGroup::setRefItems(const RefItemVector &sli) m_xrefListItems.insert(m_xrefListItems.end(), sli.cbegin(), sli.cend()); } -void MemberGroup::writeTagFile(FTextStream &tagFile) +void MemberGroup::writeTagFile(std::ostream &tagFile) { memberList->writeTagFile(tagFile); } diff --git a/src/membergroup.h b/src/membergroup.h index b258a04..178a0f9 100644 --- a/src/membergroup.h +++ b/src/membergroup.h @@ -36,7 +36,6 @@ class GroupDef; class OutputList; class Definition; class DefinitionMutable; -class FTextStream; class RefItem; /** A class representing a group of members. */ @@ -61,7 +60,7 @@ class MemberGroup const Definition *container,bool showEnumValues,bool showInline) const; void writeDocumentationPage(OutputList &ol,const char *scopeName, const DefinitionMutable *container) const; - void writeTagFile(FTextStream &); + void writeTagFile(std::ostream &); void addGroupedInheritedMembers(OutputList &ol,const ClassDef *cd, MemberListType lt, const ClassDef *inheritedFrom,const QCString &inheritId) const; diff --git a/src/memberlist.cpp b/src/memberlist.cpp index 8d07ae4..26e3dea 100644 --- a/src/memberlist.cpp +++ b/src/memberlist.cpp @@ -948,7 +948,7 @@ QCString MemberList::listTypeAsString(MemberListType type) return ""; } -void MemberList::writeTagFile(FTextStream &tagFile) +void MemberList::writeTagFile(std::ostream &tagFile) { for (const auto &imd : m_members) { diff --git a/src/memberlist.h b/src/memberlist.h index aef227a..149c05f 100644 --- a/src/memberlist.h +++ b/src/memberlist.h @@ -100,7 +100,7 @@ class MemberList void writeSimpleDocumentation(OutputList &ol,const Definition *container) const; void writeDocumentationPage(OutputList &ol, const char *scopeName, const DefinitionMutable *container) const; - void writeTagFile(FTextStream &); + void writeTagFile(std::ostream &); bool declVisible() const; void addMemberGroup(MemberGroup *mg); void setInGroup(bool inGroup) { m_inGroup=inGroup; } diff --git a/src/msc.cpp b/src/msc.cpp index 17a7a5d..0be1c31 100644 --- a/src/msc.cpp +++ b/src/msc.cpp @@ -1,8 +1,6 @@ /****************************************************************************** * - * - * - * Copyright (C) 1997-2015 by Dimitri van Heesch. + * Copyright (C) 1997-2021 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its * documentation under the terms of the GNU General Public License is hereby @@ -15,6 +13,8 @@ * */ +#include <sstream> + #include "msc.h" #include "portable.h" #include "config.h" @@ -23,43 +23,40 @@ #include "doxygen.h" #include "index.h" #include "util.h" -#include "ftextstream.h" #include "mscgen_api.h" #include "dir.h" static const int maxCmdLine = 40960; -static bool convertMapFile(FTextStream &t,const char *mapName,const QCString relPath, +static bool convertMapFile(std::ostream &t,const char *mapName,const QCString relPath, const QCString &context) { - QFile f(mapName); - if (!f.open(IO_ReadOnly)) + std::ifstream f(mapName,std::ifstream::in); + if (!f.is_open()) { err("failed to open map file %s for inclusion in the docs!\n" "If you installed Graphviz/dot after a previous failing run, \n" "try deleting the output directory and rerun doxygen.\n",mapName); - return FALSE; + return false; } const int maxLineLen=1024; - char buf[maxLineLen]; char url[maxLineLen]; char ref[maxLineLen]; int x1,y1,x2,y2; - while (!f.atEnd()) + std::string line; + while (getline(f,line)) { - bool isRef = FALSE; - int numBytes = f.readLine(buf,maxLineLen); - buf[numBytes-1]='\0'; - //printf("ReadLine '%s'\n",buf); - if (qstrncmp(buf,"rect",4)==0) + bool isRef = false; + //printf("ReadLine '%s'\n",line.c_str()); + if (qstrncmp(line.c_str(),"rect",4)==0) { // obtain the url and the coordinates in the order used by graphviz-1.5 - sscanf(buf,"rect %s %d,%d %d,%d",url,&x1,&y1,&x2,&y2); + sscanf(line.c_str(),"rect %s %d,%d %d,%d",url,&x1,&y1,&x2,&y2); if (qstrcmp(url,"\\ref")==0 || qstrcmp(url,"@ref")==0) { - isRef = TRUE; - sscanf(buf,"rect %s %s %d,%d %d,%d",ref,url,&x1,&y1,&x2,&y2); + isRef = true; + sscanf(line.c_str(),"rect %s %s %d,%d %d,%d",ref,url,&x1,&y1,&x2,&y2); } // sanity checks @@ -83,11 +80,11 @@ static bool convertMapFile(FTextStream &t,const char *mapName,const QCString rel } t << "\" shape=\"rect\" coords=\"" << x1 << "," << y1 << "," << x2 << "," << y2 << "\"" - << " alt=\"\"/>" << endl; + << " alt=\"\"/>\n"; } } - return TRUE; + return true; } void writeMscGraphFromFile(const char *inFile,const char *outDir, @@ -156,15 +153,16 @@ static QCString getMscImageMapFromFile(const QCString& inFile, const QCString& o return ""; } - QGString result; - FTextStream tmpout(&result); - convertMapFile(tmpout, outFile, relPath, context); + std::stringstream t; + convertMapFile(t, outFile, relPath, context); + QCString result = t.str(); + Dir().remove(outFile.str()); - return result.data(); + return result; } -void writeMscImageMapFromFile(FTextStream &t,const QCString &inFile, +void writeMscImageMapFromFile(std::ostream &t,const QCString &inFile, const QCString &outDir, const QCString &relPath, const QCString &baseName, @@ -192,12 +190,12 @@ void writeMscImageMapFromFile(FTextStream &t,const QCString &inFile, if (!imap.isEmpty()) { t << "\" alt=\"" - << baseName << "\" border=\"0\" usemap=\"#" << mapName << "\"/>" << endl; - t << "<map name=\"" << mapName << "\" id=\"" << mapName << "\">" << imap << "</map>" << endl; + << baseName << "\" border=\"0\" usemap=\"#" << mapName << "\"/>\n"; + t << "<map name=\"" << mapName << "\" id=\"" << mapName << "\">" << imap << "</map>\n"; } else { - t << "\" alt=\"" << baseName << "\" border=\"0\"/>" << endl; + t << "\" alt=\"" << baseName << "\" border=\"0\"/>\n"; } } @@ -1,12 +1,10 @@ /****************************************************************************** * - * - * - * Copyright (C) 1997-2015 by Dimitri van Heesch. + * Copyright (C) 1997-2021 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its - * documentation under the terms of the GNU General Public License is hereby - * granted. No representations are made about the suitability of this software + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * @@ -18,8 +16,9 @@ #ifndef _MSC_H #define _MSC_H +#include <iostream> + class QCString; -class FTextStream; enum MscOutputFormat { MSC_BITMAP , MSC_EPS, MSC_SVG }; @@ -29,7 +28,7 @@ void writeMscGraphFromFile(const char *inFile,const char *outDir, QCString getMscImageMapFromFile(const QCString& inFile, const QCString& outDir, const QCString& relPath,const QCString& context); -void writeMscImageMapFromFile(FTextStream &t,const QCString &inFile, +void writeMscImageMapFromFile(std::ostream &t,const QCString &inFile, const QCString &outDir, const QCString &relPath, const QCString &baseName, const QCString &context, MscOutputFormat format diff --git a/src/namespacedef.cpp b/src/namespacedef.cpp index 7acd463..5dc36be 100644 --- a/src/namespacedef.cpp +++ b/src/namespacedef.cpp @@ -63,7 +63,7 @@ class NamespaceDefImpl : public DefinitionMixin<NamespaceDefMutable> virtual void writeDocumentation(OutputList &ol); virtual void writeMemberPages(OutputList &ol); virtual void writeQuickMemberLinks(OutputList &ol,const MemberDef *currentMd) const; - virtual void writeTagFile(FTextStream &); + virtual void writeTagFile(std::ostream &); virtual void insertClass(const ClassDef *cd); virtual void insertNamespace(const NamespaceDef *nd); virtual void insertMember(MemberDef *md); @@ -125,7 +125,7 @@ class NamespaceDefImpl : public DefinitionMixin<NamespaceDefMutable> void endMemberDocumentation(OutputList &ol); void writeSummaryLinks(OutputList &ol) const; void addNamespaceAttributes(OutputList &ol); - void writeClassesToTagFile(FTextStream &,const ClassLinkedRefMap &d); + void writeClassesToTagFile(std::ostream &,const ClassLinkedRefMap &d); void writeNamespaceDeclarations(OutputList &ol,const QCString &title, bool isConstantGroup=false); @@ -533,15 +533,15 @@ bool NamespaceDefImpl::hasDetailedDescription() const !documentation().isEmpty()); } -void NamespaceDefImpl::writeTagFile(FTextStream &tagFile) +void NamespaceDefImpl::writeTagFile(std::ostream &tagFile) { - tagFile << " <compound kind=\"namespace\">" << endl; - tagFile << " <name>" << convertToXML(name()) << "</name>" << endl; - tagFile << " <filename>" << convertToXML(getOutputFileBase()) << Doxygen::htmlFileExtension << "</filename>" << endl; + tagFile << " <compound kind=\"namespace\">\n"; + tagFile << " <name>" << convertToXML(name()) << "</name>\n"; + tagFile << " <filename>" << convertToXML(getOutputFileBase()) << Doxygen::htmlFileExtension << "</filename>\n"; QCString idStr = id(); if (!idStr.isEmpty()) { - tagFile << " <clangid>" << convertToXML(idStr) << "</clangid>" << endl; + tagFile << " <clangid>" << convertToXML(idStr) << "</clangid>\n"; } for (const auto &lde : LayoutDocManager::instance().docEntries(LayoutDocManager::Namespace)) { @@ -553,7 +553,7 @@ void NamespaceDefImpl::writeTagFile(FTextStream &tagFile) { if (nd->isLinkableInProject()) { - tagFile << " <namespace>" << convertToXML(nd->name()) << "</namespace>" << endl; + tagFile << " <namespace>" << convertToXML(nd->name()) << "</namespace>\n"; } } } @@ -601,7 +601,7 @@ void NamespaceDefImpl::writeTagFile(FTextStream &tagFile) } } writeDocAnchorsToTagFile(tagFile); - tagFile << " </compound>" << endl; + tagFile << " </compound>\n"; } void NamespaceDefImpl::writeDetailedDescription(OutputList &ol,const QCString &title) @@ -851,14 +851,14 @@ void NamespaceDefImpl::addNamespaceAttributes(OutputList &ol) } } -void NamespaceDefImpl::writeClassesToTagFile(FTextStream &tagFile,const ClassLinkedRefMap &list) +void NamespaceDefImpl::writeClassesToTagFile(std::ostream &tagFile,const ClassLinkedRefMap &list) { for (const auto &cd : list) { if (cd->isLinkableInProject()) { tagFile << " <class kind=\"" << cd->compoundTypeString() - << "\">" << convertToXML(cd->name()) << "</class>" << endl; + << "\">" << convertToXML(cd->name()) << "</class>\n"; } } } diff --git a/src/namespacedef.h b/src/namespacedef.h index d41cc20..dfe43a7 100644 --- a/src/namespacedef.h +++ b/src/namespacedef.h @@ -29,7 +29,6 @@ class OutputList; class ClassLinkedRefMap; class MemberDef; class NamespaceDef; -class FTextStream; class NamespaceDef; class NamespaceDefMutable; @@ -109,7 +108,7 @@ class NamespaceDefMutable : public DefinitionMutable, public NamespaceDef virtual void writeDocumentation(OutputList &ol) = 0; virtual void writeMemberPages(OutputList &ol) = 0; virtual void writeQuickMemberLinks(OutputList &ol,const MemberDef *currentMd) const = 0; - virtual void writeTagFile(FTextStream &) = 0; + virtual void writeTagFile(std::ostream &) = 0; virtual void insertClass(const ClassDef *cd) = 0; virtual void insertNamespace(const NamespaceDef *nd) = 0; virtual void insertMember(MemberDef *md) = 0; // md cannot be const, since setSectionList is called on it diff --git a/src/outputgen.cpp b/src/outputgen.cpp index 5be6817..d922a93 100644 --- a/src/outputgen.cpp +++ b/src/outputgen.cpp @@ -19,14 +19,12 @@ #include <stdlib.h> -#include <qfile.h> - #include "doxygen.h" #include "outputgen.h" #include "message.h" #include "portable.h" -OutputGenerator::OutputGenerator(const char *dir) : m_dir(dir) +OutputGenerator::OutputGenerator(const char *dir) : t(nullptr), m_dir(dir) { //printf("OutputGenerator::OutputGenerator()\n"); } @@ -36,12 +34,12 @@ OutputGenerator::~OutputGenerator() //printf("OutputGenerator::~OutputGenerator()\n"); } -OutputGenerator::OutputGenerator(const OutputGenerator &og) +OutputGenerator::OutputGenerator(const OutputGenerator &og) : t(nullptr) { m_dir = og.m_dir; // we don't copy the other fields. // after copying startPlainFile() should be called - if (og.t.device()!=nullptr) + if (og.t.rdbuf()!=nullptr) { throw std::runtime_error("OutputGenerator copy constructor called while a file is processing"); } @@ -52,7 +50,7 @@ OutputGenerator &OutputGenerator::operator=(const OutputGenerator &og) m_dir = og.m_dir; // we don't copy the other fields. // after assignment startPlainFile() should be called - if (og.t.device()!=nullptr) + if (og.t.rdbuf()!=nullptr) { throw std::runtime_error("OutputGenerator assignment operator called while a file is processing"); } @@ -63,17 +61,17 @@ void OutputGenerator::startPlainFile(const char *name) { //printf("startPlainFile(%s)\n",name); m_fileName=m_dir+"/"+name; - m_file.setName(m_fileName); - if (!m_file.open(IO_WriteOnly)) + m_file.open(m_fileName.str(),std::ofstream::out | std::ofstream::binary); + if (!m_file.is_open()) { term("Could not open file %s for writing\n",m_fileName.data()); } - t.setDevice(&m_file); + t.rdbuf(m_file.rdbuf()); } void OutputGenerator::endPlainFile() { - t.unsetDevice(); + t.rdbuf(nullptr); m_file.close(); m_fileName.resize(0); } diff --git a/src/outputgen.h b/src/outputgen.h index 0d64833..7a4571d 100644 --- a/src/outputgen.h +++ b/src/outputgen.h @@ -20,12 +20,11 @@ #include <memory> #include <stack> - -#include <qfile.h> +#include <iostream> +#include <fstream> #include "index.h" #include "section.h" -#include "ftextstream.h" class ClassDiagram; class DotClassGraph; @@ -496,11 +495,11 @@ class OutputGenerator : public BaseOutputDocInterface virtual void endLabels() = 0; protected: - FTextStream t; + std::ostream t; private: QCString m_dir; QCString m_fileName; - QFile m_file; + std::ofstream m_file; bool m_active = true; std::stack<bool> m_genStack; }; diff --git a/src/pagedef.cpp b/src/pagedef.cpp index 4634be7..59055a3 100644 --- a/src/pagedef.cpp +++ b/src/pagedef.cpp @@ -57,7 +57,7 @@ class PageDefImpl : public DefinitionMixin<PageDef> virtual QCString displayName(bool=TRUE) const { return hasTitle() ? m_title : DefinitionMixin::name(); } virtual bool showLineNo() const; virtual void writeDocumentation(OutputList &ol); - virtual void writeTagFile(FTextStream &); + virtual void writeTagFile(std::ostream &); virtual void setNestingLevel(int l); virtual void writePageDocumentation(OutputList &ol) const; @@ -144,7 +144,7 @@ bool PageDefImpl::hasParentPage() const getOuterScope()->definitionType()==Definition::TypePage; } -void PageDefImpl::writeTagFile(FTextStream &tagFile) +void PageDefImpl::writeTagFile(std::ostream &tagFile) { bool found = name()=="citelist"; for (RefListManager::Ptr &rl : RefListManager::instance()) @@ -157,12 +157,12 @@ void PageDefImpl::writeTagFile(FTextStream &tagFile) } if (!found) // not one of the generated related pages { - tagFile << " <compound kind=\"page\">" << endl; - tagFile << " <name>" << name() << "</name>" << endl; - tagFile << " <title>" << convertToXML(title()) << "</title>" << endl; - tagFile << " <filename>" << convertToXML(getOutputFileBase())<< Doxygen::htmlFileExtension << "</filename>" << endl; + tagFile << " <compound kind=\"page\">\n"; + tagFile << " <name>" << name() << "</name>\n"; + tagFile << " <title>" << convertToXML(title()) << "</title>\n"; + tagFile << " <filename>" << convertToXML(getOutputFileBase())<< Doxygen::htmlFileExtension << "</filename>\n"; writeDocAnchorsToTagFile(tagFile); - tagFile << " </compound>" << endl; + tagFile << " </compound>\n"; } } diff --git a/src/pagedef.h b/src/pagedef.h index dba30dc..0da42dd 100644 --- a/src/pagedef.h +++ b/src/pagedef.h @@ -20,7 +20,6 @@ class PageLinkedRefMap; class OutputList; -class FTextStream; /** @brief A model of a page symbol. */ class PageDef : public DefinitionMutable, public Definition @@ -56,7 +55,7 @@ class PageDef : public DefinitionMutable, public Definition virtual bool showLineNo() const = 0; virtual void writeDocumentation(OutputList &) = 0; - virtual void writeTagFile(FTextStream &) = 0; + virtual void writeTagFile(std::ostream &) = 0; virtual void setNestingLevel(int) = 0; virtual void writePageDocumentation(OutputList &) const = 0; diff --git a/src/perlmodgen.cpp b/src/perlmodgen.cpp index 80a90cd..ab931f9 100644 --- a/src/perlmodgen.cpp +++ b/src/perlmodgen.cpp @@ -20,7 +20,8 @@ #include <stdlib.h> #include <stack> -#include <qfile.h> +#include <fstream> +#include <iostream> #include "perlmodgen.h" #include "docparser.h" @@ -28,7 +29,6 @@ #include "doxygen.h" #include "pagedef.h" #include "memberlist.h" -#include "ftextstream.h" #include "arguments.h" #include "config.h" #include "groupdef.h" @@ -48,58 +48,62 @@ class PerlModOutputStream { -public: - - QCString m_s; - FTextStream *m_t; + public: + //QCString m_s; + std::ostream &m_t; - PerlModOutputStream(FTextStream *t = 0) : m_t(t) { } + PerlModOutputStream(std::ostream &t) : m_t(t) { } - void add(char c); - void add(const char *s); - void add(QCString &s); - void add(int n); - void add(unsigned int n); + void add(char c); + void add(const char *s); + void add(QCString &s); + void add(int n); + void add(unsigned int n); }; void PerlModOutputStream::add(char c) { - if (m_t != 0) - (*m_t) << c; - else - m_s += c; + m_t << c; + //if (m_t != 0) + // (*m_t) << c; + //else + // m_s += c; } void PerlModOutputStream::add(const char *s) { - if (m_t != 0) - (*m_t) << s; - else - m_s += s; + m_t << s; + //if (m_t != 0) + // (*m_t) << s; + //else + // m_s += s; } void PerlModOutputStream::add(QCString &s) { - if (m_t != 0) - (*m_t) << s; - else - m_s += s; + m_t << s.str(); + //if (m_t != 0) + // (*m_t) << s; + //else + // m_s += s; } void PerlModOutputStream::add(int n) { - if (m_t != 0) - (*m_t) << n; - else - m_s += QCString().setNum(n); + m_t << n; + //if (m_t != 0) + // (*m_t) << n; + //else + // m_s += QCString().setNum(n); } void PerlModOutputStream::add(unsigned int n) { - if (m_t != 0) - (*m_t) << n; - else - m_s += QCString().setNum(n); + m_t << n; + //if (m_t != 0) + // (*m_t) << n; + //else + // m_s += QCString().setNum(n); } class PerlModOutput @@ -118,8 +122,8 @@ public: inline void setPerlModOutputStream(PerlModOutputStream *os) { m_stream = os; } - inline PerlModOutput &openSave() { iopenSave(); return *this; } - inline PerlModOutput &closeSave(QCString &s) { icloseSave(s); return *this; } + //inline PerlModOutput &openSave() { iopenSave(); return *this; } + //inline PerlModOutput &closeSave(QCString &s) { icloseSave(s); return *this; } inline PerlModOutput &continueBlock() { @@ -171,8 +175,8 @@ public: protected: - void iopenSave(); - void icloseSave(QCString &); + //void iopenSave(); + //void icloseSave(QCString &); void incIndent(); void decIndent(); @@ -191,23 +195,23 @@ private: int m_indentation; bool m_blockstart; - std::stack<PerlModOutputStream*> m_saved; + //std::stack<PerlModOutputStream*> m_saved; char m_spaces[PERLOUTPUT_MAX_INDENTATION * 2 + 2]; }; -void PerlModOutput::iopenSave() -{ - m_saved.push(m_stream); - m_stream = new PerlModOutputStream(); -} +//void PerlModOutput::iopenSave() +//{ +// m_saved.push(m_stream); +// m_stream = new PerlModOutputStream(); +//} -void PerlModOutput::icloseSave(QCString &s) -{ - s = m_stream->m_s; - delete m_stream; - m_stream = m_saved.top(); - m_saved.pop(); -} +//void PerlModOutput::icloseSave(QCString &s) +//{ +// s = m_stream->m_s; +// delete m_stream; +// m_stream = m_saved.top(); +// m_saved.pop(); +//} void PerlModOutput::incIndent() { @@ -414,8 +418,8 @@ private: void singleItem(const char *); void openSubBlock(const char * = 0); void closeSubBlock(); - void openOther(); - void closeOther(); + //void openOther(); + //void closeOther(); //-------------------------------------- // state variables @@ -498,18 +502,18 @@ void PerlModDocVisitor::closeSubBlock() m_output.closeList(); } -void PerlModDocVisitor::openOther() -{ +//void PerlModDocVisitor::openOther() +//{ // Using a secondary text stream will corrupt the perl file. Instead of // printing doc => [ data => [] ], it will print doc => [] data => []. /* leaveText(); m_output.openSave(); */ -} +//} -void PerlModDocVisitor::closeOther() -{ +//void PerlModDocVisitor::closeOther() +//{ // Using a secondary text stream will corrupt the perl file. Instead of // printing doc => [ data => [] ], it will print doc => [] data => []. /* @@ -518,7 +522,7 @@ void PerlModDocVisitor::closeOther() m_output.closeSave(other); m_other += other; */ -} +//} void PerlModDocVisitor::visit(DocWord *w) { @@ -874,14 +878,14 @@ void PerlModDocVisitor::visitPre(DocSimpleSect *s) } leaveText(); m_output.openHash(); - openOther(); + //openOther(); openSubBlock(type); } void PerlModDocVisitor::visitPost(DocSimpleSect *) { closeSubBlock(); - closeOther(); + //closeOther(); m_output.closeHash(); } @@ -1261,14 +1265,14 @@ void PerlModDocVisitor::visitPre(DocParamSect *s) break; } m_output.openHash(); - openOther(); + //openOther(); openSubBlock(type); } void PerlModDocVisitor::visitPost(DocParamSect *) { closeSubBlock(); - closeOther(); + //closeOther(); m_output.closeHash(); } @@ -1518,7 +1522,7 @@ public: void generatePerlModForGroup(const GroupDef *gd); void generatePerlModForPage(PageDef *pi); - bool createOutputFile(QFile &f, const char *s); + bool createOutputFile(std::ofstream &f, const char *s); bool createOutputDir(Dir &perlModDir); bool generateDoxyLatexTex(); bool generateDoxyFormatTex(); @@ -2137,12 +2141,11 @@ void PerlModGenerator::generatePerlModForPage(PageDef *pd) bool PerlModGenerator::generatePerlModOutput() { - QFile outputFile; - if (!createOutputFile(outputFile, pathDoxyDocsPM)) + std::ofstream outputFileStream; + if (!createOutputFile(outputFileStream, pathDoxyDocsPM)) return false; - FTextStream outputTextStream(&outputFile); - PerlModOutputStream outputStream(&outputTextStream); + PerlModOutputStream outputStream(outputFileStream); m_output.setPerlModOutputStream(&outputStream); m_output.add("$doxydocs=").openHash(); @@ -2188,10 +2191,10 @@ bool PerlModGenerator::generatePerlModOutput() return true; } -bool PerlModGenerator::createOutputFile(QFile &f, const char *s) +bool PerlModGenerator::createOutputFile(std::ofstream &f, const char *s) { - f.setName(s); - if (!f.open(IO_WriteOnly)) + f.open(s,std::ofstream::out | std::ofstream::binary); + if (!f.is_open()) { err("Cannot open file %s for writing!\n", s); return false; @@ -2213,11 +2216,10 @@ bool PerlModGenerator::createOutputDir(Dir &perlModDir) bool PerlModGenerator::generateDoxyStructurePM() { - QFile doxyModelPM; - if (!createOutputFile(doxyModelPM, pathDoxyStructurePM)) + std::ofstream doxyModelPMStream; + if (!createOutputFile(doxyModelPMStream, pathDoxyStructurePM)) return false; - FTextStream doxyModelPMStream(&doxyModelPM); doxyModelPMStream << "sub memberlist($) {\n" " my $prefix = $_[0];\n" @@ -2397,14 +2399,13 @@ bool PerlModGenerator::generateDoxyStructurePM() bool PerlModGenerator::generateDoxyRules() { - QFile doxyRules; - if (!createOutputFile(doxyRules, pathDoxyRules)) + std::ofstream doxyRulesStream; + if (!createOutputFile(doxyRulesStream, pathDoxyRules)) return false; bool perlmodLatex = Config_getBool(PERLMOD_LATEX); QCString prefix = Config_getString(PERLMOD_MAKEVAR_PREFIX); - FTextStream doxyRulesStream(&doxyRules); doxyRulesStream << prefix << "DOXY_EXEC_PATH = " << pathDoxyExec << "\n" << prefix << "DOXYFILE = " << pathDoxyfile << "\n" << @@ -2494,14 +2495,13 @@ bool PerlModGenerator::generateDoxyRules() bool PerlModGenerator::generateMakefile() { - QFile makefile; - if (!createOutputFile(makefile, pathMakefile)) + std::ofstream makefileStream; + if (!createOutputFile(makefileStream, pathMakefile)) return false; bool perlmodLatex = Config_getBool(PERLMOD_LATEX); QCString prefix = Config_getString(PERLMOD_MAKEVAR_PREFIX); - FTextStream makefileStream(&makefile); makefileStream << ".PHONY: default clean" << (perlmodLatex ? " pdf" : "") << "\n" "default: " << (perlmodLatex ? "pdf" : "clean") << "\n" @@ -2521,11 +2521,10 @@ bool PerlModGenerator::generateMakefile() bool PerlModGenerator::generateDoxyLatexStructurePL() { - QFile doxyLatexStructurePL; - if (!createOutputFile(doxyLatexStructurePL, pathDoxyLatexStructurePL)) + std::ofstream doxyLatexStructurePLStream; + if (!createOutputFile(doxyLatexStructurePLStream, pathDoxyLatexStructurePL)) return false; - FTextStream doxyLatexStructurePLStream(&doxyLatexStructurePL); doxyLatexStructurePLStream << "use DoxyStructure;\n" "\n" @@ -2555,11 +2554,10 @@ bool PerlModGenerator::generateDoxyLatexStructurePL() bool PerlModGenerator::generateDoxyLatexPL() { - QFile doxyLatexPL; - if (!createOutputFile(doxyLatexPL, pathDoxyLatexPL)) + std::ofstream doxyLatexPLStream; + if (!createOutputFile(doxyLatexPLStream, pathDoxyLatexPL)) return false; - FTextStream doxyLatexPLStream(&doxyLatexPL); doxyLatexPLStream << "use DoxyStructure;\n" "use DoxyDocs;\n" @@ -2678,11 +2676,10 @@ bool PerlModGenerator::generateDoxyLatexPL() bool PerlModGenerator::generateDoxyFormatTex() { - QFile doxyFormatTex; - if (!createOutputFile(doxyFormatTex, pathDoxyFormatTex)) + std::ofstream doxyFormatTexStream; + if (!createOutputFile(doxyFormatTexStream, pathDoxyFormatTex)) return false; - FTextStream doxyFormatTexStream(&doxyFormatTex); doxyFormatTexStream << "\\def\\Defcs#1{\\long\\expandafter\\def\\csname#1\\endcsname}\n" "\\Defcs{Empty}{}\n" @@ -2841,11 +2838,10 @@ bool PerlModGenerator::generateDoxyFormatTex() bool PerlModGenerator::generateDoxyLatexTex() { - QFile doxyLatexTex; - if (!createOutputFile(doxyLatexTex, pathDoxyLatexTex)) + std::ofstream doxyLatexTexStream; + if (!createOutputFile(doxyLatexTexStream, pathDoxyLatexTex)) return false; - FTextStream doxyLatexTexStream(&doxyLatexTex); doxyLatexTexStream << "\\documentclass[a4paper,12pt]{article}\n" "\\usepackage[latin1]{inputenc}\n" diff --git a/src/plantuml.cpp b/src/plantuml.cpp index f8623ef..da26ba7 100644 --- a/src/plantuml.cpp +++ b/src/plantuml.cpp @@ -229,12 +229,12 @@ static void runPlantumlContent(const PlantumlManager::FilesMap &plantumlFiles, pumlArguments+=puFileName; pumlArguments+="\" "; - QFile file(puFileName); - if (!file.open(IO_WriteOnly)) + std::ofstream file(puFileName.str(),std::ofstream::out | std::ofstream::binary); + if (!file.is_open()) { err("Could not open file %s for writing\n",puFileName.data()); } - file.writeBlock( nb.content, nb.content.length() ); + file.write( nb.content.data(), nb.content.length() ); file.close(); Debug::print(Debug::Plantuml,0,"*** %s Running Plantuml arguments:%s\n","PlantumlManager::runPlantumlContent",qPrint(pumlArguments)); @@ -247,7 +247,7 @@ static void runPlantumlContent(const PlantumlManager::FilesMap &plantumlFiles, else if (Config_getBool(DOT_CLEANUP)) { Debug::print(Debug::Plantuml,0,"*** %s Remove %s file\n","PlantumlManager::runPlantumlContent",qPrint(puFileName)); - file.remove(); + Dir().remove(puFileName.str()); } Portable::sysTimerStop(); @@ -284,12 +284,12 @@ void PlantumlManager::run() runPlantumlContent(m_svgPlantumlFiles, m_svgPlantumlContent, PUML_SVG); runPlantumlContent(m_epsPlantumlFiles, m_epsPlantumlContent, PUML_EPS); QCString outputFilename = Config_getString(OUTPUT_DIRECTORY) + "/" + CACHE_FILENAME; - QFile file(outputFilename); - if (!file.open(IO_WriteOnly)) + std::ofstream file(outputFilename.str(),std::ofstream::out | std::ofstream::binary); + if (!file.is_open()) { err("Could not open file %s for writing\n",CACHE_FILENAME); } - file.writeBlock( m_currentPlantumlAllContent, m_currentPlantumlAllContent.length() ); + file.write( m_currentPlantumlAllContent.data(), m_currentPlantumlAllContent.length() ); file.close(); } diff --git a/src/portable.cpp b/src/portable.cpp index a1f1e96..11fcb82 100644 --- a/src/portable.cpp +++ b/src/portable.cpp @@ -16,6 +16,7 @@ extern char **environ; #endif +#include <assert.h> #include <ctype.h> #include <map> #include <string> @@ -146,8 +147,10 @@ int Portable::system(const char *command,const char *args,bool commandHasConsole // For that case COM is initialized as follows CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); - QString commandw = QString::fromUtf8( commandCorrectedPath ); - QString argsw = QString::fromUtf8( args ); + uint16_t *commandw = NULL; + recodeUtf8StringToW( commandCorrectedPath, &commandw ); + uint16_t *argsw = NULL; + recodeUtf8StringToW( args, &argsw ); // gswin32 is a GUI api which will pop up a window and run // asynchronously. To prevent both, we use ShellExecuteEx and @@ -161,8 +164,8 @@ int Portable::system(const char *command,const char *args,bool commandHasConsole */ NULL, /* window handle */ NULL, /* action to perform: open */ - (LPCWSTR)commandw.ucs2(), /* file to execute */ - (LPCWSTR)argsw.ucs2(), /* argument list */ + (LPCWSTR)commandw, /* file to execute */ + (LPCWSTR)argsw, /* argument list */ NULL, /* use current working dir */ SW_HIDE, /* minimize on start-up */ 0, /* application instance handle */ @@ -176,6 +179,8 @@ int Portable::system(const char *command,const char *args,bool commandHasConsole if (!ShellExecuteExW(&sInfo)) { + delete[] commandw; + delete[] argsw; return -1; } else if (sInfo.hProcess) /* executable was launched, wait for it to finish */ @@ -188,6 +193,8 @@ int Portable::system(const char *command,const char *args,bool commandHasConsole exitCode = -1; } CloseHandle(sInfo.hProcess); + delete[] commandw; + delete[] argsw; return exitCode; } } @@ -314,9 +321,18 @@ portable_off_t Portable::ftell(FILE *f) FILE *Portable::fopen(const char *fileName,const char *mode) { #if defined(_WIN32) && !defined(__CYGWIN__) - QString fn(fileName); - QString m(mode); - return _wfopen((wchar_t*)fn.ucs2(),(wchar_t*)m.ucs2()); + uint16_t *fn = 0; + size_t fn_len = recodeUtf8StringToW(fileName,&fn); + uint16_t *m = 0; + size_t m_len = recodeUtf8StringToW(mode,&m); + FILE *result = 0; + if (fn_len!=(size_t)-1 && m_len!=(size_t)-1) + { + result = _wfopen((wchar_t*)fn,(wchar_t*)m); + } + delete[] fn; + delete[] m; + return result; #else return ::fopen(fileName,mode); #endif @@ -582,3 +598,21 @@ const char *Portable::devNull() return "/dev/null"; #endif } + +size_t Portable::recodeUtf8StringToW(const char *inputStr,uint16_t **outBuf) +{ + if (inputStr==0 || outBuf==0) return 0; // empty input or invalid output + void *handle = portable_iconv_open("UTF-16LE","UTF-8"); + if (handle==(void *)(-1)) return 0; // invalid encoding + size_t len = strlen(inputStr); + uint16_t *buf = new uint16_t[len+1]; + *outBuf = buf; + size_t inRemains = len; + size_t outRemains = len*sizeof(uint16_t)+2; // chars + \0 + portable_iconv(handle,(char**)&inputStr,&inRemains,(char**)&buf,&outRemains); + *buf=0; + portable_iconv_close(handle); + return len; +} + + diff --git a/src/portable.h b/src/portable.h index d2b3036..d1bfed1 100644 --- a/src/portable.h +++ b/src/portable.h @@ -3,9 +3,9 @@ #include <stdio.h> #include <sys/types.h> +#include <stdint.h> - - +class Buf; #if defined(_WIN32) typedef __int64 portable_off_t; @@ -45,12 +45,13 @@ namespace Portable const char * strnstr(const char *haystack, const char *needle, size_t haystack_len); const char * devNull(); bool checkForExecutable(const char *fileName); + size_t recodeUtf8StringToW(const char *inputStr,uint16_t **buf); } extern "C" { void * portable_iconv_open(const char* tocode, const char* fromcode); - size_t portable_iconv (void *cd, char** inbuf, size_t *inbytesleft, + size_t portable_iconv (void *cd, char** inbuf, size_t *inbytesleft, char* * outbuf, size_t *outbytesleft); int portable_iconv_close (void *cd); } diff --git a/src/qhp.cpp b/src/qhp.cpp index 50f43ff..181ed67 100644 --- a/src/qhp.cpp +++ b/src/qhp.cpp @@ -3,8 +3,8 @@ * Copyright (C) 2008 Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its - * documentation under the terms of the GNU General Public License is hereby - * granted. No representations are made about the suitability of this software + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * @@ -23,9 +23,9 @@ #include "doxygen.h" #include "filedef.h" +#include <fstream> #include <qcstringlist.h> #include <string.h> -#include <qfile.h> static QCString makeFileName(const char * withoutExtension) { @@ -47,7 +47,7 @@ static QCString makeFileName(const char * withoutExtension) static QCString makeRef(const char * withoutExtension, const char * anchor) { //printf("QHP::makeRef(%s,%s)\n",withoutExtension,anchor); - if (!withoutExtension) return QCString(); + if (!withoutExtension) return QCString(); QCString result = makeFileName(withoutExtension); if (!anchor) return result; return result+"#"+anchor; @@ -97,7 +97,7 @@ void Qhp::initialize() QCString filterName = Config_getString(QHP_CUST_FILTER_NAME); if (!filterName.isEmpty()) { - const char * tagAttributes[] = + const char * tagAttributes[] = { "name", filterName, 0 }; m_doc.open("customFilter", tagAttributes); @@ -165,8 +165,8 @@ void Qhp::finalize() m_doc.close("QtHelpProject"); QCString fileName = Config_getString(HTML_OUTPUT) + "/" + getQhpFileName(); - QFile file(fileName); - if (!file.open(IO_WriteOnly)) + std::ofstream file(fileName.str(),std::ofstream::out | std::ofstream::binary); + if (!file.is_open()) { term("Could not open file %s for writing\n", fileName.data()); } @@ -188,8 +188,8 @@ void Qhp::decContentsDepth() m_sectionLevel--; } -void Qhp::addContentsItem(bool /*isDir*/, const char * name, - const char * /*ref*/, const char * file, +void Qhp::addContentsItem(bool /*isDir*/, const char * name, + const char * /*ref*/, const char * file, const char *anchor, bool /* separateIndex */, bool /* addToNavIndex */, const Definition * /*def*/) diff --git a/src/qhpxmlwriter.cpp b/src/qhpxmlwriter.cpp index edf9ae0..51058f4 100644 --- a/src/qhpxmlwriter.cpp +++ b/src/qhpxmlwriter.cpp @@ -3,8 +3,8 @@ * Copyright (C) 2008 Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its - * documentation under the terms of the GNU General Public License is hereby - * granted. No representations are made about the suitability of this software + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * @@ -17,11 +17,8 @@ #include "qhpxmlwriter.h" #include "util.h" -#include <qfile.h> - -QhpXmlWriter::QhpXmlWriter() - : m_out(&m_backend), m_indentLevel(0), - m_curLineIndented(false), m_compress(false) +QhpXmlWriter::QhpXmlWriter() + : m_indentLevel(0), m_curLineIndented(false), m_compress(false) { } @@ -41,12 +38,12 @@ void QhpXmlWriter::setCompressionEnabled(bool enabled) void QhpXmlWriter::insert(QhpXmlWriter const & source) { - m_out << source.m_backend.data(); + m_backend << source.m_backend.str(); } -void QhpXmlWriter::dumpTo(QFile & file) +void QhpXmlWriter::dumpTo(std::ostream & file) { - file.writeBlock(m_backend.data(), m_backend.length()); + file << m_backend.str(); } void QhpXmlWriter::open(char const * elementName, @@ -71,7 +68,7 @@ void QhpXmlWriter::openCloseContent(char const * elementName, { indent(); openPure(elementName); - m_out << convertToXML(content); + m_backend << convertToXML(content); closePure(elementName); newLine(); } @@ -86,7 +83,7 @@ void QhpXmlWriter::close(char const * elementName) void QhpXmlWriter::declaration(char const * version, char const * encoding) { - m_out << "<?xml version=\"" << version << "\" encoding=\"" << encoding << "\"?>"; + m_backend << "<?xml version=\"" << version << "\" encoding=\"" << encoding << "\"?>"; newLine(); } @@ -96,9 +93,9 @@ void QhpXmlWriter::indent() { return; } - for (int i = 0; i < m_indentLevel; i++) + for (int i = 0; i < m_indentLevel; i++) { - m_out << " "; + m_backend << " "; } m_curLineIndented = true; } @@ -107,7 +104,7 @@ void QhpXmlWriter::newLine() { if (!m_compress) { - m_out << "\n"; + m_backend << "\n"; m_curLineIndented = false; } } @@ -115,7 +112,7 @@ void QhpXmlWriter::newLine() void QhpXmlWriter::openPureHelper(char const * elementName, char const * const * attributes, bool close) { - m_out << "<" << elementName; + m_backend << "<" << elementName; if (attributes) { for (char const * const * walker = attributes; @@ -125,17 +122,17 @@ void QhpXmlWriter::openPureHelper(char const * elementName, char const * const value = walker[1]; if (!value) { - continue; + continue; } - m_out << " " << key << "=\"" << convertToXML(value) << "\""; + m_backend << " " << key << "=\"" << convertToXML(value) << "\""; } } if (close) { - m_out << " /"; + m_backend << " /"; } - m_out << ">"; + m_backend << ">"; } void QhpXmlWriter::openPure(char const * elementName, @@ -152,6 +149,6 @@ void QhpXmlWriter::openClosePure(char const * elementName, void QhpXmlWriter::closePure(char const * elementName) { - m_out << "</" << elementName << ">"; + m_backend << "</" << elementName << ">"; } diff --git a/src/qhpxmlwriter.h b/src/qhpxmlwriter.h index 5541edd..31c391e 100644 --- a/src/qhpxmlwriter.h +++ b/src/qhpxmlwriter.h @@ -17,9 +17,8 @@ #ifndef QHPXMLWRITER_H #define QHPXMLWRITER_H -#include "ftextstream.h" - -class QFile; +#include <iostream> +#include <sstream> class QhpXmlWriter { @@ -30,7 +29,7 @@ class QhpXmlWriter void setIndentLevel(int level); void setCompressionEnabled(bool enabled); void insert(QhpXmlWriter const & source); - void dumpTo(QFile & file); + void dumpTo(std::ostream & file); void open(char const * elementName, char const * const * attributes = 0); void openClose(char const * elementName, @@ -52,8 +51,7 @@ class QhpXmlWriter char const * const * attributes = 0); void closePure(char const * elementName); - QGString m_backend; - FTextStream m_out; + std::stringstream m_backend; int m_indentLevel; bool m_curLineIndented; bool m_compress; diff --git a/src/reflist.cpp b/src/reflist.cpp index 39987f9..90bac91 100644 --- a/src/reflist.cpp +++ b/src/reflist.cpp @@ -14,11 +14,10 @@ */ #include <algorithm> - #include <stdio.h> + #include "reflist.h" #include "util.h" -#include "ftextstream.h" #include "definition.h" #include "config.h" diff --git a/src/resourcemgr.cpp b/src/resourcemgr.cpp index b0361f0..86d779b 100644 --- a/src/resourcemgr.cpp +++ b/src/resourcemgr.cpp @@ -14,14 +14,13 @@ */ #include <map> -#include <qfile.h> #include <qcstring.h> #include <string.h> +#include <fstream> #include "resourcemgr.h" #include "util.h" #include "version.h" -#include "ftextstream.h" #include "message.h" #include "config.h" @@ -60,9 +59,15 @@ bool ResourceMgr::writeCategory(const char *categoryName,const char *targetDir) Resource &res = kv.second; if (qstrcmp(res.category,categoryName)==0) { - QCString pathName = QCString(targetDir)+"/"+res.name; - QFile f(pathName); - if (!f.open(IO_WriteOnly) || f.writeBlock((const char *)res.data,res.size)!=res.size) + std::string pathName = std::string(targetDir)+"/"+res.name; + std::ofstream f(pathName,std::ofstream::out | std::ofstream::binary); + bool ok=false; + if (f.is_open()) + { + f.write(reinterpret_cast<const char *>(res.data),res.size); + ok = !f.fail(); + } + if (!ok) { err("Failed to write resource '%s' to directory '%s'\n",res.name,targetDir); return FALSE; @@ -74,7 +79,7 @@ bool ResourceMgr::writeCategory(const char *categoryName,const char *targetDir) bool ResourceMgr::copyResourceAs(const char *name,const char *targetDir,const char *targetName) const { - QCString pathName = QCString(targetDir)+"/"+targetName; + std::string pathName = std::string(targetDir)+"/"+targetName; const Resource *res = get(name); if (res) { @@ -82,8 +87,14 @@ bool ResourceMgr::copyResourceAs(const char *name,const char *targetDir,const ch { case Resource::Verbatim: { - QFile f(pathName); - if (f.open(IO_WriteOnly) && f.writeBlock((const char *)res->data,res->size)==res->size) + std::ofstream f(pathName,std::ofstream::out | std::ofstream::binary); + bool ok=false; + if (f.is_open()) + { + f.write(reinterpret_cast<const char *>(res->data),res->size); + ok = !f.fail(); + } + if (ok) { return TRUE; } @@ -127,12 +138,11 @@ bool ResourceMgr::copyResourceAs(const char *name,const char *targetDir,const ch break; case Resource::CSS: { - QFile f(pathName); - if (f.open(IO_WriteOnly)) + std::ofstream t(pathName,std::ofstream::out | std::ofstream::binary); + if (t.is_open()) { QCString buf(res->size+1); memcpy(buf.rawData(),res->data,res->size); - FTextStream t(&f); buf = replaceColorMarkers(buf); if (qstrcmp(name,"navtree.css")==0) { @@ -148,12 +158,11 @@ bool ResourceMgr::copyResourceAs(const char *name,const char *targetDir,const ch break; case Resource::SVG: { - QFile f(pathName); - if (f.open(IO_WriteOnly)) + std::ofstream t(pathName,std::ostream::out | std::ofstream::binary); + if (t.is_open()) { QCString buf(res->size+1); memcpy(buf.rawData(),res->data,res->size); - FTextStream t(&f); t << replaceColorMarkers(buf); return TRUE; } diff --git a/src/rtfdocvisitor.cpp b/src/rtfdocvisitor.cpp index 6b6fef0..de3d869 100644 --- a/src/rtfdocvisitor.cpp +++ b/src/rtfdocvisitor.cpp @@ -53,7 +53,7 @@ static QCString align(DocHtmlCell *cell) return ""; } -RTFDocVisitor::RTFDocVisitor(FTextStream &t,CodeOutputInterface &ci, +RTFDocVisitor::RTFDocVisitor(std::ostream &t,CodeOutputInterface &ci, const char *langExt) : DocVisitor(DocVisitor_RTF), m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE), m_indentLevel(0), m_lastIsPara(FALSE), m_langExt(langExt) @@ -192,7 +192,7 @@ void RTFDocVisitor::visit(DocURL *u) filter(u->url()); m_t << "}" "}" - "}" << endl; + "}\n"; } else { @@ -207,7 +207,7 @@ void RTFDocVisitor::visit(DocLineBreak *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visit(DocLineBreak)}\n"); - m_t << "\\par" << endl; + m_t << "\\par\n"; m_lastIsPara=TRUE; } @@ -215,7 +215,7 @@ void RTFDocVisitor::visit(DocHorRuler *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visit(DocHorRuler)}\n"); - m_t << "{\\pard\\widctlpar\\brdrb\\brdrs\\brdrw5\\brsp20 \\adjustright \\par}" << endl; + m_t << "{\\pard\\widctlpar\\brdrb\\brdrs\\brdrw5\\brsp20 \\adjustright \\par}\n"; m_lastIsPara=TRUE; } @@ -259,8 +259,8 @@ void RTFDocVisitor::visit(DocStyleChange *s) case DocStyleChange::Preformatted: if (s->enable()) { - m_t << "{" << endl; - m_t << "\\par" << endl; + m_t << "{\n"; + m_t << "\\par\n"; m_t << rtf_Style_Reset << getStyle("CodeExample"); m_insidePre=TRUE; } @@ -268,7 +268,7 @@ void RTFDocVisitor::visit(DocStyleChange *s) { m_insidePre=FALSE; m_t << "\\par"; - m_t << "}" << endl; + m_t << "}\n"; } m_lastIsPara=TRUE; break; @@ -295,21 +295,21 @@ void RTFDocVisitor::visit(DocVerbatim *s) switch(s->type()) { case DocVerbatim::Code: // fall though - m_t << "{" << endl; - m_t << "\\par" << endl; + m_t << "{\n"; + m_t << "\\par\n"; m_t << rtf_Style_Reset << getStyle("CodeExample"); getCodeParser(lang).parseCode(m_ci,s->context(),s->text(),langExt, s->isExample(),s->exampleFile()); - //m_t << "\\par" << endl; - m_t << "}" << endl; + //m_t << "\\par\n"; + m_t << "}\n"; break; case DocVerbatim::Verbatim: - m_t << "{" << endl; - m_t << "\\par" << endl; + m_t << "{\n"; + m_t << "\\par\n"; m_t << rtf_Style_Reset << getStyle("CodeExample"); filter(s->text(),TRUE); - //m_t << "\\par" << endl; - m_t << "}" << endl; + //m_t << "\\par\n"; + m_t << "}\n"; break; case DocVerbatim::RtfOnly: m_t << s->text(); @@ -331,19 +331,23 @@ void RTFDocVisitor::visit(DocVerbatim *s) dotindex++, ".dot" ); - QFile file(fileName); - if (!file.open(IO_WriteOnly)) + std::ofstream file(fileName.str(),std::ofstream::out | std::ofstream::binary); + if (!file.is_open()) { err("Could not open file %s for writing\n",fileName.data()); } - file.writeBlock( s->text(), s->text().length() ); - file.close(); + else + { + QCString stext = s->text(); + file.write( stext.data(), stext.length() ); + file.close(); + } writeDotFile(fileName, s->hasCaption()); visitCaption(this, s->children()); includePicturePostRTF(true, s->hasCaption()); - if (Config_getBool(DOT_CLEANUP)) file.remove(); + if (Config_getBool(DOT_CLEANUP)) Dir().remove(fileName.str()); } break; case DocVerbatim::Msc: @@ -356,22 +360,22 @@ void RTFDocVisitor::visit(DocVerbatim *s) mscindex++, ".msc" ); - QFile file(baseName); - if (!file.open(IO_WriteOnly)) + std::ofstream file(baseName.str(),std::ofstream::out | std::ofstream::binary); + if (!file.is_open()) { err("Could not open file %s for writing\n",baseName.data()); } QCString text = "msc {"; text+=s->text(); text+="}"; - file.writeBlock( text, text.length() ); + file.write( text.data(), text.length() ); file.close(); writeMscFile(baseName, s->hasCaption()); visitCaption(this, s->children()); includePicturePostRTF(true, s->hasCaption()); - if (Config_getBool(DOT_CLEANUP)) file.remove(); + if (Config_getBool(DOT_CLEANUP)) Dir().remove(baseName.str()); } break; case DocVerbatim::PlantUML: @@ -405,8 +409,8 @@ void RTFDocVisitor::visit(DocAnchor *anc) { anchor+=anc->anchor(); } - m_t << "{\\bkmkstart " << rtfFormatBmkStr(anchor) << "}" << endl; - m_t << "{\\bkmkend " << rtfFormatBmkStr(anchor) << "}" << endl; + m_t << "{\\bkmkstart " << rtfFormatBmkStr(anchor) << "}\n"; + m_t << "{\\bkmkend " << rtfFormatBmkStr(anchor) << "}\n"; m_lastIsPara=FALSE; } @@ -419,8 +423,8 @@ void RTFDocVisitor::visit(DocInclude *inc) { case DocInclude::IncWithLines: { - m_t << "{" << endl; - m_t << "\\par" << endl; + m_t << "{\n"; + m_t << "\\par\n"; m_t << rtf_Style_Reset << getStyle("CodeExample"); FileInfo cfi( inc->file().str() ); FileDef *fd = createFileDef( cfi.dirPath(), cfi.fileName() ); @@ -438,12 +442,12 @@ void RTFDocVisitor::visit(DocInclude *inc) ); delete fd; m_t << "\\par"; - m_t << "}" << endl; + m_t << "}\n"; } break; case DocInclude::Include: - m_t << "{" << endl; - m_t << "\\par" << endl; + m_t << "{\n"; + m_t << "\\par\n"; m_t << rtf_Style_Reset << getStyle("CodeExample"); getCodeParser(inc->extension()).parseCode(m_ci,inc->context(), inc->text(),langExt,inc->isExample(), @@ -456,7 +460,7 @@ void RTFDocVisitor::visit(DocInclude *inc) FALSE // show line numbers ); m_t << "\\par"; - m_t << "}" << endl; + m_t << "}\n"; break; case DocInclude::DontInclude: case DocInclude::DontIncWithLines: @@ -470,16 +474,16 @@ void RTFDocVisitor::visit(DocInclude *inc) m_t << inc->text(); break; case DocInclude::VerbInclude: - m_t << "{" << endl; - m_t << "\\par" << endl; + m_t << "{\n"; + m_t << "\\par\n"; m_t << rtf_Style_Reset << getStyle("CodeExample"); filter(inc->text()); m_t << "\\par"; - m_t << "}" << endl; + m_t << "}\n"; break; case DocInclude::Snippet: - m_t << "{" << endl; - if (!m_lastIsPara) m_t << "\\par" << endl; + m_t << "{\n"; + if (!m_lastIsPara) m_t << "\\par\n"; m_t << rtf_Style_Reset << getStyle("CodeExample"); getCodeParser(inc->extension()).parseCode(m_ci, inc->context(), @@ -494,8 +498,8 @@ void RTFDocVisitor::visit(DocInclude *inc) { FileInfo cfi( inc->file().str() ); FileDef *fd = createFileDef( cfi.dirPath(), cfi.fileName() ); - m_t << "{" << endl; - if (!m_lastIsPara) m_t << "\\par" << endl; + m_t << "{\n"; + if (!m_lastIsPara) m_t << "\\par\n"; m_t << rtf_Style_Reset << getStyle("CodeExample"); getCodeParser(inc->extension()).parseCode(m_ci, inc->context(), @@ -535,8 +539,8 @@ void RTFDocVisitor::visit(DocIncOperator *op) { if (!m_hide) { - m_t << "{" << endl; - m_t << "\\par" << endl; + m_t << "{\n"; + m_t << "\\par\n"; m_t << rtf_Style_Reset << getStyle("CodeExample"); } pushHidden(m_hide); @@ -574,13 +578,13 @@ void RTFDocVisitor::visit(DocIncOperator *op) if (!m_hide) { m_t << "\\par"; - m_t << "}" << endl; + m_t << "}\n"; } m_lastIsPara=TRUE; } else { - if (!m_hide) m_t << endl; + if (!m_hide) m_t << "\n"; m_lastIsPara=FALSE; } } @@ -610,7 +614,7 @@ void RTFDocVisitor::visit(DocIndexEntry *i) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visit(DocIndexEntry)}\n"); - m_t << "{\\xe \\v " << i->entry() << "}" << endl; + m_t << "{\\xe \\v " << i->entry() << "}\n"; m_lastIsPara=FALSE; } @@ -650,7 +654,7 @@ void RTFDocVisitor::visitPre(DocAutoList *l) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocAutoList)}\n"); - m_t << "{" << endl; + m_t << "{\n"; rtf_listItemInfo[m_indentLevel].isEnum = l->isEnumList(); rtf_listItemInfo[m_indentLevel].number = 1; m_lastIsPara=FALSE; @@ -661,26 +665,26 @@ void RTFDocVisitor::visitPost(DocAutoList *) if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocAutoList)}\n"); if (!m_lastIsPara) m_t << "\\par"; - m_t << "}" << endl; + m_t << "}\n"; m_lastIsPara=TRUE; - if (!m_indentLevel) m_t << "\\par" << endl; + if (!m_indentLevel) m_t << "\\par\n"; } void RTFDocVisitor::visitPre(DocAutoListItem *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocAutoListItem)}\n"); - if (!m_lastIsPara) m_t << "\\par" << endl; + if (!m_lastIsPara) m_t << "\\par\n"; m_t << rtf_Style_Reset; if (rtf_listItemInfo[m_indentLevel].isEnum) { - m_t << getStyle("ListEnum") << endl; + m_t << getStyle("ListEnum") << "\n"; m_t << rtf_listItemInfo[m_indentLevel].number << ".\\tab "; rtf_listItemInfo[m_indentLevel].number++; } else { - m_t << getStyle("ListBullet") << endl; + m_t << getStyle("ListBullet") << "\n"; } incIndentLevel(); m_lastIsPara=FALSE; @@ -708,7 +712,7 @@ void RTFDocVisitor::visitPost(DocPara *p) ) ) { - m_t << "\\par" << endl; + m_t << "\\par\n"; m_lastIsPara=TRUE; } } @@ -718,14 +722,14 @@ void RTFDocVisitor::visitPre(DocRoot *r) if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocRoot)}\n"); if (r->indent()) incIndentLevel(); - m_t << "{" << rtf_Style["BodyText"].reference() << endl; + m_t << "{" << rtf_Style["BodyText"].reference() << "\n"; } void RTFDocVisitor::visitPost(DocRoot *r) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocRoot)}\n"); - if (!m_lastIsPara && !r->singleLine()) m_t << "\\par" << endl; + if (!m_lastIsPara && !r->singleLine()) m_t << "\\par\n"; m_t << "}"; m_lastIsPara=TRUE; if (r->indent()) decIndentLevel(); @@ -735,10 +739,10 @@ void RTFDocVisitor::visitPre(DocSimpleSect *s) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocSimpleSect)}\n"); - if (!m_lastIsPara) m_t << "\\par" << endl; + if (!m_lastIsPara) m_t << "\\par\n"; m_t << "{"; // start desc //m_t << "{\\b "; // start bold - m_t << "{" << rtf_Style["Heading5"].reference() << endl; + m_t << "{" << rtf_Style["Heading5"].reference() << "\n"; switch(s->type()) { case DocSimpleSect::See: @@ -792,7 +796,7 @@ void RTFDocVisitor::visitPost(DocSimpleSect *s) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocSimpleSect)}\n"); - if (!m_lastIsPara) m_t << "\\par" << endl; + if (!m_lastIsPara) m_t << "\\par\n"; decIndentLevel(); if (s->type()!=DocSimpleSect::User && s->type()!=DocSimpleSect::Rcs) m_t << "}"; m_t << "}"; // end desc @@ -808,7 +812,7 @@ void RTFDocVisitor::visitPost(DocTitle *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocTitle)}\n"); - m_t << "\\par" << endl; + m_t << "\\par\n"; m_t << "}"; // end bold incIndentLevel(); m_t << rtf_Style_Reset << getStyle("DescContinue"); @@ -819,7 +823,7 @@ void RTFDocVisitor::visitPre(DocSimpleList *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocSimpleSect)}\n"); - m_t << "{" << endl; + m_t << "{\n"; rtf_listItemInfo[m_indentLevel].isEnum = FALSE; m_lastIsPara=FALSE; } @@ -828,8 +832,8 @@ void RTFDocVisitor::visitPost(DocSimpleList *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocSimpleSect)}\n"); - if (!m_lastIsPara) m_t << "\\par" << endl; - m_t << "}" << endl; + if (!m_lastIsPara) m_t << "\\par\n"; + m_t << "}\n"; m_lastIsPara=TRUE; } @@ -837,7 +841,7 @@ void RTFDocVisitor::visitPre(DocSimpleListItem *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocSimpleListItem)}\n"); - m_t << "\\par" << rtf_Style_Reset << getStyle("ListBullet") << endl; + m_t << "\\par" << rtf_Style_Reset << getStyle("ListBullet") << "\n"; m_lastIsPara=FALSE; incIndentLevel(); } @@ -852,22 +856,22 @@ void RTFDocVisitor::visitPre(DocSection *s) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocSection)}\n"); - if (!m_lastIsPara) m_t << "\\par" << endl; - m_t << "{\\bkmkstart " << rtfFormatBmkStr(s->file()+"_"+s->anchor()) << "}" << endl; - m_t << "{\\bkmkend " << rtfFormatBmkStr(s->file()+"_"+s->anchor()) << "}" << endl; + if (!m_lastIsPara) m_t << "\\par\n"; + m_t << "{\\bkmkstart " << rtfFormatBmkStr(s->file()+"_"+s->anchor()) << "}\n"; + m_t << "{\\bkmkend " << rtfFormatBmkStr(s->file()+"_"+s->anchor()) << "}\n"; m_t << "{{" // start section << rtf_Style_Reset; QCString heading; int level = QMIN(s->level()+1,4); heading.sprintf("Heading%d",level); // set style - m_t << rtf_Style[heading.str()].reference() << endl; + m_t << rtf_Style[heading.str()].reference() << "\n"; // make table of contents entry filter(s->title()); - m_t << endl << "\\par" << "}" << endl; + m_t << "\n\\par" << "}\n"; m_t << "{\\tc\\tcl" << level << " \\v "; filter(s->title()); - m_t << "}" << endl; + m_t << "}\n"; m_lastIsPara=TRUE; } @@ -875,7 +879,7 @@ void RTFDocVisitor::visitPost(DocSection *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocSection)}\n"); - m_t << "\\par}" << endl; // end section + m_t << "\\par}\n"; // end section m_lastIsPara=TRUE; } @@ -883,7 +887,7 @@ void RTFDocVisitor::visitPre(DocHtmlList *l) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocHtmlList)}\n"); - m_t << "{" << endl; + m_t << "{\n"; rtf_listItemInfo[m_indentLevel].isEnum = l->type()==DocHtmlList::Ordered; rtf_listItemInfo[m_indentLevel].number = 1; m_lastIsPara=FALSE; @@ -893,7 +897,7 @@ void RTFDocVisitor::visitPost(DocHtmlList *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlList)}\n"); - m_t << "\\par" << "}" << endl; + m_t << "\\par" << "}\n"; m_lastIsPara=TRUE; } @@ -901,17 +905,17 @@ void RTFDocVisitor::visitPre(DocHtmlListItem *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocHtmlListItem)}\n"); - m_t << "\\par" << endl; + m_t << "\\par\n"; m_t << rtf_Style_Reset; if (rtf_listItemInfo[m_indentLevel].isEnum) { - m_t << getStyle("ListEnum") << endl; + m_t << getStyle("ListEnum") << "\n"; m_t << rtf_listItemInfo[m_indentLevel].number << ".\\tab "; rtf_listItemInfo[m_indentLevel].number++; } else { - m_t << getStyle("ListBullet") << endl; + m_t << getStyle("ListBullet") << "\n"; } incIndentLevel(); m_lastIsPara=FALSE; @@ -927,7 +931,7 @@ void RTFDocVisitor::visitPre(DocHtmlDescList *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocHtmlDescList)}\n"); - //m_t << "{" << endl; + //m_t << "{\n"; //m_t << rtf_Style_Reset << getStyle("ListContinue"); //m_lastIsPara=FALSE; } @@ -936,8 +940,8 @@ void RTFDocVisitor::visitPost(DocHtmlDescList *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlDescList)}\n"); - //m_t << "}" << endl; - //m_t << "\\par" << endl; + //m_t << "}\n"; + //m_t << "\\par\n"; //m_lastIsPara=TRUE; } @@ -945,9 +949,9 @@ void RTFDocVisitor::visitPre(DocHtmlDescTitle *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocHtmlDescTitle)}\n"); - //m_t << "\\par" << endl; + //m_t << "\\par\n"; //m_t << "{\\b "; - m_t << "{" << rtf_Style["Heading5"].reference() << endl; + m_t << "{" << rtf_Style["Heading5"].reference() << "\n"; m_lastIsPara=FALSE; } @@ -955,8 +959,8 @@ void RTFDocVisitor::visitPost(DocHtmlDescTitle *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlDescTitle)}\n"); - m_t << "\\par" << endl; - m_t << "}" << endl; + m_t << "\\par\n"; + m_t << "}\n"; m_lastIsPara=TRUE; } @@ -973,7 +977,7 @@ void RTFDocVisitor::visitPost(DocHtmlDescData *) if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlDescData)}\n"); m_t << "\\par"; - m_t << "}" << endl; + m_t << "}\n"; decIndentLevel(); m_lastIsPara=TRUE; } @@ -982,7 +986,7 @@ void RTFDocVisitor::visitPre(DocHtmlTable *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocHtmlTable)}\n"); - if (!m_lastIsPara) m_t << "\\par" << endl; + if (!m_lastIsPara) m_t << "\\par\n"; m_lastIsPara=TRUE; } @@ -990,8 +994,8 @@ void RTFDocVisitor::visitPost(DocHtmlTable *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlTable)}\n"); - m_t << "\\pard\\plain" << endl; - m_t << "\\par" << endl; + m_t << "\\pard\\plain\n"; + m_t << "\\par\n"; m_lastIsPara=TRUE; } @@ -1005,7 +1009,7 @@ void RTFDocVisitor::visitPre(DocHtmlCaption *) void RTFDocVisitor::visitPost(DocHtmlCaption *) { DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlCaption)}\n"); - m_t << "}\n\\par" << endl; + m_t << "}\n\\par\n"; } void RTFDocVisitor::visitPre(DocHtmlRow *r) @@ -1019,7 +1023,7 @@ void RTFDocVisitor::visitPre(DocHtmlRow *r) "\\trbrdrb\\brdrs\\brdrw10 " "\\trbrdrr\\brdrs\\brdrw10 " "\\trbrdrh\\brdrs\\brdrw10 " - "\\trbrdrv\\brdrs\\brdrw10 "<< endl; + "\\trbrdrv\\brdrs\\brdrw10 \n"; for (i=0;i<r->numCells();i++) { if (r->isHeading()) @@ -1031,9 +1035,9 @@ void RTFDocVisitor::visitPre(DocHtmlRow *r) "\\clbrdrb\\brdrs\\brdrw10 " "\\clbrdrr \\brdrs\\brdrw10 " "\\cltxlrtb " - "\\cellx" << ((i+1)*columnWidth) << endl; + "\\cellx" << ((i+1)*columnWidth) << "\n"; } - m_t << "\\pard \\widctlpar\\intbl\\adjustright" << endl; + m_t << "\\pard \\widctlpar\\intbl\\adjustright\n"; m_lastIsPara=FALSE; } @@ -1041,9 +1045,9 @@ void RTFDocVisitor::visitPost(DocHtmlRow *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlRow)}\n"); - m_t << endl; - m_t << "\\pard \\widctlpar\\intbl\\adjustright" << endl; - m_t << "{\\row }" << endl; + m_t << "\n"; + m_t << "\\pard \\widctlpar\\intbl\\adjustright\n"; + m_t << "{\\row }\n"; m_lastIsPara=FALSE; } @@ -1071,7 +1075,7 @@ void RTFDocVisitor::visitPre(DocInternal *) //m_t << "{\\b "; // start bold //m_t << theTranslator->trForInternalUseOnly(); //m_t << "}"; // end bold - //m_t << "\\par" << endl; + //m_t << "\\par\n"; //incIndentLevel(); //m_t << rtf_Style_Reset << getStyle("DescContinue"); //m_lastIsPara=FALSE; @@ -1164,7 +1168,7 @@ void RTFDocVisitor::visitPost(DocHtmlHeader *) DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlHeader)}\n"); // close open table of contents entry m_t << "} \\par"; - m_t << "}" << endl; // end section + m_t << "}\n"; // end section m_lastIsPara=TRUE; } @@ -1179,18 +1183,18 @@ void RTFDocVisitor::includePicturePreRTF(const QCString name, bool isTypeRTF, bo { if (!inlineImage) { - m_t << "\\par" << endl; - m_t << "{" << endl; - m_t << rtf_Style_Reset << endl; - if (hasCaption || m_lastIsPara) m_t << "\\par" << endl; + m_t << "\\par\n"; + m_t << "{\n"; + m_t << rtf_Style_Reset << "\n"; + if (hasCaption || m_lastIsPara) m_t << "\\par\n"; m_t << "\\pard \\qc "; } m_t << "{ \\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \""; m_t << name; - m_t << "\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt Image}}" << endl; + m_t << "\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt Image}}\n"; if (!inlineImage) { - m_t << "\\par" << endl; + m_t << "\\par\n"; if (hasCaption) { m_t << "\\pard \\qc \\b"; @@ -1229,12 +1233,12 @@ void RTFDocVisitor::includePicturePostRTF(bool isTypeRTF, bool hasCaption, bool { if (hasCaption) { - m_t << "}" <<endl; - m_t << "\\par}" <<endl; + m_t << "}\n"; + m_t << "\\par}\n"; } else { - m_t << "}" <<endl; + m_t << "}\n"; } } } @@ -1333,10 +1337,10 @@ void RTFDocVisitor::visitPre(DocSecRefList *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocSecRefList)}\n"); - m_t << "{" << endl; + m_t << "{\n"; incIndentLevel(); - m_t << rtf_Style_Reset << getStyle("LatexTOC") << endl; - m_t << "\\par" << endl; + m_t << rtf_Style_Reset << getStyle("LatexTOC") << "\n"; + m_t << "\\par\n"; m_lastIsPara=TRUE; } @@ -1346,7 +1350,7 @@ void RTFDocVisitor::visitPost(DocSecRefList *) DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocSecRefList)}\n"); decIndentLevel(); m_t << "\\par"; - m_t << "}" << endl; + m_t << "}\n"; m_lastIsPara=TRUE; } @@ -1355,9 +1359,9 @@ void RTFDocVisitor::visitPre(DocParamSect *s) if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocParamSect)}\n"); m_t << "{"; // start param list - if (!m_lastIsPara) m_t << "\\par" << endl; + if (!m_lastIsPara) m_t << "\\par\n"; //m_t << "{\\b "; // start bold - m_t << "{" << rtf_Style["Heading5"].reference() << endl; + m_t << "{" << rtf_Style["Heading5"].reference() << "\n"; switch(s->type()) { case DocParamSect::Param: @@ -1372,7 +1376,7 @@ void RTFDocVisitor::visitPre(DocParamSect *s) ASSERT(0); } m_t << "\\par"; - m_t << "}" << endl; + m_t << "}\n"; bool useTable = s->type()==DocParamSect::Param || s->type()==DocParamSect::RetVal || s->type()==DocParamSect::Exception || @@ -1389,7 +1393,7 @@ void RTFDocVisitor::visitPost(DocParamSect *s) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocParamSect)}\n"); - //m_t << "\\par" << endl; + //m_t << "\\par\n"; bool useTable = s->type()==DocParamSect::Param || s->type()==DocParamSect::RetVal || s->type()==DocParamSect::Exception || @@ -1398,7 +1402,7 @@ void RTFDocVisitor::visitPost(DocParamSect *s) { decIndentLevel(); } - m_t << "}" << endl; + m_t << "}\n"; } void RTFDocVisitor::visitPre(DocParamList *pl) @@ -1435,7 +1439,7 @@ void RTFDocVisitor::visitPre(DocParamList *pl) "\\trbrdrb\\brdrs\\brdrw10\\brdrcf15 " "\\trbrdrr\\brdrs\\brdrw10\\brdrcf15 " "\\trbrdrh\\brdrs\\brdrw10\\brdrcf15 " - "\\trbrdrv\\brdrs\\brdrw10\\brdrcf15 "<< endl; + "\\trbrdrv\\brdrs\\brdrw10\\brdrcf15 "<< "\n"; for (i=0;i<columnPos[config][0];i++) { m_t << "\\clvertalt\\clbrdrt\\brdrs\\brdrw10\\brdrcf15 " @@ -1443,9 +1447,9 @@ void RTFDocVisitor::visitPre(DocParamList *pl) "\\clbrdrb\\brdrs\\brdrw10\\brdrcf15 " "\\clbrdrr \\brdrs\\brdrw10\\brdrcf15 " "\\cltxlrtb " - "\\cellx" << (rtf_pageWidth*columnPos[config][i+1]/100) << endl; + "\\cellx" << (rtf_pageWidth*columnPos[config][i+1]/100) << "\n"; } - m_t << "\\pard \\widctlpar\\intbl\\adjustright" << endl; + m_t << "\\pard \\widctlpar\\intbl\\adjustright\n"; } if (sect && sect->hasInOutSpecifier()) @@ -1552,13 +1556,13 @@ void RTFDocVisitor::visitPost(DocParamList *pl) parentType==DocParamSect::TemplateParam; if (useTable) { - m_t << "\\cell }" << endl; - //m_t << "\\pard \\widctlpar\\intbl\\adjustright" << endl; - m_t << "{\\row }" << endl; + m_t << "\\cell }\n"; + //m_t << "\\pard \\widctlpar\\intbl\\adjustright\n"; + m_t << "{\\row }\n"; } else { - m_t << "\\par" << endl; + m_t << "\\par\n"; } m_lastIsPara=TRUE; @@ -1572,12 +1576,12 @@ void RTFDocVisitor::visitPre(DocXRefItem *x) DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocXRefItem)}\n"); if (!m_lastIsPara) { - m_t << "\\par" << endl; + m_t << "\\par\n"; m_lastIsPara=TRUE; } m_t << "{"; // start param list //m_t << "{\\b "; // start bold - m_t << "{" << rtf_Style["Heading5"].reference() << endl; + m_t << "{" << rtf_Style["Heading5"].reference() << "\n"; if (Config_getBool(RTF_HYPERLINKS) && !anonymousEnum) { QCString refName; @@ -1623,9 +1627,9 @@ void RTFDocVisitor::visitPost(DocXRefItem *x) if (m_hide) return; if (x->title().isEmpty()) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocXRefItem)}\n"); - m_t << "\\par" << endl; + m_t << "\\par\n"; decIndentLevel(); - m_t << "}" << endl; // end xref item + m_t << "}\n"; // end xref item m_lastIsPara=TRUE; } @@ -1660,7 +1664,7 @@ void RTFDocVisitor::visitPre(DocHtmlBlockQuote *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPre(DocHtmlBlockQuote)}\n"); - if (!m_lastIsPara) m_t << "\\par" << endl; + if (!m_lastIsPara) m_t << "\\par\n"; m_t << "{"; // start desc incIndentLevel(); m_t << rtf_Style_Reset << getStyle("DescContinue"); @@ -1670,7 +1674,7 @@ void RTFDocVisitor::visitPost(DocHtmlBlockQuote *) { if (m_hide) return; DBG_RTF("{\\comment RTFDocVisitor::visitPost(DocHtmlBlockQuote)}\n"); - if (!m_lastIsPara) m_t << "\\par" << endl; + if (!m_lastIsPara) m_t << "\\par\n"; decIndentLevel(); m_t << "}"; // end desc m_lastIsPara=TRUE; @@ -1736,7 +1740,7 @@ void RTFDocVisitor::filter(const char *str,bool verbatim) case '\\': m_t << "\\\\"; break; case '\n': if (verbatim) { - m_t << "\\par" << endl; + m_t << "\\par\n"; } else { diff --git a/src/rtfdocvisitor.h b/src/rtfdocvisitor.h index 5cb5de3..cbe4eb0 100644 --- a/src/rtfdocvisitor.h +++ b/src/rtfdocvisitor.h @@ -19,17 +19,18 @@ #ifndef _RTFDOCVISITOR_H #define _RTFDOCVISITOR_H +#include <iostream> + #include "docvisitor.h" #include <qcstring.h> -class FTextStream; class CodeOutputInterface; /*! @brief Concrete visitor implementation for RTF output. */ class RTFDocVisitor : public DocVisitor { public: - RTFDocVisitor(FTextStream &t,CodeOutputInterface &ci,const char *langExt); + RTFDocVisitor(std::ostream &t,CodeOutputInterface &ci,const char *langExt); //-------------------------------------- // visitor functions for leaf nodes @@ -161,7 +162,7 @@ class RTFDocVisitor : public DocVisitor // state variables //-------------------------------------- - FTextStream &m_t; + std::ostream &m_t; CodeOutputInterface &m_ci; bool m_insidePre; bool m_hide; diff --git a/src/rtfgen.cpp b/src/rtfgen.cpp index 636d278..0f96cad 100644 --- a/src/rtfgen.cpp +++ b/src/rtfgen.cpp @@ -97,9 +97,8 @@ void RTFGenerator::setSourceFileName(const QCString &name) m_sourceFileName = name; } -void RTFGenerator::writeStyleSheetFile(QFile &file) +void RTFGenerator::writeStyleSheetFile(std::ostream &t) { - FTextStream t(&file); t << "# Generated by doxygen " << getDoxygenVersion() << "\n\n"; t << "# This file describes styles used for generating RTF output.\n"; t << "# All text after a hash (#) is considered a comment and will be ignored.\n"; @@ -110,13 +109,12 @@ void RTFGenerator::writeStyleSheetFile(QFile &file) { t << "# " << rtf_Style_Default[i].name << " = " << rtf_Style_Default[i].reference - << rtf_Style_Default[i].definition << endl; + << rtf_Style_Default[i].definition << "\n"; } } -void RTFGenerator::writeExtensionsFile(QFile &file) +void RTFGenerator::writeExtensionsFile(std::ostream &t) { - FTextStream t(&file); t << "# Generated by doxygen " << getDoxygenVersion() << "\n\n"; t << "# This file describes extensions used for generating RTF output.\n"; t << "# All text after a hash (#) is considered a comment and will be ignored.\n"; @@ -323,9 +321,9 @@ void RTFGenerator::beginRTFDocument() } } - t <<"}" << endl; + t <<"}\n"; // this comment is needed for postprocessing! - t <<"{\\comment begin body}" << endl; + t <<"{\\comment begin body}\n"; } @@ -393,13 +391,13 @@ void RTFGenerator::endFile() void RTFGenerator::startProjectNumber() { - DBG_RTF(t <<"{\\comment startProjectNumber }" << endl) + DBG_RTF(t <<"{\\comment startProjectNumber }\n") t << " "; } void RTFGenerator::endProjectNumber() { - DBG_RTF(t <<"{\\comment endProjectNumber }" << endl) + DBG_RTF(t <<"{\\comment endProjectNumber }\n") } void RTFGenerator::startIndexSection(IndexSections is) @@ -597,7 +595,7 @@ void RTFGenerator::endIndexSection(IndexSections is) DBG_RTF(t << "{\\comment begin title page}\n") - t << rtf_Style_Reset << rtf_Style["SubTitle"].reference() << endl; // set to title style + t << rtf_Style_Reset << rtf_Style["SubTitle"].reference() << "\n"; // set to title style t << "\\vertalc\\qc\\par\\par\\par\\par\\par\\par\\par\n"; if (rtf_logoFilename) @@ -610,20 +608,20 @@ void RTFGenerator::endIndexSection(IndexSections is) t << rtf_company << "\\par\\par\n"; } - t << rtf_Style_Reset << rtf_Style["Title"].reference() << endl; // set to title style + t << rtf_Style_Reset << rtf_Style["Title"].reference() << "\n"; // set to title style if (rtf_title) // User has overridden document title in extensions file - t << "{\\field\\fldedit {\\*\\fldinst TITLE \\\\*MERGEFORMAT}{\\fldrslt " << rtf_title << "}}\\par" << endl; + t << "{\\field\\fldedit {\\*\\fldinst TITLE \\\\*MERGEFORMAT}{\\fldrslt " << rtf_title << "}}\\par\n"; else { DocText *root = validatingParseText(projectName); t << "{\\field\\fldedit {\\*\\fldinst TITLE \\\\*MERGEFORMAT}{\\fldrslt "; writeDoc(root,0,0,0); - t << "}}\\par" << endl; + t << "}}\\par\n"; } - t << rtf_Style_Reset << rtf_Style["SubTitle"].reference() << endl; // set to title style + t << rtf_Style_Reset << rtf_Style["SubTitle"].reference() << "\n"; // set to title style t << "\\par\n"; if (rtf_documentType) { @@ -635,38 +633,38 @@ void RTFGenerator::endIndexSection(IndexSections is) } t << "\\par\\par\\par\\par\\par\\par\\par\\par\\par\\par\\par\\par\n"; - t << rtf_Style_Reset << rtf_Style["SubTitle"].reference() << endl; // set to subtitle style + t << rtf_Style_Reset << rtf_Style["SubTitle"].reference() << "\n"; // set to subtitle style if (rtf_author) - t << "{\\field\\fldedit {\\*\\fldinst AUTHOR \\\\*MERGEFORMAT}{\\fldrslt "<< rtf_author << " }}\\par" << endl; + t << "{\\field\\fldedit {\\*\\fldinst AUTHOR \\\\*MERGEFORMAT}{\\fldrslt "<< rtf_author << " }}\\par\n"; else - t << "{\\field\\fldedit {\\*\\fldinst AUTHOR \\\\*MERGEFORMAT}{\\fldrslt AUTHOR}}\\par" << endl; + t << "{\\field\\fldedit {\\*\\fldinst AUTHOR \\\\*MERGEFORMAT}{\\fldrslt AUTHOR}}\\par\n"; t << theTranslator->trVersion() << " " << Config_getString(PROJECT_NUMBER) << "\\par"; t << "{\\field\\fldedit {\\*\\fldinst CREATEDATE \\\\*MERGEFORMAT}" - "{\\fldrslt "<< dateToString(FALSE) << " }}\\par"<<endl; + "{\\fldrslt "<< dateToString(FALSE) << " }}\\par\n"; t << "\\page\\page"; - DBG_RTF(t << "{\\comment End title page}" << endl) + DBG_RTF(t << "{\\comment End title page}\n") // table of contents section DBG_RTF(t << "{\\comment Table of contents}\n") t << "\\vertalt\n"; - t << rtf_Style_Reset << endl; + t << rtf_Style_Reset << "\n"; t << rtf_Style["Heading1"].reference(); - t << theTranslator->trRTFTableOfContents() << "\\par"<< endl; - t << rtf_Style_Reset << "\\par" << endl; + t << theTranslator->trRTFTableOfContents() << "\\par\n"; + t << rtf_Style_Reset << "\\par\n"; t << "{\\field\\fldedit {\\*\\fldinst TOC \\\\f \\\\*MERGEFORMAT}{\\fldrslt Table of contents}}\\par\n"; - t << rtf_Style_Reset << endl; + t << rtf_Style_Reset << "\n"; } break; case isMainPage: - t << "\\par " << rtf_Style_Reset << endl; + t << "\\par " << rtf_Style_Reset << "\n"; if (!mainPageHasTitle()) { - t << "{\\tc \\v " << theTranslator->trMainPage() << "}"<< endl; + t << "{\\tc \\v " << theTranslator->trMainPage() << "}\n"; } else { - t << "{\\tc \\v " << substitute(Doxygen::mainPage->title(),"%","") << "}"<< endl; + t << "{\\tc \\v " << substitute(Doxygen::mainPage->title(),"%","") << "}\n"; } t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \""; //if (Config_getBool(GENERATE_TREEVIEW)) t << "main"; else t << "index"; @@ -674,73 +672,73 @@ void RTFGenerator::endIndexSection(IndexSections is) t << ".rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; break; //case isPackageIndex: - // t << "\\par " << rtf_Style_Reset << endl; - // t << "{\\tc \\v " << theTranslator->trPackageList() << "}"<< endl; + // t << "\\par " << rtf_Style_Reset << "\n"; + // t << "{\\tc \\v " << theTranslator->trPackageList() << "}\n"; // t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \"packages.rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; // break; case isModuleIndex: - t << "\\par " << rtf_Style_Reset << endl; - t << "{\\tc \\v " << theTranslator->trModuleIndex() << "}"<< endl; + t << "\\par " << rtf_Style_Reset << "\n"; + t << "{\\tc \\v " << theTranslator->trModuleIndex() << "}\n"; t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \"modules.rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; break; case isDirIndex: - t << "\\par " << rtf_Style_Reset << endl; - t << "{\\tc \\v " << theTranslator->trDirIndex() << "}"<< endl; + t << "\\par " << rtf_Style_Reset << "\n"; + t << "{\\tc \\v " << theTranslator->trDirIndex() << "}\n"; t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \"dirs.rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; break; case isNamespaceIndex: - t << "\\par " << rtf_Style_Reset << endl; + t << "\\par " << rtf_Style_Reset << "\n"; if (fortranOpt) { - t << "{\\tc \\v " << theTranslator->trModulesIndex() << "}" << endl; + t << "{\\tc \\v " << theTranslator->trModulesIndex() << "}\n"; } else { - t << "{\\tc \\v " << theTranslator->trNamespaceIndex() << "}" << endl; + t << "{\\tc \\v " << theTranslator->trNamespaceIndex() << "}\n"; } t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \"namespaces.rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; break; case isClassHierarchyIndex: - t << "\\par " << rtf_Style_Reset << endl; - t << "{\\tc \\v " << theTranslator->trHierarchicalIndex() << "}"<< endl; + t << "\\par " << rtf_Style_Reset << "\n"; + t << "{\\tc \\v " << theTranslator->trHierarchicalIndex() << "}\n"; t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \"hierarchy.rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; break; case isCompoundIndex: - t << "\\par " << rtf_Style_Reset << endl; + t << "\\par " << rtf_Style_Reset << "\n"; if (fortranOpt) { - t << "{\\tc \\v " << theTranslator->trCompoundIndexFortran() << "}"<< endl; + t << "{\\tc \\v " << theTranslator->trCompoundIndexFortran() << "}\n"; } else if (vhdlOpt) { - t << "{\\tc \\v " << theTranslator->trDesignUnitIndex() << "}"<< endl; + t << "{\\tc \\v " << theTranslator->trDesignUnitIndex() << "}\n"; } else { - t << "{\\tc \\v " << theTranslator->trCompoundIndex() << "}"<< endl; + t << "{\\tc \\v " << theTranslator->trCompoundIndex() << "}\n"; } t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \"annotated.rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; break; case isFileIndex: - t << "\\par " << rtf_Style_Reset << endl; - t << "{\\tc \\v " << theTranslator->trFileIndex() << "}"<< endl; + t << "\\par " << rtf_Style_Reset << "\n"; + t << "{\\tc \\v " << theTranslator->trFileIndex() << "}\n"; t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \"files.rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; break; case isPageIndex: - t << "\\par " << rtf_Style_Reset << endl; - t << "{\\tc \\v " << theTranslator->trPageIndex() << "}"<< endl; + t << "\\par " << rtf_Style_Reset << "\n"; + t << "{\\tc \\v " << theTranslator->trPageIndex() << "}\n"; t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \"pages.rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; break; case isModuleDocumentation: { bool first=true; - t << "{\\tc \\v " << theTranslator->trModuleDocumentation() << "}"<< endl; + t << "{\\tc \\v " << theTranslator->trModuleDocumentation() << "}\n"; for (const auto &gd : *Doxygen::groupLinkedMap) { if (!gd->isReference()) { - t << "\\par " << rtf_Style_Reset << endl; + t << "\\par " << rtf_Style_Reset << "\n"; if (!first) { beginRTFSection(); @@ -756,12 +754,12 @@ void RTFGenerator::endIndexSection(IndexSections is) case isDirDocumentation: { bool first=true; - t << "{\\tc \\v " << theTranslator->trDirDocumentation() << "}"<< endl; + t << "{\\tc \\v " << theTranslator->trDirDocumentation() << "}\n"; for (const auto &dd : *Doxygen::dirLinkedMap) { if (dd->isLinkableInProject()) { - t << "\\par " << rtf_Style_Reset << endl; + t << "\\par " << rtf_Style_Reset << "\n"; if (!first) { beginRTFSection(); @@ -781,7 +779,7 @@ void RTFGenerator::endIndexSection(IndexSections is) { if (nd->isLinkableInProject() && !nd->isAlias()) { - t << "\\par " << rtf_Style_Reset << endl; + t << "\\par " << rtf_Style_Reset << "\n"; if (!first) { beginRTFSection(); @@ -799,11 +797,11 @@ void RTFGenerator::endIndexSection(IndexSections is) bool first=true; if (fortranOpt) { - t << "{\\tc \\v " << theTranslator->trTypeDocumentation() << "}"<< endl; + t << "{\\tc \\v " << theTranslator->trTypeDocumentation() << "}\n"; } else { - t << "{\\tc \\v " << theTranslator->trClassDocumentation() << "}"<< endl; + t << "{\\tc \\v " << theTranslator->trClassDocumentation() << "}\n"; } for (const auto &cd : *Doxygen::classLinkedMap) { @@ -813,7 +811,7 @@ void RTFGenerator::endIndexSection(IndexSections is) !cd->isAlias() ) { - t << "\\par " << rtf_Style_Reset << endl; + t << "\\par " << rtf_Style_Reset << "\n"; if (!first) { beginRTFSection(); @@ -830,14 +828,14 @@ void RTFGenerator::endIndexSection(IndexSections is) { bool isFirst=TRUE; - t << "{\\tc \\v " << theTranslator->trFileDocumentation() << "}"<< endl; + t << "{\\tc \\v " << theTranslator->trFileDocumentation() << "}\n"; for (const auto &fn : *Doxygen::inputNameLinkedMap) { for (const auto &fd : *fn) { if (fd->isLinkableInProject()) { - t << "\\par " << rtf_Style_Reset << endl; + t << "\\par " << rtf_Style_Reset << "\n"; if (!isFirst) { beginRTFSection(); @@ -848,7 +846,7 @@ void RTFGenerator::endIndexSection(IndexSections is) t << ".rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; if (sourceBrowser && m_prettyCode && fd->generateSourceFile()) { - t << "\\par " << rtf_Style_Reset << endl; + t << "\\par " << rtf_Style_Reset << "\n"; t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \"" << fd->getSourceFileBase() << ".rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; } } @@ -860,10 +858,10 @@ void RTFGenerator::endIndexSection(IndexSections is) { //t << "}\n"; bool isFirst=true; - t << "{\\tc \\v " << theTranslator->trExampleDocumentation() << "}"<< endl; + t << "{\\tc \\v " << theTranslator->trExampleDocumentation() << "}\n"; for (const auto &pd : *Doxygen::exampleLinkedMap) { - t << "\\par " << rtf_Style_Reset << endl; + t << "\\par " << rtf_Style_Reset << "\n"; if (!isFirst) { beginRTFSection(); @@ -878,14 +876,14 @@ void RTFGenerator::endIndexSection(IndexSections is) case isPageDocumentation: { //#error "fix me in the same way as the latex index..." - //t << "{\\tc \\v " << theTranslator->trPageDocumentation() << "}"<< endl; - //t << "}"<< endl; + //t << "{\\tc \\v " << theTranslator->trPageDocumentation() << "}\n"; + //t << "}\n"; //bool first=TRUE; //for (const auto *pd : Doxygen::pageLinkedMap) //{ // if (!pd->getGroupDef() && !pd->isReference()) // { - // if (first) t << "\\par " << rtf_Style_Reset << endl; + // if (first) t << "\\par " << rtf_Style_Reset << "\n"; // t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \""; // t << pd->getOutputFileBase(); // t << ".rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; @@ -897,15 +895,15 @@ void RTFGenerator::endIndexSection(IndexSections is) case isPageDocumentation2: { t << "}"; - t << "\\par " << rtf_Style_Reset << endl; + t << "\\par " << rtf_Style_Reset << "\n"; } break; case isEndIndex: beginRTFChapter(); t << rtf_Style["Heading1"].reference(); - t << theTranslator->trRTFGeneralIndex() << "\\par "<< endl; - t << rtf_Style_Reset << endl; - t << "{\\tc \\v " << theTranslator->trRTFGeneralIndex() << "}" << endl; + t << theTranslator->trRTFGeneralIndex() << "\\par \n"; + t << rtf_Style_Reset << "\n"; + t << "{\\tc \\v " << theTranslator->trRTFGeneralIndex() << "}\n"; t << "{\\field\\fldedit {\\*\\fldinst INDEX \\\\c2 \\\\*MERGEFORMAT}{\\fldrslt INDEX}}\n"; break; @@ -914,7 +912,7 @@ void RTFGenerator::endIndexSection(IndexSections is) void RTFGenerator::writePageLink(const char *name,bool first) { - if (first) t << "\\par " << rtf_Style_Reset << endl; + if (first) t << "\\par " << rtf_Style_Reset << "\n"; t << "{\\field\\fldedit{\\*\\fldinst INCLUDETEXT \""; t << name; t << ".rtf\" \\\\*MERGEFORMAT}{\\fldrslt includedstuff}}\n"; @@ -938,8 +936,8 @@ void RTFGenerator::writeStyleInfo(int) void RTFGenerator::lineBreak(const char *) { - DBG_RTF(t << "{\\comment (lineBreak)}" << endl) - t << "\\par" << endl; + DBG_RTF(t << "{\\comment (lineBreak)}" << "\n") + t << "\\par\n"; m_omitParagraph = TRUE; } @@ -950,17 +948,17 @@ void RTFGenerator::writeString(const char *text) void RTFGenerator::startIndexList() { - DBG_RTF(t << "{\\comment (startIndexList)}" << endl) - t << "{" << endl; - t << "\\par" << endl; + DBG_RTF(t << "{\\comment (startIndexList)}\n") + t << "{\n"; + t << "\\par\n"; incrementIndentLevel(); - t << rtf_Style_Reset << rtf_LCList_DepthStyle() << endl; + t << rtf_Style_Reset << rtf_LCList_DepthStyle() << "\n"; m_omitParagraph = TRUE; } void RTFGenerator::endIndexList() { - DBG_RTF(t << "{\\comment (endIndexList)}" << endl) + DBG_RTF(t << "{\\comment (endIndexList)}\n") if (!m_omitParagraph) { t << "\\par"; @@ -974,7 +972,7 @@ void RTFGenerator::endIndexList() void RTFGenerator::startItemList() { newParagraph(); - DBG_RTF(t << "{\\comment (startItemList level=" << m_listLevel << ") }" << endl) + DBG_RTF(t << "{\\comment (startItemList level=" << m_listLevel << ") }\n") t << "{"; incrementIndentLevel(); rtf_listItemInfo[m_listLevel].isEnum = FALSE; @@ -984,7 +982,7 @@ void RTFGenerator::startItemList() void RTFGenerator::endItemList() { newParagraph(); - DBG_RTF(t << "{\\comment (endItemList level=" << m_listLevel << ")}" << endl) + DBG_RTF(t << "{\\comment (endItemList level=" << m_listLevel << ")}\n") t << "}"; decrementIndentLevel(); m_omitParagraph = TRUE; @@ -993,8 +991,8 @@ void RTFGenerator::endItemList() ///*! start enumeration list */ //void RTFGenerator::startEnumList() // starts an enumeration list //{ -// DBG_RTF(t << "{\\comment (startEnumList)}" << endl) -// t << "{" << endl; +// DBG_RTF(t << "{\\comment (startEnumList)}\n") +// t << "{\n"; // incrementIndentLevel(); // rtf_listItemInfo[m_listLevel].isEnum = TRUE; // rtf_listItemInfo[m_listLevel].number = 1; @@ -1004,7 +1002,7 @@ void RTFGenerator::endItemList() //void RTFGenerator::endEnumList() //{ // newParagraph(); -// DBG_RTF(t << "{\\comment (endEnumList)}" << endl) +// DBG_RTF(t << "{\\comment (endEnumList)}\n") // t << "}"; // decrementIndentLevel(); // m_omitParagraph = TRUE; @@ -1013,50 +1011,50 @@ void RTFGenerator::endItemList() /*! write bullet or enum item */ void RTFGenerator::startItemListItem() { - DBG_RTF(t << "{\\comment (startItemListItem)}" << endl) + DBG_RTF(t << "{\\comment (startItemListItem)}\n") newParagraph(); t << rtf_Style_Reset; if (rtf_listItemInfo[m_listLevel].isEnum) { - t << rtf_EList_DepthStyle() << endl; + t << rtf_EList_DepthStyle() << "\n"; t << rtf_listItemInfo[m_listLevel].number << ".\\tab "; rtf_listItemInfo[m_listLevel].number++; } else { - t << rtf_BList_DepthStyle() << endl; + t << rtf_BList_DepthStyle() << "\n"; } m_omitParagraph = TRUE; } void RTFGenerator::endItemListItem() { - DBG_RTF(t << "{\\comment (endItemListItem)}" << endl) + DBG_RTF(t << "{\\comment (endItemListItem)}\n") } void RTFGenerator::startIndexItem(const char *,const char *) { - DBG_RTF(t << "{\\comment (startIndexItem)}" << endl) + DBG_RTF(t << "{\\comment (startIndexItem)}\n") if (!m_omitParagraph) { - t << "\\par" << endl; + t << "\\par\n"; m_omitParagraph = TRUE; } } void RTFGenerator::endIndexItem(const char *ref,const char *fn) { - DBG_RTF(t << "{\\comment (endIndexItem)}" << endl) + DBG_RTF(t << "{\\comment (endIndexItem)}\n") if (!ref && fn) { t << "\\tab "; writeRTFReference(fn); - t << endl; + t << "\n"; } else { - t << endl; + t << "\n"; } m_omitParagraph = TRUE; } @@ -1065,7 +1063,7 @@ void RTFGenerator::endIndexItem(const char *ref,const char *fn) //{ // t << "\\item\\contentsline{section}{"; // docify(text); -// t << "}{\\pageref{" << text << "}}" << endl; +// t << "}{\\pageref{" << text << "}}\n"; //} void RTFGenerator::startHtmlLink(const char *url) @@ -1088,7 +1086,7 @@ void RTFGenerator::endHtmlLink() { if (Config_getBool(RTF_HYPERLINKS)) { - t << "}}}" << endl; + t << "}}}\n"; } else { @@ -1106,7 +1104,7 @@ void RTFGenerator::endHtmlLink() void RTFGenerator::writeStartAnnoItem(const char *,const char *f, const char *path,const char *name) { - DBG_RTF(t << "{\\comment (writeStartAnnoItem)}" << endl) + DBG_RTF(t << "{\\comment (writeStartAnnoItem)}\n") t << "{\\b "; if (path) docify(path); if (f && Config_getBool(RTF_HYPERLINKS)) @@ -1118,7 +1116,7 @@ void RTFGenerator::writeStartAnnoItem(const char *,const char *f, docify(name); - t << "}}}" << endl; + t << "}}}\n"; } else { @@ -1129,52 +1127,52 @@ void RTFGenerator::writeStartAnnoItem(const char *,const char *f, void RTFGenerator::writeEndAnnoItem(const char *name) { - DBG_RTF(t << "{\\comment (writeEndAnnoItem)}" << endl) + DBG_RTF(t << "{\\comment (writeEndAnnoItem)}\n") if (name) { t << "\\tab "; writeRTFReference(name); - t << endl; + t << "\n"; } else { - t << endl; + t << "\n"; } newParagraph(); } void RTFGenerator::startIndexKey() { - DBG_RTF(t << "{\\comment (startIndexKey)}" << endl) + DBG_RTF(t << "{\\comment (startIndexKey)}\n") t << "{\\b "; } void RTFGenerator::endIndexKey() { - DBG_RTF(t << "{\\comment (endIndexKey)}" << endl) + DBG_RTF(t << "{\\comment (endIndexKey)}\n") } void RTFGenerator::startIndexValue(bool hasBrief) { - DBG_RTF(t << "{\\comment (startIndexValue)}" << endl) + DBG_RTF(t << "{\\comment (startIndexValue)}\n") t << " "; if (hasBrief) t << "("; } void RTFGenerator::endIndexValue(const char *name,bool hasBrief) { - DBG_RTF(t << "{\\comment (endIndexValue)}" << endl) + DBG_RTF(t << "{\\comment (endIndexValue)}\n") if (hasBrief) t << ")"; t << "} "; if (name) { t << "\\tab "; writeRTFReference(name); - t << endl; + t << "\n"; } else { - t << endl; + t << "\n"; } m_omitParagraph=FALSE; newParagraph(); @@ -1192,7 +1190,7 @@ void RTFGenerator::startSubsection() void RTFGenerator::endSubsection() { newParagraph(); - t << rtf_Style_Reset << endl; + t << rtf_Style_Reset << "\n"; } void RTFGenerator::startSubsubsection() @@ -1200,14 +1198,14 @@ void RTFGenerator::startSubsubsection() //beginRTFSubSubSection(); t << "\n"; DBG_RTF(t << "{\\comment Begin SubSubSection}\n") - t << "{" << endl; + t << "{\n"; t << rtf_Style_Reset << rtf_Style["Heading4"].reference() << "\n"; } void RTFGenerator::endSubsubsection() { newParagraph(); - t << "}" << endl; + t << "}\n"; } @@ -1231,15 +1229,15 @@ void RTFGenerator::endSubsubsection() // DBG_RTF(t << "{\\comment endTable}\n";) // if (!hasCaption) // t << "\n\\pard \\widctlpar\\intbl\\adjustright\n{\\row }\n"; -// t << "\\pard\n" << endl; +// t << "\\pard\n\n"; //} // //void RTFGenerator::startCaption() //{ // DBG_RTF(t << "{\\comment startCaption}\n";) // endTableRow(); -// t << "\\trowd \\trgaph108\\trleft-108\\trbrdrt\\brdrs\\brdrw10 \\trbrdrl\\brdrs\\brdrw10 \\trbrdrb\\brdrs\\brdrw10 \\trbrdrr\\brdrs\\brdrw10 \\trbrdrh\\brdrs\\brdrw10 \\trbrdrv\\brdrs\\brdrw10" << endl; -// t << "\\clvertalt\\clbrdrt\\brdrs\\brdrw10 \\clbrdrl\\brdrs\\brdrw10 \\clbrdrb\\brdrs\\brdrw10 \\clbrdrr \\brdrs\\brdrw10 \\cltxlrtb \\cellx"<<rtf_pageWidth<<"\\pard \\qc\\nowidctlpar\\widctlpar\\intbl\\adjustright " << endl; +// t << "\\trowd \\trgaph108\\trleft-108\\trbrdrt\\brdrs\\brdrw10 \\trbrdrl\\brdrs\\brdrw10 \\trbrdrb\\brdrs\\brdrw10 \\trbrdrr\\brdrs\\brdrw10 \\trbrdrh\\brdrs\\brdrw10 \\trbrdrv\\brdrs\\brdrw10\n"; +// t << "\\clvertalt\\clbrdrt\\brdrs\\brdrw10 \\clbrdrl\\brdrs\\brdrw10 \\clbrdrb\\brdrs\\brdrw10 \\clbrdrr \\brdrs\\brdrw10 \\cltxlrtb \\cellx"<<rtf_pageWidth<<"\\pard \\qc\\nowidctlpar\\widctlpar\\intbl\\adjustright \n"; // nextTableColumn(); //} // @@ -1258,12 +1256,12 @@ void RTFGenerator::endSubsubsection() // t << "\\trowd \\trgaph108\\trleft-108\\trbrdrt\\brdrs\\brdrw10 " // "\\trbrdrl\\brdrs\\brdrw10 \\trbrdrb\\brdrs\\brdrw10 " // "\\trbrdrr\\brdrs\\brdrw10 \\trbrdrh\\brdrs\\brdrw10 " -// "\\trbrdrv\\brdrs\\brdrw10 "<<endl; +// "\\trbrdrv\\brdrs\\brdrw10 \n"; // for (int i=0;i<m_numCols;i++) // { // t << "\\clvertalt\\clbrdrt\\brdrs\\brdrw10 \\clbrdrl\\brdrs\\brdrw10 " // "\\clbrdrb\\brdrs\\brdrw10 \\clbrdrr \\brdrs\\brdrw10 \\cltxlrtb " -// "\\cellx" << (i*columnWidth) << endl; +// "\\cellx" << (i*columnWidth) << "\n"; // } // t << "\\pard \\widctlpar\\intbl\\adjustright\n{"; //} @@ -1312,7 +1310,7 @@ void RTFGenerator::endTextLink() { if (Config_getBool(RTF_HYPERLINKS)) { - t << "}}}" << endl; + t << "}}}\n"; } } @@ -1339,7 +1337,7 @@ void RTFGenerator::writeObjectLink(const char *ref, const char *f, docify(text); - t << "}}}" << endl; + t << "}}}\n"; } else { @@ -1396,7 +1394,7 @@ void RTFGenerator::writeCodeLink(const char *ref,const char *f, codify(name); - t << "}}}" << endl; + t << "}}}\n"; } else { @@ -1406,22 +1404,22 @@ void RTFGenerator::writeCodeLink(const char *ref,const char *f, void RTFGenerator::startTitleHead(const char *) { - DBG_RTF(t <<"{\\comment startTitleHead}" << endl) + DBG_RTF(t <<"{\\comment startTitleHead}\n") // beginRTFSection(); - t << rtf_Style_Reset << rtf_Style["Heading2"].reference() << endl; + t << rtf_Style_Reset << rtf_Style["Heading2"].reference() << "\n"; } void RTFGenerator::endTitleHead(const char *fileName,const char *name) { - DBG_RTF(t <<"{\\comment endTitleHead}" << endl) - t << "\\par " << rtf_Style_Reset << endl; + DBG_RTF(t <<"{\\comment endTitleHead}\n") + t << "\\par " << rtf_Style_Reset << "\n"; if (name) { // make table of contents entry t << "{\\tc\\tcl2 \\v "; docify(name); - t << "}" << endl; + t << "}\n"; // make an index entry addIndexItem(name,0); @@ -1440,7 +1438,7 @@ void RTFGenerator::endTitleHead(const char *fileName,const char *name) void RTFGenerator::startTitle() { - DBG_RTF(t <<"{\\comment startTitle}" << endl) + DBG_RTF(t <<"{\\comment startTitle}\n") if (Config_getBool(COMPACT_RTF)) beginRTFSection(); else @@ -1449,7 +1447,7 @@ void RTFGenerator::startTitle() void RTFGenerator::startGroupHeader(int extraIndent) { - DBG_RTF(t <<"{\\comment startGroupHeader}" << endl) + DBG_RTF(t <<"{\\comment startGroupHeader}\n") //newParagraph(); t << rtf_Style_Reset; if (extraIndent==2) @@ -1464,14 +1462,14 @@ void RTFGenerator::startGroupHeader(int extraIndent) { t << rtf_Style["Heading3"].reference(); } - t << endl; + t << "\n"; } void RTFGenerator::endGroupHeader(int) { - DBG_RTF(t <<"{\\comment endGroupHeader}" << endl) - t << "\\par" << endl; - t << rtf_Style_Reset << endl; + DBG_RTF(t <<"{\\comment endGroupHeader}\n") + t << "\\par\n"; + t << rtf_Style_Reset << "\n"; } void RTFGenerator::startMemberDoc(const char *clname, @@ -1482,7 +1480,7 @@ void RTFGenerator::startMemberDoc(const char *clname, int, bool showInline) { - DBG_RTF(t << "{\\comment startMemberDoc}" << endl) + DBG_RTF(t << "{\\comment startMemberDoc}\n") if (memname && memname[0]!='@') { addIndexItem(memname,clname); @@ -1490,20 +1488,20 @@ void RTFGenerator::startMemberDoc(const char *clname, } t << rtf_Style_Reset << rtf_Style[showInline ? "Heading5" : "Heading4"].reference(); //styleStack.push(rtf_Style_Heading4); - t << "{" << endl; + t << "{\n"; //printf("RTFGenerator::startMemberDoc() '%s'\n",rtf_Style["Heading4"].reference()); startBold(); - t << endl; + t << "\n"; } void RTFGenerator::endMemberDoc(bool) { - DBG_RTF(t << "{\\comment endMemberDoc}" << endl) + DBG_RTF(t << "{\\comment endMemberDoc}\n") //const char *style = styleStack.pop(); //printf("RTFGenerator::endMemberDoc() '%s'\n",style); //ASSERT(style==rtf_Style["Heading4"].reference()); endBold(); - t << "}" << endl; + t << "}\n"; newParagraph(); } @@ -1512,7 +1510,7 @@ void RTFGenerator::startDoxyAnchor(const char *,const char *, const char * ) { - DBG_RTF(t << "{\\comment startDoxyAnchor}" << endl) + DBG_RTF(t << "{\\comment startDoxyAnchor}\n") } void RTFGenerator::endDoxyAnchor(const char *fName,const char *anchor) @@ -1528,13 +1526,13 @@ void RTFGenerator::endDoxyAnchor(const char *fName,const char *anchor) ref+=anchor; } - DBG_RTF(t << "{\\comment endDoxyAnchor}" << endl) + DBG_RTF(t << "{\\comment endDoxyAnchor}\n") t << "{\\bkmkstart "; t << rtfFormatBmkStr(ref); - t << "}" << endl; + t << "}\n"; t << "{\\bkmkend "; t << rtfFormatBmkStr(ref); - t << "}" << endl; + t << "}\n"; } @@ -1554,35 +1552,35 @@ void RTFGenerator::addIndexItem(const char *s1,const char *s2) t << "\\:"; docify(s2); } - t << "}" << endl; + t << "}\n"; } } void RTFGenerator::startIndent() { incrementIndentLevel(); - DBG_RTF(t << "{\\comment (startIndent) }" << endl) - t << "{" << endl; - t << rtf_Style_Reset << rtf_CList_DepthStyle() << endl; + DBG_RTF(t << "{\\comment (startIndent) }\n") + t << "{\n"; + t << rtf_Style_Reset << rtf_CList_DepthStyle() << "\n"; } void RTFGenerator::endIndent() { - t << "}" << endl; + t << "}\n"; decrementIndentLevel(); } void RTFGenerator::startDescription() { - DBG_RTF(t << "{\\comment (startDescription)}" << endl) - t << "{" << endl; + DBG_RTF(t << "{\\comment (startDescription)}" << "\n") + t << "{\n"; t << rtf_Style_Reset << rtf_DList_DepthStyle(); } void RTFGenerator::endDescription() { - DBG_RTF(t << "{\\comment (endDescription)}" << endl) + DBG_RTF(t << "{\\comment (endDescription)}" << "\n") newParagraph(); t << "}"; } @@ -1590,21 +1588,21 @@ void RTFGenerator::endDescription() void RTFGenerator::startDescItem() { newParagraph(); - DBG_RTF(t << "{\\comment (startDescItem)}" << endl) + DBG_RTF(t << "{\\comment (startDescItem)}\n") t << "{\\b "; } void RTFGenerator::endDescItem() { - DBG_RTF(t << "{\\comment (endDescItem)}" << endl) - t << "}" << endl; + DBG_RTF(t << "{\\comment (endDescItem)}\n") + t << "}\n"; newParagraph(); } void RTFGenerator::startMemberDescription(const char *,const char *,bool) { - DBG_RTF(t << "{\\comment (startMemberDescription)}" << endl) - t << "{" << endl; + DBG_RTF(t << "{\\comment (startMemberDescription)}\n") + t << "{\n"; incrementIndentLevel(); t << rtf_Style_Reset << rtf_CList_DepthStyle(); startEmphasis(); @@ -1612,18 +1610,18 @@ void RTFGenerator::startMemberDescription(const char *,const char *,bool) void RTFGenerator::endMemberDescription() { - DBG_RTF(t << "{\\comment (endMemberDescription)}" << endl) + DBG_RTF(t << "{\\comment (endMemberDescription)}\n") endEmphasis(); //newParagraph(); decrementIndentLevel(); t << "\\par"; - t << "}" << endl; + t << "}\n"; m_omitParagraph = TRUE; } void RTFGenerator::startDescList(SectionTypes) { - DBG_RTF(t << "{\\comment (startDescList)}" << endl) + DBG_RTF(t << "{\\comment (startDescList)}\n") t << "{"; // ends at endDescList t << "{"; // ends at endDescTitle startBold(); @@ -1632,7 +1630,7 @@ void RTFGenerator::startDescList(SectionTypes) //void RTFGenerator::endDescTitle() //{ -// DBG_RTF(t << "{\\comment (endDescTitle) }" << endl) +// DBG_RTF(t << "{\\comment (endDescTitle) }\n") // endBold(); // t << "}"; // newParagraph(); @@ -1642,17 +1640,17 @@ void RTFGenerator::startDescList(SectionTypes) void RTFGenerator::startDescForItem() { - DBG_RTF(t << "{\\comment (startDescForItem) }" << endl) + DBG_RTF(t << "{\\comment (startDescForItem) }\n") } void RTFGenerator::endDescForItem() { - DBG_RTF(t << "{\\comment (endDescForItem) }" << endl) + DBG_RTF(t << "{\\comment (endDescForItem) }\n") } //void RTFGenerator::endDescList() //{ -// DBG_RTF(t << "{\\comment (endDescList)}" << endl) +// DBG_RTF(t << "{\\comment (endDescList)}\n") // newParagraph(); // decrementIndentLevel(); // m_omitParagraph = TRUE; @@ -1662,7 +1660,7 @@ void RTFGenerator::endDescForItem() void RTFGenerator::startSection(const char *,const char *title,SectionType type) { - DBG_RTF(t << "{\\comment (startSection)}" << endl) + DBG_RTF(t << "{\\comment (startSection)}\n") t << "{"; t<< rtf_Style_Reset; int num=4; @@ -1682,12 +1680,12 @@ void RTFGenerator::startSection(const char *,const char *title,SectionType type) // make table of contents entry t << "{\\tc\\tcl" << num << " \\v "; docify(title); - t << "}" << endl; + t << "}\n"; } void RTFGenerator::endSection(const char *lab,SectionType) { - DBG_RTF(t << "{\\comment (endSection)}" << endl) + DBG_RTF(t << "{\\comment (endSection)}\n") // make bookmark m_omitParagraph=FALSE; newParagraph(); @@ -1710,7 +1708,7 @@ void RTFGenerator::endSection(const char *lab,SectionType) // t << " ("; // docify(theTranslator->trPageAbbreviation()); // writeRTFReference(lab); -// t << ")" << endl; +// t << ")\n"; // } //} // @@ -1720,7 +1718,7 @@ void RTFGenerator::endSection(const char *lab,SectionType) // docify(title); // t << "\\tab"; // writeRTFReference(lab); -// t << endl; +// t << "\n"; //} // //void RTFGenerator::writeSectionRefAnchor(const char *name,const char *lab, @@ -1827,7 +1825,7 @@ void RTFGenerator::writeChar(char c) void RTFGenerator::startClassDiagram() { - DBG_RTF(t <<"{\\comment startClassDiagram }" << endl) + DBG_RTF(t <<"{\\comment startClassDiagram }\n") } void RTFGenerator::endClassDiagram(const ClassDiagram &d, @@ -1839,12 +1837,12 @@ void RTFGenerator::endClassDiagram(const ClassDiagram &d, d.writeImage(t,dir(),m_relPath,fileName,FALSE); // display the file - t << "{" << endl; - t << rtf_Style_Reset << endl; + t << "{\n"; + t << rtf_Style_Reset << "\n"; t << "\\par\\pard \\qc {\\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \""; t << fileName << ".png\""; - t << " \\\\d \\\\*MERGEFORMAT}{\\fldrslt IMAGE}}\\par" << endl; - t << "}" << endl; + t << " \\\\d \\\\*MERGEFORMAT}{\\fldrslt IMAGE}}\\par\n"; + t << "}\n"; } //void RTFGenerator::writeFormula(const char *,const char *text) @@ -1854,13 +1852,13 @@ void RTFGenerator::endClassDiagram(const ClassDiagram &d, void RTFGenerator::startMemberItem(const char *,int,const char *) { - DBG_RTF(t <<"{\\comment startMemberItem }" << endl) - t << rtf_Style_Reset << rtf_BList_DepthStyle() << endl; // set style to appropriate depth + DBG_RTF(t <<"{\\comment startMemberItem }\n") + t << rtf_Style_Reset << rtf_BList_DepthStyle() << "\n"; // set style to appropriate depth } void RTFGenerator::endMemberItem() { - DBG_RTF(t <<"{\\comment endMemberItem }" << endl) + DBG_RTF(t <<"{\\comment endMemberItem }\n") newParagraph(); } @@ -1880,9 +1878,9 @@ void RTFGenerator::writeAnchor(const char *fileName,const char *name) anchor+=name; } - DBG_RTF(t <<"{\\comment writeAnchor (" << anchor << ")}" << endl) - t << "{\\bkmkstart " << rtfFormatBmkStr(anchor) << "}" << endl; - t << "{\\bkmkend " << rtfFormatBmkStr(anchor) << "}" << endl; + DBG_RTF(t <<"{\\comment writeAnchor (" << anchor << ")}\n") + t << "{\\bkmkstart " << rtfFormatBmkStr(anchor) << "}\n"; + t << "{\\bkmkend " << rtfFormatBmkStr(anchor) << "}\n"; } void RTFGenerator::writeRTFReference(const char *label) @@ -1894,8 +1892,8 @@ void RTFGenerator::writeRTFReference(const char *label) void RTFGenerator::startCodeFragment(const char *) { - DBG_RTF(t << "{\\comment (startCodeFragment) }" << endl) - t << "{" << endl; + DBG_RTF(t << "{\\comment (startCodeFragment) }\n") + t << "{\n"; t << rtf_Style_Reset << rtf_Code_DepthStyle(); } @@ -1903,8 +1901,8 @@ void RTFGenerator::endCodeFragment(const char *) { endCodeLine(); - DBG_RTF(t << "{\\comment (endCodeFragment) }" << endl) - t << "}" << endl; + DBG_RTF(t << "{\\comment (endCodeFragment) }\n") + t << "}\n"; m_omitParagraph = TRUE; } @@ -1916,34 +1914,34 @@ void RTFGenerator::writeNonBreakableSpace(int) void RTFGenerator::startMemberList() { - t << endl; - DBG_RTF(t << "{\\comment (startMemberList) }" << endl) - t << "{" << endl; + t << "\n"; + DBG_RTF(t << "{\\comment (startMemberList) }\n") + t << "{\n"; #ifdef DELETEDCODE if (!insideTabbing) - t << "\\begin{CompactItemize}" << endl; + t << "\\begin{CompactItemize}\n"; #endif } void RTFGenerator::endMemberList() { - DBG_RTF(t << "{\\comment (endMemberList) }" << endl) - t << "}" << endl; + DBG_RTF(t << "{\\comment (endMemberList) }\n") + t << "}\n"; #ifdef DELETEDCODE if (!insideTabbing) - t << "\\end{CompactItemize}" << endl; + t << "\\end{CompactItemize}\n"; #endif } //void RTFGenerator::startImage(const char *name,const char *,bool) //{ // newParagraph(); -// t << "{" << endl; -// t << rtf_Style_Reset << endl; +// t << "{\n"; +// t << rtf_Style_Reset << "\n"; // t << "\\par\\pard \\qc {\\field\\flddirty {\\*\\fldinst INCLUDEPICTURE "; // t << name; -// t << " \\\\d \\\\*MERGEFORMAT}{\\fldrslt IMAGE}}\\par" << endl; -// t << "}" << endl; +// t << " \\\\d \\\\*MERGEFORMAT}{\\fldrslt IMAGE}}\\par\n"; +// t << "}\n"; //} // //void RTFGenerator::endImage(bool) @@ -1962,12 +1960,12 @@ void RTFGenerator::endMemberList() // QCString outDir = Config_getString(RTF_OUTPUT); // writeDotGraphFromFile(name,outDir,baseName,BITMAP); // newParagraph(); -// t << "{" << endl; -// t << rtf_Style_Reset << endl; +// t << "{\n"; +// t << rtf_Style_Reset << "\n"; // t << "\\par\\pard \\qc {\\field\\flddirty {\\*\\fldinst INCLUDEPICTURE "; // t << outDir << "\\" << baseName; -// t << " \\\\d \\\\*MERGEFORMAT}{\\fldrslt IMAGE}}\\par" << endl; -// t << "}" << endl; +// t << " \\\\d \\\\*MERGEFORMAT}{\\fldrslt IMAGE}}\\par\n"; +// t << "}\n"; //} // //void RTFGenerator::endDotFile(bool) @@ -1977,11 +1975,11 @@ void RTFGenerator::endMemberList() // void RTFGenerator::startDescTable(const char *title) { - DBG_RTF(t << "{\\comment (startDescTable) }" << endl) - t << "{\\par" << endl; - t << "{" << rtf_Style["Heading5"].reference() << endl; + DBG_RTF(t << "{\\comment (startDescTable) }\n") + t << "{\\par\n"; + t << "{" << rtf_Style["Heading5"].reference() << "\n"; docify(title); - t << ":\\par}" << endl; + t << ":\\par}\n"; t << rtf_Style_Reset << rtf_DList_DepthStyle(); t << "\\trowd \\trgaph108\\trleft426\\tblind426" "\\trbrdrt\\brdrs\\brdrw10\\brdrcf15 " @@ -1989,7 +1987,7 @@ void RTFGenerator::startDescTable(const char *title) "\\trbrdrb\\brdrs\\brdrw10\\brdrcf15 " "\\trbrdrr\\brdrs\\brdrw10\\brdrcf15 " "\\trbrdrh\\brdrs\\brdrw10\\brdrcf15 " - "\\trbrdrv\\brdrs\\brdrw10\\brdrcf15 "<< endl; + "\\trbrdrv\\brdrs\\brdrw10\\brdrcf15 \n"; int i,columnPos[2] = { 25, 100 }; for (i=0;i<2;i++) { @@ -1998,15 +1996,15 @@ void RTFGenerator::startDescTable(const char *title) "\\clbrdrb\\brdrs\\brdrw10\\brdrcf15 " "\\clbrdrr \\brdrs\\brdrw10\\brdrcf15 " "\\cltxlrtb " - "\\cellx" << (rtf_pageWidth*columnPos[i]/100) << endl; + "\\cellx" << (rtf_pageWidth*columnPos[i]/100) << "\n"; } - t << "\\pard \\widctlpar\\intbl\\adjustright" << endl; + t << "\\pard \\widctlpar\\intbl\\adjustright\n"; } void RTFGenerator::endDescTable() { - DBG_RTF(t << "{\\comment (endDescTable)}" << endl) - t << "}" << endl; + DBG_RTF(t << "{\\comment (endDescTable)}\n") + t << "}\n"; } void RTFGenerator::startDescTableRow() @@ -2019,26 +2017,26 @@ void RTFGenerator::endDescTableRow() void RTFGenerator::startDescTableTitle() { - DBG_RTF(t << "{\\comment (startDescTableTitle) }" << endl) + DBG_RTF(t << "{\\comment (startDescTableTitle) }\n") t << "{\\qr "; } void RTFGenerator::endDescTableTitle() { - DBG_RTF(t << "{\\comment (endDescTableTitle) }" << endl) + DBG_RTF(t << "{\\comment (endDescTableTitle) }\n") t << "\\cell }"; } void RTFGenerator::startDescTableData() { - DBG_RTF(t << "{\\comment (startDescTableData) }" << endl) + DBG_RTF(t << "{\\comment (startDescTableData) }\n") t << "{"; } void RTFGenerator::endDescTableData() { - DBG_RTF(t << "{\\comment (endDescTableData) }" << endl) - t << "\\cell }{\\row }" << endl; + DBG_RTF(t << "{\\comment (endDescTableData) }\n") + t << "\\cell }{\\row }\n"; } // a style for list formatted as a "bulleted list" @@ -2105,8 +2103,8 @@ const char * RTFGenerator::rtf_Code_DepthStyle() void RTFGenerator::startTextBlock(bool dense) { - DBG_RTF(t << "{\\comment startTextBlock}" << endl) - t << "{" << endl; + DBG_RTF(t << "{\\comment startTextBlock}\n") + t << "{\n"; t << rtf_Style_Reset; if (dense) // no spacing between "paragraphs" { @@ -2121,8 +2119,8 @@ void RTFGenerator::startTextBlock(bool dense) void RTFGenerator::endTextBlock(bool /*paraBreak*/) { newParagraph(); - DBG_RTF(t << "{\\comment endTextBlock}" << endl) - t << "}" << endl; + DBG_RTF(t << "{\\comment endTextBlock}\n") + t << "}\n"; //m_omitParagraph = TRUE; } @@ -2130,39 +2128,39 @@ void RTFGenerator::newParagraph() { if (!m_omitParagraph) { - DBG_RTF(t << "{\\comment (newParagraph)}" << endl) - t << "\\par" << endl; + DBG_RTF(t << "{\\comment (newParagraph)}\n") + t << "\\par\n"; } m_omitParagraph = FALSE; } void RTFGenerator::startParagraph(const char *txt) { - DBG_RTF(t << "{\\comment startParagraph}" << endl) + DBG_RTF(t << "{\\comment startParagraph}\n") newParagraph(); - t << "{" << endl; - if (QCString(txt) == "reference") t << "\\ql" << endl; + t << "{\n"; + if (QCString(txt) == "reference") t << "\\ql\n"; } void RTFGenerator::endParagraph() { - DBG_RTF(t << "{\\comment endParagraph}" << endl) - t << "}\\par" << endl; + DBG_RTF(t << "{\\comment endParagraph}\n") + t << "}\\par\n"; m_omitParagraph = TRUE; } void RTFGenerator::startMemberSubtitle() { - DBG_RTF(t << "{\\comment startMemberSubtitle}" << endl) - t << "{" << endl; - t << rtf_Style_Reset << rtf_CList_DepthStyle() << endl; + DBG_RTF(t << "{\\comment startMemberSubtitle}\n") + t << "{\n"; + t << rtf_Style_Reset << rtf_CList_DepthStyle() << "\n"; } void RTFGenerator::endMemberSubtitle() { - DBG_RTF(t << "{\\comment endMemberSubtitle}" << endl) + DBG_RTF(t << "{\\comment endMemberSubtitle}\n") newParagraph(); - t << "}" << endl; + t << "}\n"; } //void RTFGenerator::writeUmlaut(char c) @@ -2308,7 +2306,7 @@ bool isLeadBytes(int c) // note: function is not reentrant! -static void encodeForOutput(FTextStream &t,const char *s) +static void encodeForOutput(std::ostream &t,const char *s) { if (s==0) return; QCString encoding; @@ -2373,13 +2371,13 @@ static void encodeForOutput(FTextStream &t,const char *s) * VERY brittle routine inline RTF's included by other RTF's. * it is recursive and ugly. */ -static bool preProcessFile(Dir &d,QCString &infName, FTextStream &t, bool bIncludeHeader=TRUE) +static bool preProcessFile(Dir &d,const QCString &infName, std::ostream &t, bool bIncludeHeader=TRUE) { - QFile f(infName); - if (!f.open(IO_ReadOnly)) + std::ifstream f(infName.str(),std::ifstream::in); + if (!f.is_open()) { err("problems opening rtf file %s for reading\n",infName.data()); - return FALSE; + return false; } const int maxLineLength = 10240; @@ -2389,57 +2387,49 @@ static bool preProcessFile(Dir &d,QCString &infName, FTextStream &t, bool bInclu // this is EXTREEEEEEEMLY brittle. It works on OUR rtf // files because the first line before the body // ALWAYS contains "{\comment begin body}" - int len; - for(;;) + std::string line; + while (getline(f,line)) { - lineBuf.resize(maxLineLength); - if ((len=f.readLine(lineBuf.rawData(),maxLineLength))==-1) - { - err("read error in %s before end of RTF header!\n",infName.data()); - return FALSE; - } - lineBuf.resize(len+1); - if (lineBuf.find("\\comment begin body")!=-1) break; - if (bIncludeHeader) encodeForOutput(t,lineBuf.data()); + line+='\n'; + if (line.find("\\comment begin body")!=std::string::npos) break; + if (bIncludeHeader) encodeForOutput(t,line.c_str()); } - - lineBuf.resize(maxLineLength); - while ((len=f.readLine(lineBuf.rawData(),maxLineLength))!=-1) + std::string prevLine; + bool first=true; + while (getline(f,line)) { - lineBuf.resize(len+1); - int pos; - if ((pos=lineBuf.find("INCLUDETEXT"))!=-1) + line+='\n'; + size_t pos; + if ((pos=prevLine.find("INCLUDETEXT"))!=std::string::npos) { - int startNamePos = lineBuf.find('"',pos)+1; - int endNamePos = lineBuf.find('"',startNamePos); - QCString fileName = lineBuf.mid(startNamePos,endNamePos-startNamePos); - DBG_RTF(t << "{\\comment begin include " << fileName << "}" << endl) - if (!preProcessFile(d,fileName,t,FALSE)) return FALSE; - DBG_RTF(t << "{\\comment end include " << fileName << "}" << endl) + size_t startNamePos = prevLine.find('"',pos)+1; + size_t endNamePos = prevLine.find('"',startNamePos); + std::string fileName = prevLine.substr(startNamePos,endNamePos-startNamePos); + DBG_RTF(t << "{\\comment begin include " << fileName << "}\n") + if (!preProcessFile(d,fileName.c_str(),t,FALSE)) return FALSE; + DBG_RTF(t << "{\\comment end include " << fileName << "}\n") } - else // no INCLUDETEXT on this line + else if (!first) // no INCLUDETEXT on this line { - // elaborate hoopla to skip the final "}" if we didn't include the - // headers - if (!f.atEnd() || bIncludeHeader) - { - encodeForOutput(t,lineBuf); - } - else // last line of included file - { - // null terminate at the last '}' - //char *str = strrchr(buffer,'}'); - pos = lineBuf.findRev('}'); - - if (pos != -1) - lineBuf.at(pos) = '\0'; - else - err("Strange, the last char was not a '}'\n"); - encodeForOutput(t,lineBuf); - } + encodeForOutput(t,prevLine.c_str()); } - lineBuf.resize(maxLineLength); + prevLine = line; + first=false; + } + if (!bIncludeHeader) // skip final '}' in case we don't include headers + { + size_t pos = line.rfind('}'); + if (pos==std::string::npos) + { + err("Strange, the last char was not a '}'\n"); + pos = line.length(); + } + encodeForOutput(t,line.substr(0,pos).c_str()); + } + else + { + encodeForOutput(t,line.c_str()); } f.close(); // remove temporary file @@ -2449,7 +2439,7 @@ static bool preProcessFile(Dir &d,QCString &infName, FTextStream &t, bool bInclu void RTFGenerator::startDotGraph() { - DBG_RTF(t << "{\\comment (startDotGraph)}" << endl) + DBG_RTF(t << "{\\comment (startDotGraph)}\n") } void RTFGenerator::endDotGraph(DotClassGraph &g) @@ -2460,20 +2450,20 @@ void RTFGenerator::endDotGraph(DotClassGraph &g) g.writeGraph(t,GOF_BITMAP,EOF_Rtf,dir(),fileName(),m_relPath,TRUE,FALSE); // display the file - t << "{" << endl; - t << rtf_Style_Reset << endl; + t << "{\n"; + t << rtf_Style_Reset << "\n"; t << "\\par\\pard \\qc {\\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \""; QCString imgExt = getDotImageExtension(); t << fn << "." << imgExt; - t << "\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt IMAGE}}\\par" << endl; - t << "}" << endl; + t << "\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt IMAGE}}\\par\n"; + t << "}\n"; newParagraph(); - DBG_RTF(t << "{\\comment (endDotGraph)}" << endl) + DBG_RTF(t << "{\\comment (endDotGraph)}\n") } void RTFGenerator::startInclDepGraph() { - DBG_RTF(t << "{\\comment (startInclDepGraph)}" << endl) + DBG_RTF(t << "{\\comment (startInclDepGraph)}\n") } void RTFGenerator::endInclDepGraph(DotInclDepGraph &g) @@ -2483,14 +2473,14 @@ void RTFGenerator::endInclDepGraph(DotInclDepGraph &g) QCString fn = g.writeGraph(t,GOF_BITMAP,EOF_Rtf,dir(),fileName(),m_relPath,FALSE); // display the file - t << "{" << endl; - t << rtf_Style_Reset << endl; + t << "{\n"; + t << rtf_Style_Reset << "\n"; t << "\\par\\pard \\qc {\\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \""; QCString imgExt = getDotImageExtension(); t << fn << "." << imgExt; - t << "\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt IMAGE}}\\par" << endl; - t << "}" << endl; - DBG_RTF(t << "{\\comment (endInclDepGraph)}" << endl) + t << "\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt IMAGE}}\\par\n"; + t << "}\n"; + DBG_RTF(t << "{\\comment (endInclDepGraph)}\n") } void RTFGenerator::startGroupCollaboration() @@ -2503,7 +2493,7 @@ void RTFGenerator::endGroupCollaboration(DotGroupCollaboration &) void RTFGenerator::startCallGraph() { - DBG_RTF(t << "{\\comment (startCallGraph)}" << endl) + DBG_RTF(t << "{\\comment (startCallGraph)}\n") } void RTFGenerator::endCallGraph(DotCallGraph &g) @@ -2513,19 +2503,19 @@ void RTFGenerator::endCallGraph(DotCallGraph &g) QCString fn = g.writeGraph(t,GOF_BITMAP,EOF_Rtf,dir(),fileName(),m_relPath,FALSE); // display the file - t << "{" << endl; - t << rtf_Style_Reset << endl; + t << "{\n"; + t << rtf_Style_Reset << "\n"; t << "\\par\\pard \\qc {\\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \""; QCString imgExt = getDotImageExtension(); t << fn << "." << imgExt; - t << "\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt IMAGE}}\\par" << endl; - t << "}" << endl; - DBG_RTF(t << "{\\comment (endCallGraph)}" << endl) + t << "\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt IMAGE}}\\par\n"; + t << "}\n"; + DBG_RTF(t << "{\\comment (endCallGraph)}\n") } void RTFGenerator::startDirDepGraph() { - DBG_RTF(t << "{\\comment (startDirDepGraph)}" << endl) + DBG_RTF(t << "{\\comment (startDirDepGraph)}\n") } void RTFGenerator::endDirDepGraph(DotDirDeps &g) @@ -2535,14 +2525,14 @@ void RTFGenerator::endDirDepGraph(DotDirDeps &g) QCString fn = g.writeGraph(t,GOF_BITMAP,EOF_Rtf,dir(),fileName(),m_relPath,FALSE); // display the file - t << "{" << endl; - t << rtf_Style_Reset << endl; + t << "{\n"; + t << rtf_Style_Reset << "\n"; t << "\\par\\pard \\qc {\\field\\flddirty {\\*\\fldinst INCLUDEPICTURE \""; QCString imgExt = getDotImageExtension(); t << fn << "." << imgExt; - t << "\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt IMAGE}}\\par" << endl; - t << "}" << endl; - DBG_RTF(t << "{\\comment (endDirDepGraph)}" << endl) + t << "\" \\\\d \\\\*MERGEFORMAT}{\\fldrslt IMAGE}}\\par\n"; + t << "}\n"; + DBG_RTF(t << "{\\comment (endDirDepGraph)}\n") } /** Tests the integrity of the result by counting brackets. @@ -2553,14 +2543,14 @@ void testRTFOutput(const char *name) int bcount=0; int line=1; int c; - QFile f(name); - if (f.open(IO_ReadOnly)) + std::ifstream f(name,std::ifstream::in); + if (f.is_open()) { - while ((c=f.getch())!=-1) + while ((c=f.get())!=-1) { if (c=='\\') // escape char { - c=f.getch(); + c=f.get(); if (c==-1) break; } else if (c=='{') // open bracket @@ -2611,26 +2601,25 @@ bool RTFGenerator::preProcessFileInplace(const char *path,const char *name) QCString combinedName = (QCString)path+"/combined.rtf"; QCString mainRTFName = (QCString)path+"/"+name; - QFile outf(combinedName); - if (!outf.open(IO_WriteOnly)) + std::ofstream outt(combinedName.str(),std::ofstream::out); + if (!outt.is_open()) { err("Failed to open %s for writing!\n",combinedName.data()); Dir::setCurrent(oldDir); return FALSE; } - FTextStream outt(&outf); if (!preProcessFile(thisDir,mainRTFName,outt)) { // it failed, remove the temp file - outf.close(); + outt.close(); thisDir.remove(combinedName.str()); Dir::setCurrent(oldDir); return FALSE; } // everything worked, move the files - outf.close(); + outt.close(); thisDir.remove(mainRTFName.str()); thisDir.rename(combinedName.str(),mainRTFName.str()); @@ -2642,48 +2631,48 @@ bool RTFGenerator::preProcessFileInplace(const char *path,const char *name) void RTFGenerator::startMemberGroupHeader(bool hasHeader) { - DBG_RTF(t << "{\\comment startMemberGroupHeader}" << endl) - t << "{" << endl; + DBG_RTF(t << "{\\comment startMemberGroupHeader}\n") + t << "{\n"; if (hasHeader) incrementIndentLevel(); t << rtf_Style_Reset << rtf_Style["GroupHeader"].reference(); } void RTFGenerator::endMemberGroupHeader() { - DBG_RTF(t << "{\\comment endMemberGroupHeader}" << endl) + DBG_RTF(t << "{\\comment endMemberGroupHeader}\n") newParagraph(); t << rtf_Style_Reset << rtf_CList_DepthStyle(); } void RTFGenerator::startMemberGroupDocs() { - DBG_RTF(t << "{\\comment startMemberGroupDocs}" << endl) + DBG_RTF(t << "{\\comment startMemberGroupDocs}\n") startEmphasis(); } void RTFGenerator::endMemberGroupDocs() { - DBG_RTF(t << "{\\comment endMemberGroupDocs}" << endl) + DBG_RTF(t << "{\\comment endMemberGroupDocs}\n") endEmphasis(); newParagraph(); } void RTFGenerator::startMemberGroup() { - DBG_RTF(t << "{\\comment startMemberGroup}" << endl) - t << rtf_Style_Reset << rtf_BList_DepthStyle() << endl; + DBG_RTF(t << "{\\comment startMemberGroup}\n") + t << rtf_Style_Reset << rtf_BList_DepthStyle() << "\n"; } void RTFGenerator::endMemberGroup(bool hasHeader) { - DBG_RTF(t << "{\\comment endMemberGroup}" << endl) + DBG_RTF(t << "{\\comment endMemberGroup}\n") if (hasHeader) decrementIndentLevel(); t << "}"; } void RTFGenerator::startExamples() { - DBG_RTF(t << "{\\comment (startExamples)}" << endl) + DBG_RTF(t << "{\\comment (startExamples)}\n") t << "{"; // ends at endDescList t << "{"; // ends at endDescTitle startBold(); @@ -2698,7 +2687,7 @@ void RTFGenerator::startExamples() void RTFGenerator::endExamples() { - DBG_RTF(t << "{\\comment (endExamples)}" << endl) + DBG_RTF(t << "{\\comment (endExamples)}\n") m_omitParagraph = FALSE; newParagraph(); decrementIndentLevel(); @@ -2708,7 +2697,7 @@ void RTFGenerator::endExamples() void RTFGenerator::startParamList(ParamListTypes,const char *title) { - DBG_RTF(t << "{\\comment (startParamList)}" << endl) + DBG_RTF(t << "{\\comment (startParamList)}\n") t << "{"; // ends at endParamList t << "{"; // ends at endDescTitle startBold(); @@ -2723,7 +2712,7 @@ void RTFGenerator::startParamList(ParamListTypes,const char *title) void RTFGenerator::endParamList() { - DBG_RTF(t << "{\\comment (endParamList)}" << endl) + DBG_RTF(t << "{\\comment (endParamList)}\n") newParagraph(); decrementIndentLevel(); m_omitParagraph = TRUE; @@ -2732,7 +2721,7 @@ void RTFGenerator::endParamList() void RTFGenerator::startParameterType(bool first,const char *key) { - DBG_RTF(t << "{\\comment (startParameterType)}" << endl) + DBG_RTF(t << "{\\comment (startParameterType)}\n") if (!first && key) { t << " " << key << " "; @@ -2741,13 +2730,13 @@ void RTFGenerator::startParameterType(bool first,const char *key) void RTFGenerator::endParameterType() { - DBG_RTF(t << "{\\comment (endParameterType)}" << endl) + DBG_RTF(t << "{\\comment (endParameterType)}\n") t << " "; } void RTFGenerator::exceptionEntry(const char* prefix,bool closeBracket) { - DBG_RTF(t << "{\\comment (exceptionEntry)}" << endl) + DBG_RTF(t << "{\\comment (exceptionEntry)}\n") if (prefix) t << " " << prefix << "("; else if (closeBracket) @@ -2765,26 +2754,26 @@ void RTFGenerator::writeDoc(DocNode *n,const Definition *ctx,const MemberDef *,i void RTFGenerator::rtfwriteRuler_doubleline() { - DBG_RTF(t << "{\\comment (rtfwriteRuler_doubleline)}" << endl) - t << "{\\pard\\widctlpar\\brdrb\\brdrdb\\brdrw15\\brsp20 \\adjustright \\par}" << endl; + DBG_RTF(t << "{\\comment (rtfwriteRuler_doubleline)}\n") + t << "{\\pard\\widctlpar\\brdrb\\brdrdb\\brdrw15\\brsp20 \\adjustright \\par}\n"; } void RTFGenerator::rtfwriteRuler_emboss() { - DBG_RTF(t << "{\\comment (rtfwriteRuler_emboss)}" << endl) - t << "{\\pard\\widctlpar\\brdrb\\brdremboss\\brdrw15\\brsp20 \\adjustright \\par}" << endl; + DBG_RTF(t << "{\\comment (rtfwriteRuler_emboss)}\n") + t << "{\\pard\\widctlpar\\brdrb\\brdremboss\\brdrw15\\brsp20 \\adjustright \\par}\n"; } void RTFGenerator::rtfwriteRuler_thick() { - DBG_RTF(t << "{\\comment (rtfwriteRuler_thick)}" << endl) - t << "{\\pard\\widctlpar\\brdrb\\brdrs\\brdrw75\\brsp20 \\adjustright \\par}" << endl; + DBG_RTF(t << "{\\comment (rtfwriteRuler_thick)}\n") + t << "{\\pard\\widctlpar\\brdrb\\brdrs\\brdrw75\\brsp20 \\adjustright \\par}\n"; } void RTFGenerator::rtfwriteRuler_thin() { - DBG_RTF(t << "{\\comment (rtfwriteRuler_thin)}" << endl) - t << "{\\pard\\widctlpar\\brdrb\\brdrs\\brdrw5\\brsp20 \\adjustright \\par}" << endl; + DBG_RTF(t << "{\\comment (rtfwriteRuler_thin)}\n") + t << "{\\pard\\widctlpar\\brdrb\\brdrs\\brdrw5\\brsp20 \\adjustright \\par}\n"; } #if 0 @@ -2820,7 +2809,7 @@ void RTFGenerator::postProcess(QByteArray &a) void RTFGenerator::startConstraintList(const char *header) { - DBG_RTF(t << "{\\comment (startConstraintList)}" << endl) + DBG_RTF(t << "{\\comment (startConstraintList)}\n") t << "{"; // ends at endConstraintList t << "{"; startBold(); @@ -2835,44 +2824,44 @@ void RTFGenerator::startConstraintList(const char *header) void RTFGenerator::startConstraintParam() { - DBG_RTF(t << "{\\comment (startConstraintParam)}" << endl) + DBG_RTF(t << "{\\comment (startConstraintParam)}\n") startEmphasis(); } void RTFGenerator::endConstraintParam() { - DBG_RTF(t << "{\\comment (endConstraintParam)}" << endl) + DBG_RTF(t << "{\\comment (endConstraintParam)}\n") endEmphasis(); t << " : "; } void RTFGenerator::startConstraintType() { - DBG_RTF(t << "{\\comment (startConstraintType)}" << endl) + DBG_RTF(t << "{\\comment (startConstraintType)}\n") startEmphasis(); } void RTFGenerator::endConstraintType() { - DBG_RTF(t << "{\\comment (endConstraintType)}" << endl) + DBG_RTF(t << "{\\comment (endConstraintType)}\n") endEmphasis(); t << " "; } void RTFGenerator::startConstraintDocs() { - DBG_RTF(t << "{\\comment (startConstraintDocs)}" << endl) + DBG_RTF(t << "{\\comment (startConstraintDocs)}\n") } void RTFGenerator::endConstraintDocs() { - DBG_RTF(t << "{\\comment (endConstraintDocs)}" << endl) + DBG_RTF(t << "{\\comment (endConstraintDocs)}\n") newParagraph(); } void RTFGenerator::endConstraintList() { - DBG_RTF(t << "{\\comment (endConstraintList)}" << endl) + DBG_RTF(t << "{\\comment (endConstraintList)}\n") newParagraph(); decrementIndentLevel(); m_omitParagraph = TRUE; @@ -2881,36 +2870,36 @@ void RTFGenerator::endConstraintList() void RTFGenerator::startIndexListItem() { - DBG_RTF(t << "{\\comment (startIndexListItem)}" << endl) + DBG_RTF(t << "{\\comment (startIndexListItem)}\n") } void RTFGenerator::endIndexListItem() { - DBG_RTF(t << "{\\comment (endIndexListItem)}" << endl) - t << "\\par" << endl; + DBG_RTF(t << "{\\comment (endIndexListItem)}\n") + t << "\\par\n"; } void RTFGenerator::startInlineHeader() { - DBG_RTF(t << "{\\comment (startInlineHeader)}" << endl) - t << "{" << endl; + DBG_RTF(t << "{\\comment (startInlineHeader)}\n") + t << "{\n"; t << rtf_Style_Reset << rtf_Style["Heading5"].reference(); startBold(); } void RTFGenerator::endInlineHeader() { - DBG_RTF(t << "{\\comment (endInlineHeader)}" << endl) + DBG_RTF(t << "{\\comment (endInlineHeader)}\n") endBold(); t << "\\par"; - t << "}" << endl; + t << "}\n"; } void RTFGenerator::startMemberDocSimple(bool isEnum) { - DBG_RTF(t << "{\\comment (startMemberDocSimple)}" << endl) - t << "{\\par" << endl; - t << "{" << rtf_Style["Heading5"].reference() << endl; + DBG_RTF(t << "{\\comment (startMemberDocSimple)}\n") + t << "{\\par\n"; + t << "{" << rtf_Style["Heading5"].reference() << "\n"; if (isEnum) { t << theTranslator->trEnumerationValues(); @@ -2919,7 +2908,7 @@ void RTFGenerator::startMemberDocSimple(bool isEnum) { t << theTranslator->trCompoundMembers(); } - t << ":\\par}" << endl; + t << ":\\par}\n"; t << rtf_Style_Reset << rtf_DList_DepthStyle(); t << "\\trowd \\trgaph108\\trleft426\\tblind426" "\\trbrdrt\\brdrs\\brdrw10\\brdrcf15 " @@ -2927,7 +2916,7 @@ void RTFGenerator::startMemberDocSimple(bool isEnum) "\\trbrdrb\\brdrs\\brdrw10\\brdrcf15 " "\\trbrdrr\\brdrs\\brdrw10\\brdrcf15 " "\\trbrdrh\\brdrs\\brdrw10\\brdrcf15 " - "\\trbrdrv\\brdrs\\brdrw10\\brdrcf15 "<< endl; + "\\trbrdrv\\brdrs\\brdrw10\\brdrcf15 \n"; int i,n=3,columnPos[3] = { 25, 50, 100 }; if (isEnum) { @@ -2942,51 +2931,51 @@ void RTFGenerator::startMemberDocSimple(bool isEnum) "\\clbrdrb\\brdrs\\brdrw10\\brdrcf15 " "\\clbrdrr \\brdrs\\brdrw10\\brdrcf15 " "\\cltxlrtb " - "\\cellx" << (rtf_pageWidth*columnPos[i]/100) << endl; + "\\cellx" << (rtf_pageWidth*columnPos[i]/100) << "\n"; } - t << "\\pard \\widctlpar\\intbl\\adjustright" << endl; + t << "\\pard \\widctlpar\\intbl\\adjustright\n"; } void RTFGenerator::endMemberDocSimple(bool) { - DBG_RTF(t << "{\\comment (endMemberDocSimple)}" << endl) - t << "}" << endl; + DBG_RTF(t << "{\\comment (endMemberDocSimple)}\n") + t << "}\n"; } void RTFGenerator::startInlineMemberType() { - DBG_RTF(t << "{\\comment (startInlineMemberType)}" << endl) + DBG_RTF(t << "{\\comment (startInlineMemberType)}\n") t << "{\\qr "; } void RTFGenerator::endInlineMemberType() { - DBG_RTF(t << "{\\comment (endInlineMemberType)}" << endl) + DBG_RTF(t << "{\\comment (endInlineMemberType)}\n") t << "\\cell }"; } void RTFGenerator::startInlineMemberName() { - DBG_RTF(t << "{\\comment (startInlineMemberName)}" << endl) + DBG_RTF(t << "{\\comment (startInlineMemberName)}\n") t << "{"; } void RTFGenerator::endInlineMemberName() { - DBG_RTF(t << "{\\comment (endInlineMemberName)}" << endl) + DBG_RTF(t << "{\\comment (endInlineMemberName)}\n") t << "\\cell }"; } void RTFGenerator::startInlineMemberDoc() { - DBG_RTF(t << "{\\comment (startInlineMemberDoc)}" << endl) + DBG_RTF(t << "{\\comment (startInlineMemberDoc)}\n") t << "{"; } void RTFGenerator::endInlineMemberDoc() { - DBG_RTF(t << "{\\comment (endInlineMemberDoc)}" << endl) - t << "\\cell }{\\row }" << endl; + DBG_RTF(t << "{\\comment (endInlineMemberDoc)}\n") + t << "\\cell }{\\row }\n"; } void RTFGenerator::writeLineNumber(const char *ref,const char *fileName,const char *anchor,int l) @@ -3008,7 +2997,7 @@ void RTFGenerator::writeLineNumber(const char *ref,const char *fileName,const ch t << "}"; t << "{\\bkmkend "; t << rtfFormatBmkStr(lineAnchor); - t << "}" << endl; + t << "}\n"; } t << lineNumber << " "; } diff --git a/src/rtfgen.h b/src/rtfgen.h index 0aebd15..e6695bb 100644 --- a/src/rtfgen.h +++ b/src/rtfgen.h @@ -21,8 +21,6 @@ #include "config.h" #include "outputgen.h" -class QFile; - /** Generator for RTF output. */ class RTFGenerator : public OutputGenerator { @@ -34,8 +32,8 @@ class RTFGenerator : public OutputGenerator virtual std::unique_ptr<OutputGenerator> clone() const; static void init(); - static void writeStyleSheetFile(QFile &f); - static void writeExtensionsFile(QFile &file); + static void writeStyleSheetFile(std::ostream &t); + static void writeExtensionsFile(std::ostream &t); OutputType type() const { return RTF; } void setRelativePath(const QCString &path); @@ -152,7 +150,7 @@ class RTFGenerator : public OutputGenerator void endSubsection(); void startSubsubsection(); void endSubsubsection(); - void startCenter() { t << "{\\qc" << endl; } + void startCenter() { t << "{\\qc\n"; } void endCenter() { t << "}"; } void startSmall() { t << "{\\sub "; } void endSmall() { t << "}"; } diff --git a/src/scanner.l b/src/scanner.l index 6b4cda3..8c2cd07 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -35,8 +35,6 @@ #include <assert.h> #include <ctype.h> -#include <qfile.h> - #include "scanner.h" #include "entry.h" #include "message.h" diff --git a/src/searchindex.cpp b/src/searchindex.cpp index 61d2d6c..c0d3c02 100644 --- a/src/searchindex.cpp +++ b/src/searchindex.cpp @@ -17,8 +17,6 @@ #include <ctype.h> #include <assert.h> -#include <qfile.h> - #include "searchindex.h" #include "config.h" #include "util.h" @@ -244,19 +242,19 @@ void SearchIndex::addWord(const char *word,bool hiPriority) addWord(word,hiPriority,FALSE); } -static void writeInt(QFile &f,size_t index) +static void writeInt(std::ostream &f,size_t index) { - f.putch(static_cast<int>(index>>24)); - f.putch(static_cast<int>((index>>16)&0xff)); - f.putch(static_cast<int>((index>>8)&0xff)); - f.putch(static_cast<int>(index&0xff)); + f.put(static_cast<int>(index>>24)); + f.put(static_cast<int>((index>>16)&0xff)); + f.put(static_cast<int>((index>>8)&0xff)); + f.put(static_cast<int>(index&0xff)); } -static void writeString(QFile &f,const char *s) +static void writeString(std::ostream &f,const char *s) { const char *p = s; - while (*p) f.putch(*p++); - f.putch(0); + while (*p) f.put(*p++); + f.put(0); } void SearchIndex::write(const char *fileName) @@ -332,11 +330,11 @@ void SearchIndex::write(const char *fileName) } //printf("Total size %x bytes (word=%x stats=%x urls=%x)\n",size,wordsOffset,statsOffset,urlsOffset); - QFile f(fileName); - if (f.open(IO_WriteOnly)) + std::ofstream f(fileName,std::ofstream::out | std::ofstream::binary); + if (f.is_open()) { // write header - f.putch('D'); f.putch('O'); f.putch('X'); f.putch('S'); + f.put('D'); f.put('O'); f.put('X'); f.put('S'); // write index for (i=0;i<numIndexEntries;i++) { @@ -354,11 +352,11 @@ void SearchIndex::write(const char *fileName) writeString(f,iw.word()); writeInt(f,wordStatOffsets[count++]); } - f.putch(0); + f.put(0); } } // write extra padding bytes - for (i=0;i<padding;i++) f.putch(0); + for (i=0;i<padding;i++) f.put(0); // write word statistics for (i=0;i<numIndexEntries;i++) { @@ -504,34 +502,33 @@ void SearchIndexExternal::addWord(const char *word,bool hiPriority) void SearchIndexExternal::write(const char *fileName) { - QFile f(fileName); - if (f.open(IO_WriteOnly)) + std::ofstream t(fileName,std::ofstream::out | std::ofstream::binary); + if (t.is_open()) { - FTextStream t(&f); - t << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl; - t << "<add>" << endl; + t << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; + t << "<add>\n"; for (auto &kv : p->docEntries) { SearchDocEntry &doc = kv.second; doc.normalText.addChar(0); // make sure buffer ends with a 0 terminator doc.importantText.addChar(0); // make sure buffer ends with a 0 terminator - t << " <doc>" << endl; - t << " <field name=\"type\">" << doc.type << "</field>" << endl; - t << " <field name=\"name\">" << convertToXML(doc.name) << "</field>" << endl; + t << " <doc>\n"; + t << " <field name=\"type\">" << doc.type << "</field>\n"; + t << " <field name=\"name\">" << convertToXML(doc.name) << "</field>\n"; if (!doc.args.isEmpty()) { - t << " <field name=\"args\">" << convertToXML(doc.args) << "</field>" << endl; + t << " <field name=\"args\">" << convertToXML(doc.args) << "</field>\n"; } if (!doc.extId.isEmpty()) { - t << " <field name=\"tag\">" << convertToXML(doc.extId) << "</field>" << endl; + t << " <field name=\"tag\">" << convertToXML(doc.extId) << "</field>\n"; } - t << " <field name=\"url\">" << convertToXML(doc.url) << "</field>" << endl; - t << " <field name=\"keywords\">" << convertToXML(doc.importantText.get()) << "</field>" << endl; - t << " <field name=\"text\">" << convertToXML(doc.normalText.get()) << "</field>" << endl; - t << " </doc>" << endl; + t << " <field name=\"url\">" << convertToXML(doc.url) << "</field>\n"; + t << " <field name=\"keywords\">" << convertToXML(doc.importantText.get()) << "</field>\n"; + t << " <field name=\"text\">" << convertToXML(doc.normalText.get()) << "</field>\n"; + t << " </doc>\n"; } - t << "</add>" << endl; + t << "</add>\n"; } else { @@ -918,58 +915,55 @@ void writeJavaScriptSearchIndex() QCString fileName = searchDirName + "/"+baseName+Doxygen::htmlFileExtension; QCString dataFileName = searchDirName + "/"+baseName+".js"; - QFile outFile(fileName); - QFile dataOutFile(dataFileName); - if (outFile.open(IO_WriteOnly) && dataOutFile.open(IO_WriteOnly)) + std::ofstream t(fileName.str(), std::ofstream::out | std::ofstream::binary); + std::ofstream ti(dataFileName.str(), std::ofstream::out | std::ofstream::binary); + if (t.is_open() && ti.is_open()) { { - FTextStream t(&outFile); - t << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"" - " \"https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" << endl; - t << "<html xmlns=\"http://www.w3.org/1999/xhtml\">" << endl; - t << "<head><title></title>" << endl; - t << "<meta http-equiv=\"Content-Type\" content=\"text/xhtml;charset=UTF-8\"/>" << endl; - t << "<meta name=\"generator\" content=\"Doxygen " << getDoxygenVersion() << "\"/>" << endl; - t << "<link rel=\"stylesheet\" type=\"text/css\" href=\"search.css\"/>" << endl; - t << "<script type=\"text/javascript\" src=\"" << baseName << ".js\"></script>" << endl; - t << "<script type=\"text/javascript\" src=\"search.js\"></script>" << endl; - t << "</head>" << endl; - t << "<body class=\"SRPage\">" << endl; - t << "<div id=\"SRIndex\">" << endl; - t << "<div class=\"SRStatus\" id=\"Loading\">" << theTranslator->trLoading() << "</div>" << endl; - t << "<div id=\"SRResults\"></div>" << endl; // here the results will be inserted - t << "<script type=\"text/javascript\">" << endl; + " \"https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"; + t << "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"; + t << "<head><title></title>\n"; + t << "<meta http-equiv=\"Content-Type\" content=\"text/xhtml;charset=UTF-8\"/>\n"; + t << "<meta name=\"generator\" content=\"Doxygen " << getDoxygenVersion() << "\"/>\n"; + t << "<link rel=\"stylesheet\" type=\"text/css\" href=\"search.css\"/>\n"; + t << "<script type=\"text/javascript\" src=\"" << baseName << ".js\"></script>\n"; + t << "<script type=\"text/javascript\" src=\"search.js\"></script>\n"; + t << "</head>\n"; + t << "<body class=\"SRPage\">\n"; + t << "<div id=\"SRIndex\">\n"; + t << "<div class=\"SRStatus\" id=\"Loading\">" << theTranslator->trLoading() << "</div>\n"; + t << "<div id=\"SRResults\"></div>\n"; // here the results will be inserted + t << "<script type=\"text/javascript\">\n"; t << "/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */\n"; - t << "createResults();" << endl; // this function will insert the results + t << "createResults();\n"; // this function will insert the results t << "/* @license-end */\n"; - t << "</script>" << endl; + t << "</script>\n"; t << "<div class=\"SRStatus\" id=\"Searching\">" - << theTranslator->trSearching() << "</div>" << endl; + << theTranslator->trSearching() << "</div>\n"; t << "<div class=\"SRStatus\" id=\"NoMatches\">" - << theTranslator->trNoMatches() << "</div>" << endl; + << theTranslator->trNoMatches() << "</div>\n"; - t << "<script type=\"text/javascript\">" << endl; + t << "<script type=\"text/javascript\">\n"; t << "/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */\n"; - t << "document.getElementById(\"Loading\").style.display=\"none\";" << endl; - t << "document.getElementById(\"NoMatches\").style.display=\"none\";" << endl; - t << "var searchResults = new SearchResults(\"searchResults\");" << endl; - t << "searchResults.Search();" << endl; - t << "window.addEventListener(\"message\", function(event) {" << endl; - t << " if (event.data == \"take_focus\") {" << endl; - t << " var elem = searchResults.NavNext(0);" << endl; - t << " if (elem) elem.focus();" << endl; - t << " }" << endl; - t << "});" << endl; + t << "document.getElementById(\"Loading\").style.display=\"none\";\n"; + t << "document.getElementById(\"NoMatches\").style.display=\"none\";\n"; + t << "var searchResults = new SearchResults(\"searchResults\");\n"; + t << "searchResults.Search();\n"; + t << "window.addEventListener(\"message\", function(event) {\n"; + t << " if (event.data == \"take_focus\") {\n"; + t << " var elem = searchResults.NavNext(0);\n"; + t << " if (elem) elem.focus();\n"; + t << " }\n"; + t << "});\n"; t << "/* @license-end */\n"; - t << "</script>" << endl; - t << "</div>" << endl; // SRIndex - t << "</body>" << endl; - t << "</html>" << endl; + t << "</script>\n"; + t << "</div>\n"; // SRIndex + t << "</body>\n"; + t << "</html>\n"; } - FTextStream ti(&dataOutFile); - ti << "var searchData=" << endl; + ti << "var searchData=\n"; // format // searchData[] = array of items // searchData[x][0] = id @@ -980,7 +974,7 @@ void writeJavaScriptSearchIndex() // searchData[x][1][y+1][1] = 1 => target="_parent" // searchData[x][1][y+1][2] = scope - ti << "[" << endl; + ti << "[\n"; bool firstEntry=TRUE; int childCount=0; @@ -997,7 +991,7 @@ void writeJavaScriptSearchIndex() if (!firstEntry) { ti << "]]]"; - ti << "," << endl; + ti << ",\n"; } firstEntry=FALSE; @@ -1124,9 +1118,9 @@ void writeJavaScriptSearchIndex() } if (!firstEntry) { - ti << "]]]" << endl; + ti << "]]]\n"; } - ti << "];" << endl; + ti << "];\n"; } else { @@ -1137,18 +1131,17 @@ void writeJavaScriptSearchIndex() } { - QFile f(searchDirName+"/searchdata.js"); - if (f.open(IO_WriteOnly)) + std::ofstream t(searchDirName.str()+"/searchdata.js",std::ofstream::out); + if (t.is_open()) { - FTextStream t(&f); - t << "var indexSectionsWithContent =" << endl; - t << "{" << endl; + t << "var indexSectionsWithContent =\n"; + t << "{\n"; int j=0; for (const auto &sii : g_searchIndexInfo) { if (!sii.symbolMap.empty()) { - if (j>0) t << "," << endl; + if (j>0) t << ",\n"; t << " " << j << ": \""; for (const auto &kv : sii.symbolMap) @@ -1161,59 +1154,59 @@ void writeJavaScriptSearchIndex() } } if (j>0) t << "\n"; - t << "};" << endl << endl; - t << "var indexSectionNames =" << endl; - t << "{" << endl; + t << "};\n\n"; + t << "var indexSectionNames =\n"; + t << "{\n"; j=0; for (const auto &sii : g_searchIndexInfo) { if (!sii.symbolMap.empty()) { - if (j>0) t << "," << endl; + if (j>0) t << ",\n"; t << " " << j << ": \"" << sii.name << "\""; j++; } } if (j>0) t << "\n"; - t << "};" << endl << endl; - t << "var indexSectionLabels =" << endl; - t << "{" << endl; + t << "};\n\n"; + t << "var indexSectionLabels =\n"; + t << "{\n"; j=0; for (const auto &sii : g_searchIndexInfo) { if (!sii.symbolMap.empty()) { - if (j>0) t << "," << endl; + if (j>0) t << ",\n"; t << " " << j << ": \"" << convertToXML(sii.getText()) << "\""; j++; } } if (j>0) t << "\n"; - t << "};" << endl << endl; + t << "};\n\n"; } ResourceMgr::instance().copyResource("search.js",searchDirName); } { - QFile f(searchDirName+"/nomatches"+Doxygen::htmlFileExtension); - if (f.open(IO_WriteOnly)) + QCString noMatchesFileName =searchDirName+"/nomatches"+Doxygen::htmlFileExtension; + std::ofstream t(noMatchesFileName.str(), std::ofstream::out | std::ofstream::binary); + if (t.is_open()) { - FTextStream t(&f); t << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" " - "\"https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" << endl; - t << "<html xmlns=\"http://www.w3.org/1999/xhtml\">" << endl; - t << "<head><title></title>" << endl; - t << "<meta http-equiv=\"Content-Type\" content=\"text/xhtml;charset=UTF-8\"/>" << endl; - t << "<link rel=\"stylesheet\" type=\"text/css\" href=\"search.css\"/>" << endl; - t << "<script type=\"text/javascript\" src=\"search.js\"></script>" << endl; - t << "</head>" << endl; - t << "<body class=\"SRPage\">" << endl; - t << "<div id=\"SRIndex\">" << endl; + "\"https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"; + t << "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"; + t << "<head><title></title>\n"; + t << "<meta http-equiv=\"Content-Type\" content=\"text/xhtml;charset=UTF-8\"/>\n"; + t << "<link rel=\"stylesheet\" type=\"text/css\" href=\"search.css\"/>\n"; + t << "<script type=\"text/javascript\" src=\"search.js\"></script>\n"; + t << "</head>\n"; + t << "<body class=\"SRPage\">\n"; + t << "<div id=\"SRIndex\">\n"; t << "<div class=\"SRStatus\" id=\"NoMatches\">" - << theTranslator->trNoMatches() << "</div>" << endl; - t << "</div>" << endl; - t << "</body>" << endl; - t << "</html>" << endl; + << theTranslator->trNoMatches() << "</div>\n"; + t << "</div>\n"; + t << "</body>\n"; + t << "</html>\n"; } } Doxygen::indexList->addStyleSheetFile("search/search.js"); diff --git a/src/sqlite3gen.cpp b/src/sqlite3gen.cpp index de30544..04c0953 100644 --- a/src/sqlite3gen.cpp +++ b/src/sqlite3gen.cpp @@ -15,12 +15,13 @@ #include <stdlib.h> #include <stdio.h> +#include <sstream> + #include "settings.h" #include "message.h" #if USE_SQLITE3 -#include "qtbc.h" #include "sqlite3gen.h" #include "doxygen.h" #include "xmlgen.h" @@ -1382,9 +1383,9 @@ QCString getSQLDocBlock(const Definition *scope, const QCString &fileName, int lineNr) { - QGString s; - if (doc.isEmpty()) return s.data(); - FTextStream t(&s); + if (doc.isEmpty()) return ""; + + std::stringstream t; DocNode *root = validatingParseDoc( fileName, lineNr, @@ -1404,8 +1405,7 @@ QCString getSQLDocBlock(const Definition *scope, root->accept(visitor); delete visitor; delete root; - QCString result = convertCharEntitiesToUTF8(s.data()); - return result.data(); + return convertCharEntitiesToUTF8(t.str().c_str()); } static void getSQLDesc(SqlStmt &s,const char *col,const char *value,const Definition *def) diff --git a/src/template.cpp b/src/template.cpp index ae55fc4..9bfeb23 100644 --- a/src/template.cpp +++ b/src/template.cpp @@ -20,10 +20,9 @@ #include <unordered_map> #include <deque> #include <cstdio> +#include <fstream> +#include <sstream> -#include <qfile.h> - -#include "ftextstream.h" #include "message.h" #include "util.h" #include "resourcemgr.h" @@ -1661,7 +1660,7 @@ class TemplateNode TemplateNode(TemplateNode *parent) : m_parent(parent) {} virtual ~TemplateNode() {} - virtual void render(FTextStream &ts, TemplateContext *c) = 0; + virtual void render(std::ostream &ts, TemplateContext *c) = 0; TemplateNode *parent() { return m_parent; } @@ -1691,7 +1690,7 @@ using TemplateTokenStream = std::deque< TemplateTokenPtr >; class TemplateNodeList : public std::vector< std::unique_ptr<TemplateNode> > { public: - void render(FTextStream &ts,TemplateContext *c) + void render(std::ostream &ts,TemplateContext *c) { TRACE(("{TemplateNodeList::render\n")); for (const auto &tn : *this) @@ -2279,7 +2278,7 @@ class TemplateImpl : public TemplateNode, public Template TemplateImpl(TemplateEngine *e,const QCString &name,const QCString &data, const QCString &extension); ~TemplateImpl(); - void render(FTextStream &ts, TemplateContext *c); + void render(std::ostream &ts, TemplateContext *c); TemplateEngine *engine() const { return m_engine; } TemplateBlockContext *blockContext() { return &m_blockContext; } @@ -2648,7 +2647,7 @@ class TemplateNodeText : public TemplateNode TRACE(("TemplateNodeText('%s')\n",replace(data,'\n',' ').data())); } - void render(FTextStream &ts, TemplateContext *c) + void render(std::ostream &ts, TemplateContext *c) { TemplateContextImpl* ci = dynamic_cast<TemplateContextImpl*>(c); if (ci==0) return; // should not happen @@ -2702,7 +2701,7 @@ class TemplateNodeVariable : public TemplateNode delete m_var; } - void render(FTextStream &ts, TemplateContext *c) + void render(std::ostream &ts, TemplateContext *c) { TemplateContextImpl* ci = dynamic_cast<TemplateContextImpl*>(c); if (ci==0) return; // should not happen @@ -2864,7 +2863,7 @@ class TemplateNodeIf : public TemplateNodeCreator<TemplateNodeIf> { } - void render(FTextStream &ts, TemplateContext *c) + void render(std::ostream &ts, TemplateContext *c) { TemplateContextImpl* ci = dynamic_cast<TemplateContextImpl*>(c); if (ci==0) return; // should not happen @@ -2927,7 +2926,7 @@ class TemplateNodeRepeat : public TemplateNodeCreator<TemplateNodeRepeat> { delete m_expr; } - void render(FTextStream &ts, TemplateContext *c) + void render(std::ostream &ts, TemplateContext *c) { TemplateContextImpl* ci = dynamic_cast<TemplateContextImpl*>(c); if (ci==0) return; // should not happen @@ -3039,7 +3038,7 @@ class TemplateNodeRange : public TemplateNodeCreator<TemplateNodeRange> delete m_endExpr; } - void render(FTextStream &ts, TemplateContext *c) + void render(std::ostream &ts, TemplateContext *c) { TemplateContextImpl* ci = dynamic_cast<TemplateContextImpl*>(c); if (ci==0) return; // should not happen @@ -3197,7 +3196,7 @@ class TemplateNodeFor : public TemplateNodeCreator<TemplateNodeFor> delete m_expr; } - void render(FTextStream &ts, TemplateContext *c) + void render(std::ostream &ts, TemplateContext *c) { TemplateContextImpl* ci = dynamic_cast<TemplateContextImpl*>(c); if (ci==0) return; // should not happen @@ -3299,7 +3298,7 @@ class TemplateNodeMsg : public TemplateNodeCreator<TemplateNodeMsg> parser->removeNextToken(); // skip over endmsg TRACE(("}TemplateNodeMsg()\n")); } - void render(FTextStream &, TemplateContext *c) + void render(std::ostream &, TemplateContext *c) { TemplateContextImpl* ci = dynamic_cast<TemplateContextImpl*>(c); if (ci==0) return; // should not happen @@ -3308,9 +3307,8 @@ class TemplateNodeMsg : public TemplateNodeCreator<TemplateNodeMsg> ci->setActiveEscapeIntf(0); // avoid escaping things we send to standard out bool enable = ci->spacelessEnabled(); ci->enableSpaceless(FALSE); - FTextStream ts(stdout); - m_nodes.render(ts,c); - ts << endl; + m_nodes.render(std::cout,c); + std::cout << "\n"; ci->setActiveEscapeIntf(escIntf); ci->enableSpaceless(enable); } @@ -3340,7 +3338,7 @@ class TemplateNodeBlock : public TemplateNodeCreator<TemplateNodeBlock> TRACE(("}TemplateNodeBlock(%s)\n",data.data())); } - void render(FTextStream &ts, TemplateContext *c) + void render(std::ostream &ts, TemplateContext *c) { TemplateContextImpl *ci = dynamic_cast<TemplateContextImpl*>(c); if (ci==0) return; // should not happen @@ -3353,8 +3351,7 @@ class TemplateNodeBlock : public TemplateNodeCreator<TemplateNodeBlock> if (nb) // block is overruled { ci->push(); - QGString super; - FTextStream ss(&super); + std::stringstream ss; // get super block of block nb TemplateNodeBlock *sb = ci->blockContext()->get(m_blockName); if (sb && sb!=nb && sb!=this) // nb and sb both overrule this block @@ -3365,6 +3362,7 @@ class TemplateNodeBlock : public TemplateNodeCreator<TemplateNodeBlock> { m_nodes.render(ss,c); // render parent of nb to string } + QCString super = ss.str(); // add 'block.super' variable to allow access to parent block content TemplateAutoRef<TemplateStruct> superBlock(TemplateStruct::alloc()); superBlock->set("super",TemplateVariant(super.data(),TRUE)); @@ -3421,7 +3419,7 @@ class TemplateNodeExtend : public TemplateNodeCreator<TemplateNodeExtend> delete m_extendExpr; } - void render(FTextStream &ts, TemplateContext *c) + void render(std::ostream &ts, TemplateContext *c) { TemplateContextImpl* ci = dynamic_cast<TemplateContextImpl*>(c); if (ci==0) return; // should not happen @@ -3498,7 +3496,7 @@ class TemplateNodeInclude : public TemplateNodeCreator<TemplateNodeInclude> { delete m_includeExpr; } - void render(FTextStream &ts, TemplateContext *c) + void render(std::ostream &ts, TemplateContext *c) { TemplateContextImpl* ci = dynamic_cast<TemplateContextImpl*>(c); if (ci==0) return; // should not happen @@ -3537,12 +3535,12 @@ class TemplateNodeInclude : public TemplateNodeCreator<TemplateNodeInclude> //---------------------------------------------------------- -static void stripLeadingWhiteSpace(QGString &s) +static void stripLeadingWhiteSpace(QCString &s) { const char *src = s.data(); if (src) { - char *dst = s.data(); + char *dst = s.rawData(); char c; bool skipSpaces=TRUE; while ((c=*src++)) @@ -3595,7 +3593,7 @@ class TemplateNodeCreate : public TemplateNodeCreator<TemplateNodeCreate> delete m_templateExpr; delete m_fileExpr; } - void render(FTextStream &, TemplateContext *c) + void render(std::ostream &, TemplateContext *c) { TemplateContextImpl* ci = dynamic_cast<TemplateContextImpl*>(c); if (ci==0) return; // should not happen @@ -3634,15 +3632,14 @@ class TemplateNodeCreate : public TemplateNodeCreator<TemplateNodeCreate> outputFile.prepend(ci->outputDirectory()+"/"); } //printf("NoteCreate(%s)\n",outputFile.data()); - QFile f(outputFile); - if (f.open(IO_WriteOnly)) + std::ofstream ts(outputFile.str(),std::ofstream::out | std::ofstream::binary); + if (ts.is_open()) { TemplateEscapeIntf *escIntf = ci->escapeIntf(); ci->selectEscapeIntf(extension); - FTextStream ts(&f); - QGString out; - FTextStream os(&out); + std::stringstream os; createTemplate->render(os,c); + QCString out = os.str(); stripLeadingWhiteSpace(out); ts << out; t->engine()->unload(t); @@ -3713,8 +3710,7 @@ class TemplateNodeTree : public TemplateNodeCreator<TemplateNodeTree> TemplateContext *c = ctx->templateCtx; TemplateContextImpl* ci = dynamic_cast<TemplateContextImpl*>(c); if (ci==0) return QCString(); // should not happen - QGString result; - FTextStream ss(&result); + std::stringstream ss; c->push(); TemplateVariant node; TemplateListIntf::ConstIterator *it = ctx->list->createIterator(); @@ -3756,9 +3752,9 @@ class TemplateNodeTree : public TemplateNodeCreator<TemplateNodeTree> } c->pop(); delete it; - return result.data(); + return ss.str(); } - void render(FTextStream &ts, TemplateContext *c) + void render(std::ostream &ts, TemplateContext *c) { //printf("TemplateNodeTree::render()\n"); TemplateContextImpl* ci = dynamic_cast<TemplateContextImpl*>(c); @@ -3830,7 +3826,7 @@ class TemplateNodeIndexEntry : public TemplateNodeCreator<TemplateNodeIndexEntry } TRACE(("}TemplateNodeIndexEntry(%s)\n",data.data())); } - void render(FTextStream &, TemplateContext *c) + void render(std::ostream &, TemplateContext *c) { TemplateContextImpl *ci = dynamic_cast<TemplateContextImpl*>(c); if (ci==0) return; // should not happen @@ -3872,7 +3868,7 @@ class TemplateNodeOpenSubIndex : public TemplateNodeCreator<TemplateNodeOpenSubI } TRACE(("}TemplateNodeOpenSubIndex(%s)\n",data.data())); } - void render(FTextStream &, TemplateContext *c) + void render(std::ostream &, TemplateContext *c) { TemplateContextImpl *ci = dynamic_cast<TemplateContextImpl*>(c); if (ci==0) return; // should not happen @@ -3908,7 +3904,7 @@ class TemplateNodeCloseSubIndex : public TemplateNodeCreator<TemplateNodeCloseSu } TRACE(("}TemplateNodeCloseSubIndex(%s)\n",data.data())); } - void render(FTextStream &, TemplateContext *c) + void render(std::ostream &, TemplateContext *c) { TemplateContextImpl *ci = dynamic_cast<TemplateContextImpl*>(c); if (ci==0) return; // should not happen @@ -3969,7 +3965,7 @@ class TemplateNodeWith : public TemplateNodeCreator<TemplateNodeWith> ~TemplateNodeWith() { } - void render(FTextStream &ts, TemplateContext *c) + void render(std::ostream &ts, TemplateContext *c) { TemplateContextImpl *ci = dynamic_cast<TemplateContextImpl*>(c); if (ci==0) return; // should not happen @@ -4017,7 +4013,7 @@ class TemplateNodeCycle : public TemplateNodeCreator<TemplateNodeCycle> } TRACE(("}TemplateNodeCycle(%s)\n",data.data())); } - void render(FTextStream &ts, TemplateContext *c) + void render(std::ostream &ts, TemplateContext *c) { TemplateContextImpl *ci = dynamic_cast<TemplateContextImpl*>(c); ci->setLocation(m_templateName,m_line); @@ -4091,7 +4087,7 @@ class TemplateNodeSet : public TemplateNodeCreator<TemplateNodeSet> ~TemplateNodeSet() { } - void render(FTextStream &, TemplateContext *c) + void render(std::ostream &, TemplateContext *c) { TemplateContextImpl *ci = dynamic_cast<TemplateContextImpl*>(c); if (ci==0) return; // should not happen @@ -4121,7 +4117,7 @@ class TemplateNodeSpaceless : public TemplateNodeCreator<TemplateNodeSpaceless> parser->removeNextToken(); // skip over endwith TRACE(("}TemplateNodeSpaceless()\n")); } - void render(FTextStream &ts, TemplateContext *c) + void render(std::ostream &ts, TemplateContext *c) { TemplateContextImpl *ci = dynamic_cast<TemplateContextImpl*>(c); if (ci==0) return; // should not happen @@ -4168,7 +4164,7 @@ class TemplateNodeMarkers : public TemplateNodeCreator<TemplateNodeMarkers> delete m_listExpr; delete m_patternExpr; } - void render(FTextStream &ts, TemplateContext *c) + void render(std::ostream &ts, TemplateContext *c) { TemplateContextImpl *ci = dynamic_cast<TemplateContextImpl*>(c); if (ci==0) return; // should not happen @@ -4270,7 +4266,7 @@ class TemplateNodeTabbing : public TemplateNodeCreator<TemplateNodeTabbing> parser->removeNextToken(); // skip over endtabbing TRACE(("}TemplateNodeTabbing()\n")); } - void render(FTextStream &ts, TemplateContext *c) + void render(std::ostream &ts, TemplateContext *c) { TemplateContextImpl *ci = dynamic_cast<TemplateContextImpl*>(c); if (ci==0) return; // should not happen @@ -4319,7 +4315,7 @@ class TemplateNodeResource : public TemplateNodeCreator<TemplateNodeResource> delete m_resExpr; delete m_asExpr; } - void render(FTextStream &, TemplateContext *c) + void render(std::ostream &, TemplateContext *c) { TemplateContextImpl *ci = dynamic_cast<TemplateContextImpl*>(c); if (ci==0) return; // should not happen @@ -4387,7 +4383,7 @@ class TemplateNodeEncoding : public TemplateNodeCreator<TemplateNodeEncoding> { delete m_encExpr; } - void render(FTextStream &ts, TemplateContext *c) + void render(std::ostream &ts, TemplateContext *c) { TemplateContextImpl *ci = dynamic_cast<TemplateContextImpl*>(c); if (ci==0) return; // should not happen @@ -4950,7 +4946,7 @@ TemplateImpl::~TemplateImpl() //printf("deleting template %s\n",m_name.data()); } -void TemplateImpl::render(FTextStream &ts, TemplateContext *c) +void TemplateImpl::render(std::ostream &ts, TemplateContext *c) { TemplateContextImpl *ci = dynamic_cast<TemplateContextImpl*>(c); if (ci==0) return; // should not happen @@ -5009,13 +5005,14 @@ class TemplateEngine::Private if (kv==m_templateCache.end()) // first time template is referenced { QCString filePath = m_templateDirName+"/"+fileName; - QFile f(filePath); - if (f.open(IO_ReadOnly)) // read template from disk + std::ifstream f(filePath.str(),std::ifstream::in | std::ifstream::binary); + if (f.is_open()) // read template from disk { FileInfo fi(filePath.str()); - int size=fi.size(); + int size=(int)fi.size(); QCString data(size+1); - if (f.readBlock(data.rawData(),size)==size) + f.read(data.rawData(),size); + if (!f.fail()) { kv = m_templateCache.insert( std::make_pair(fileName.str(), diff --git a/src/template.h b/src/template.h index c9e9041..d611ec3 100644 --- a/src/template.h +++ b/src/template.h @@ -18,8 +18,7 @@ #include <qcstring.h> #include <vector> - -class FTextStream; +#include <iostream> class TemplateListIntf; class TemplateStructIntf; @@ -552,7 +551,7 @@ class Template * @param[in] c The context containing data that can be used * when instantiating the template. */ - virtual void render(FTextStream &ts,TemplateContext *c) = 0; + virtual void render(std::ostream &ts,TemplateContext *c) = 0; }; //------------------------------------------------------------------------ diff --git a/src/textdocvisitor.cpp b/src/textdocvisitor.cpp index b6c90e3..c40cbd9 100644 --- a/src/textdocvisitor.cpp +++ b/src/textdocvisitor.cpp @@ -1,13 +1,13 @@ /****************************************************************************** * - * + * * * * Copyright (C) 1997-2015 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its - * documentation under the terms of the GNU General Public License is hereby - * granted. No representations are made about the suitability of this software + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * @@ -16,7 +16,6 @@ * */ -#include <qdir.h> #include "textdocvisitor.h" #include "message.h" #include "util.h" @@ -52,7 +51,7 @@ void TextDocVisitor::visit(DocEmoji *s) } void TextDocVisitor::filter(const char *str) -{ +{ if (str==0) return; //printf("TextDocVisitor::filter(%s)\n",str); const char *p=str; diff --git a/src/textdocvisitor.h b/src/textdocvisitor.h index e424529..1fa92cc 100644 --- a/src/textdocvisitor.h +++ b/src/textdocvisitor.h @@ -22,14 +22,12 @@ #include "docvisitor.h" #include "docparser.h" #include <qcstring.h> -#include "ftextstream.h" - /*! @brief Concrete visitor implementation for TEXT output. */ class TextDocVisitor : public DocVisitor { public: - TextDocVisitor(FTextStream &t) : DocVisitor(DocVisitor_Text), m_t(t) {} + TextDocVisitor(std::ostream &t) : DocVisitor(DocVisitor_Text), m_t(t) {} //-------------------------------------- // visitor functions for leaf nodes @@ -137,7 +135,7 @@ class TextDocVisitor : public DocVisitor void filter(const char *str); - FTextStream &m_t; + std::ostream &m_t; }; #endif diff --git a/src/util.cpp b/src/util.cpp index 3cdcdfe..b2f8e56 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -28,12 +28,10 @@ #include <ctime> #include <cctype> #include <cinttypes> +#include <sstream> #include "md5.h" -#include <qfileinfo.h> -#include <qdir.h> - #include "regex.h" #include "util.h" #include "message.h" @@ -72,6 +70,7 @@ #include "htmlentity.h" #include "symbolresolver.h" #include "fileinfo.h" +#include "dir.h" #define ENABLE_TRACINGSUPPORT 0 @@ -1404,29 +1403,17 @@ QCString transcodeCharacterStringToUTF8(const QCString &input) QCString fileToString(const char *name,bool filter,bool isSourceCode) { if (name==0 || name[0]==0) return 0; - QFile f; - - bool fileOpened=FALSE; + bool fileOpened=false; if (name[0]=='-' && name[1]==0) // read from stdin { - fileOpened=f.open(IO_ReadOnly,stdin); - if (fileOpened) + fileOpened=true; + std::string contents; + std::string line; + while (getline(std::cin,line)) { - const int bSize=4096; - QCString contents(bSize+1); - int totalSize=0; - int size; - while ((size=f.readBlock(contents.rawData()+totalSize,bSize))==bSize) - { - totalSize+=bSize; - contents.resize(totalSize+bSize+1); - } - totalSize = filterCRLF(contents.rawData(),totalSize+size)+2; - contents.resize(totalSize); - contents.at(totalSize-2)='\n'; // to help the scanner - contents.at(totalSize-1)='\0'; - return contents; + contents+=line+'\n'; } + return contents; } else // read from file { @@ -1436,7 +1423,7 @@ QCString fileToString(const char *name,bool filter,bool isSourceCode) err("file '%s' not found\n",name); return ""; } - BufStr buf(fi.size()); + BufStr buf((uint)fi.size()); fileOpened=readInputFile(name,buf,filter,isSourceCode); if (fileOpened) { @@ -4244,9 +4231,9 @@ QCString convertToPSString(const char *s) QCString convertToLaTeX(const QCString &s,bool insideTabbing,bool keepSpaces) { - QGString result; - FTextStream t(&result); + std::stringstream t; filterLatexString(t,s,insideTabbing,false,false,false,keepSpaces); + QCString result = t.str(); return result.data(); } @@ -4984,7 +4971,7 @@ void addGroupListToTitle(OutputList &ol,const Definition *d) recursivelyAddGroupListToTitle(ol,d,TRUE); } -void filterLatexString(FTextStream &t,const char *str, +void filterLatexString(std::ostream &t,const char *str, bool insideTabbing,bool insidePre,bool insideItem,bool insideTable,bool keepSpaces) { if (str==0) return; @@ -5139,9 +5126,8 @@ void filterLatexString(FTextStream &t,const char *str, QCString latexEscapeLabelName(const char *s) { if (s==0) return ""; - QGString result; QCString tmp(qstrlen(s)+1); - FTextStream t(&result); + std::stringstream t; const char *p=s; char c; int i; @@ -5177,15 +5163,14 @@ QCString latexEscapeLabelName(const char *s) break; } } - return result.data(); + return t.str(); } QCString latexEscapeIndexChars(const char *s) { if (s==0) return ""; - QGString result; QCString tmp(qstrlen(s)+1); - FTextStream t(&result); + std::stringstream t; const char *p=s; char c; int i; @@ -5222,14 +5207,13 @@ QCString latexEscapeIndexChars(const char *s) break; } } - return result.data(); + return t.str(); } QCString latexEscapePDFString(const char *s) { if (s==0) return ""; - QGString result; - FTextStream t(&result); + std::stringstream t; const char *p=s; char c; while ((c=*p++)) @@ -5247,14 +5231,13 @@ QCString latexEscapePDFString(const char *s) break; } } - return result.data(); + return t.str(); } QCString latexFilterURL(const char *s) { if (s==0) return ""; - QGString result; - FTextStream t(&result); + std::stringstream t; const signed char *p=(const signed char*)s; char c; while ((c=*p++)) @@ -5277,7 +5260,7 @@ QCString latexFilterURL(const char *s) break; } } - return result.data(); + return t.str(); } static std::mutex g_rtfFormatMutex; @@ -5712,33 +5695,34 @@ bool checkIfTypedef(const Definition *scope,const FileDef *fileScope,const char return FALSE; } -const char *writeUtf8Char(FTextStream &t,const char *s) +const char *writeUtf8Char(std::ostream &t,const char *s) { + const char *p = s; uchar c=(uchar)*s++; - t << (char)c; if (c>=0x80) // multibyte character { if (((uchar)c&0xE0)==0xC0) { - t << *s++; // 11xx.xxxx: >=2 byte character + s++; // 11xx.xxxx: >=2 byte character } if (((uchar)c&0xF0)==0xE0) { - t << *s++; // 111x.xxxx: >=3 byte character + s++; // 111x.xxxx: >=3 byte character } if (((uchar)c&0xF8)==0xF0) { - t << *s++; // 1111.xxxx: >=4 byte character + s++; // 1111.xxxx: >=4 byte character } if (((uchar)c&0xFC)==0xF8) { - t << *s++; // 1111.1xxx: >=5 byte character + s++; // 1111.1xxx: >=5 byte character } if (((uchar)c&0xFE)==0xFC) { - t << *s++; // 1111.1xxx: 6 byte character + s++; // 1111.1xxx: 6 byte character } } + t.write(p,s-p); return s; } @@ -5811,10 +5795,9 @@ int nextUtf8CharPosition(const QCString &utf8Str,uint len,uint startPos) QCString parseCommentAsText(const Definition *scope,const MemberDef *md, const QCString &doc,const QCString &fileName,int lineNr) { - QGString s; - if (doc.isEmpty()) return s.data(); + if (doc.isEmpty()) return ""; //printf("parseCommentAsText(%s)\n",doc.data()); - FTextStream t(&s); + std::stringstream t; DocNode *root = validatingParseDoc(fileName,lineNr, (Definition*)scope,(MemberDef*)md,doc,FALSE,FALSE, 0,FALSE,FALSE,Config_getBool(MARKDOWN_SUPPORT)); @@ -5822,7 +5805,7 @@ QCString parseCommentAsText(const Definition *scope,const MemberDef *md, root->accept(visitor); delete visitor; delete root; - QCString result = convertCharEntitiesToUTF8(s.data()).stripWhiteSpace(); + QCString result = convertCharEntitiesToUTF8(t.str().c_str()).stripWhiteSpace(); int i=0; int charCnt=0; int l=result.length(); @@ -6235,24 +6218,23 @@ bool readInputFile(const char *fileName,BufStr &inBuf,bool filter,bool isSourceC { // try to open file int size=0; - //uint oldPos = dest.curPos(); - //printf(".......oldPos=%d\n",oldPos); FileInfo fi(fileName); if (!fi.exists()) return FALSE; QCString filterName = getFileFilter(fileName,isSourceCode); if (filterName.isEmpty() || !filter) { - QFile f(fileName); - if (!f.open(IO_ReadOnly)) + std::ifstream f(fileName,std::ifstream::in | std::ifstream::binary); + if (!f.is_open()) { err("could not open file %s\n",fileName); return FALSE; } - size=fi.size(); + size=(int)fi.size(); // read the file inBuf.skip(size); - if (f.readBlock(inBuf.data()/*+oldPos*/,size)!=size) + f.read(inBuf.data(),size); + if (f.fail()) { err("problems while reading file %s\n",fileName); return FALSE; @@ -6384,7 +6366,9 @@ bool patternMatch(const FileInfo &fi,const StringVector &patList) afp = QCString(afp).lower().str(); } reg::Ex re(pattern,reg::Ex::Mode::Wildcard); - found = re.isValid() && (reg::match(fn,re) || reg::match(fp,re) || reg::match(afp,re)); + found = re.isValid() && (reg::match(fn,re) || + (fn!=fp && reg::match(fp,re)) || + (fn!=afp && fp!=afp && reg::match(afp,re))); if (found) break; //printf("Matching '%s' against pattern '%s' found=%d\n", // fi->fileName().data(),pattern.data(),found); @@ -6394,49 +6378,6 @@ bool patternMatch(const FileInfo &fi,const StringVector &patList) return found; } -bool patternMatch(const QFileInfo &fi,const StringVector &patList) -{ - bool caseSenseNames = Config_getBool(CASE_SENSE_NAMES); - bool found = FALSE; - - // For platforms where the file system is non case sensitive overrule the setting - if (!Portable::fileSystemIsCaseSensitive()) - { - caseSenseNames = FALSE; - } - - if (!patList.empty()) - { - std::string fn = fi.fileName().utf8().data(); - std::string fp = fi.filePath().utf8().data(); - std::string afp= fi.absFilePath().utf8().data(); - - for (auto pattern: patList) - { - if (!pattern.empty()) - { - size_t i=pattern.find('='); - if (i!=std::string::npos) pattern=pattern.substr(0,i); // strip of the extension specific filter name - - if (!caseSenseNames) - { - pattern = QCString(pattern).lower().str(); - fn = QCString(fn).lower().str(); - fp = QCString(fp).lower().str(); - afp = QCString(afp).lower().str(); - } - reg::Ex re(pattern,reg::Ex::Mode::Wildcard); - found = re.isValid() && (reg::match(fn,re) || reg::match(fp,re) || reg::match(afp,re)); - if (found) break; - //printf("Matching '%s' against pattern '%s' found=%d\n", - // fi->fileName().data(),pattern.data(),found); - } - } - } - return found; -} - - QCString externalLinkTarget(const bool parent) { static bool extLinksInWindow = Config_getBool(EXT_LINKS_IN_WINDOW); @@ -6486,14 +6427,9 @@ void writeColoredImgData(const char *dir,ColoredImgDataItem data[]) { QCString fileName; fileName=(QCString)dir+"/"+data->name; - QFile f(fileName); - if (f.open(IO_WriteOnly)) - { - ColoredImage img(data->width,data->height,data->content,data->alpha, - sat,hue,gamma); - img.save(fileName); - } - else + ColoredImage img(data->width,data->height,data->content,data->alpha, + sat,hue,gamma); + if (!img.save(fileName)) { fprintf(stderr,"Warning: Cannot open file %s for writing\n",data->name); } @@ -6561,31 +6497,12 @@ QCString replaceColorMarkers(const char *str) */ bool copyFile(const QCString &src,const QCString &dest) { - QFile sf(src); - if (sf.open(IO_ReadOnly)) + if (!Dir().copy(src.str(),dest.str())) { - FileInfo fi(src.str()); - QFile df(dest); - if (df.open(IO_WriteOnly)) - { - char *buffer = new char[fi.size()]; - sf.readBlock(buffer,fi.size()); - df.writeBlock(buffer,fi.size()); - df.flush(); - delete[] buffer; - } - else - { - err("could not write to file %s\n",dest.data()); - return FALSE; - } - } - else - { - err("could not open user specified file %s\n",src.data()); - return FALSE; + err("could not copy file %s to %s\n",src.data(),dest.data()); + return false; } - return TRUE; + return true; } /** Returns the section of text, in between a pair of markers. @@ -7237,13 +7154,14 @@ QCString getDotImageExtension() return i==-1 ? imgExt : imgExt.left(i); } -bool openOutputFile(const char *outFile,QFile &f) +bool openOutputFile(const char *outFile,std::ofstream &f) { bool fileOpened=FALSE; bool writeToStdout=(outFile[0]=='-' && outFile[1]=='\0'); if (writeToStdout) // write to stdout { - fileOpened = f.open(IO_WriteOnly,stdout); + f.basic_ios<char>::rdbuf(std::cout.rdbuf()); + fileOpened = true; } else // write to file { @@ -7256,13 +7174,13 @@ bool openOutputFile(const char *outFile,QFile &f) dir.remove(backup.fileName()); dir.rename(fi.fileName(),fi.fileName()+".bak"); } - f.setName(outFile); - fileOpened = f.open(IO_WriteOnly|IO_Translate); + f.open(outFile,std::ofstream::out | std::ofstream::binary); + fileOpened = f.is_open(); } return fileOpened; } -void writeExtraLatexPackages(FTextStream &t) +void writeExtraLatexPackages(std::ostream &t) { // User-specified packages const StringVector &extraPackages = Config_getList(EXTRA_PACKAGES); @@ -7280,7 +7198,7 @@ void writeExtraLatexPackages(FTextStream &t) } } -void writeLatexSpecialFormulaChars(FTextStream &t) +void writeLatexSpecialFormulaChars(std::ostream &t) { unsigned char minus[4]; // Superscript minus char *pminus = (char *)minus; @@ -26,6 +26,7 @@ #include <unordered_map> #include <algorithm> #include <functional> +#include <fstream> #include <ctype.h> #include "types.h" @@ -56,9 +57,6 @@ class SectionInfo; class Definition; class BufStr; class FileInfo; -class QFileInfo; -class FTextStream; -class QFile; //-------------------------------------------------------------------- @@ -317,7 +315,7 @@ QCString unescapeCharsInString(const char *s); void addGroupListToTitle(OutputList &ol,const Definition *d); -void filterLatexString(FTextStream &t,const char *str, +void filterLatexString(std::ostream &t,const char *str, bool insideTabbing, bool insidePre, bool insideItem, @@ -391,12 +389,11 @@ bool readInputFile(const char *fileName,BufStr &inBuf, QCString filterTitle(const std::string &title); bool patternMatch(const FileInfo &fi,const StringVector &patList); -bool patternMatch(const QFileInfo &fi,const StringVector &patList); QCString externalLinkTarget(const bool parent = false); QCString externalRef(const QCString &relPath,const QCString &ref,bool href); int nextUtf8CharPosition(const QCString &utf8Str,uint len,uint startPos); -const char *writeUtf8Char(FTextStream &t,const char *s); +const char *writeUtf8Char(std::ostream &t,const char *s); void writeMarkerList(OutputList &ol,const std::string &markerText,size_t numMarkers, std::function<void(size_t)> replaceFunc); @@ -456,9 +453,9 @@ void convertProtectionLevel( ); bool mainPageHasTitle(); -bool openOutputFile(const char *outFile,QFile &f); -void writeExtraLatexPackages(FTextStream &t); -void writeLatexSpecialFormulaChars(FTextStream &t); +bool openOutputFile(const char *outFile,std::ofstream &f); +void writeExtraLatexPackages(std::ostream &t); +void writeLatexSpecialFormulaChars(std::ostream &t); StringVector split(const std::string &s,const std::string &delimiter); StringVector split(const std::string &s,const reg::Ex &delimiter); diff --git a/src/vhdlcode.l b/src/vhdlcode.l index c363a23..29a8e0b 100644 --- a/src/vhdlcode.l +++ b/src/vhdlcode.l @@ -37,7 +37,6 @@ #include <stdio.h> #include <assert.h> #include <ctype.h> -#include <qdir.h> #include <qcstringlist.h> #include "vhdlcode.h" diff --git a/src/vhdldocgen.cpp b/src/vhdldocgen.cpp index 7c21e47..87dcd72 100644 --- a/src/vhdldocgen.cpp +++ b/src/vhdldocgen.cpp @@ -72,15 +72,15 @@ static void addInstance(ClassDefMutable* entity, ClassDefMutable* arch, ClassDef //---------- create svg ------------------------------------------------------------- static void createSVG(); -static void startDot(FTextStream &t); -static void startTable(FTextStream &t,const QCString &className); +static void startDot(std::ostream &t); +static void startTable(std::ostream &t,const QCString &className); static std::vector<const MemberDef *> getPorts(const ClassDef *cd); -static void writeVhdlEntityToolTip(FTextStream& t,ClassDef *cd); -static void endDot(FTextStream &t); -static void writeTable(const std::vector<const MemberDef*> &portList,FTextStream & t); -static void endTable(FTextStream &t); -static void writeClassToDot(FTextStream &t,ClassDef* cd); -static void writeVhdlDotLink(FTextStream &t,const QCString &a,const QCString &b,const QCString &style); +static void writeVhdlEntityToolTip(std::ostream& t,ClassDef *cd); +static void endDot(std::ostream &t); +static void writeTable(const std::vector<const MemberDef*> &portList,std::ostream & t); +static void endTable(std::ostream &t); +static void writeClassToDot(std::ostream &t,ClassDef* cd); +static void writeVhdlDotLink(std::ostream &t,const QCString &a,const QCString &b,const QCString &style); static const MemberDef *flowMember=0; void VhdlDocGen::setFlowMember( const MemberDef* mem) @@ -96,7 +96,7 @@ void VhdlDocGen::setFlowMember( const MemberDef* mem) //-------------------------------------------------------------------------------------------------- -static void codify(FTextStream &t,const char *str) +static void codify(std::ostream &t,const char *str) { if (str) { @@ -188,10 +188,8 @@ void VhdlDocGen::writeOverview() QCString ov =Config_getString(HTML_OUTPUT); QCString fileName=ov+"/vhdl_design.dot"; - QFile f(fileName); - FTextStream t(&f); - - if (!f.open(IO_WriteOnly)) + std::ofstream t(fileName.str(),std::ofstream::out | std::ofstream::binary); + if (!t.is_open()) { err("Warning: Cannot open file %s for writing\n",fileName.data()); return; @@ -233,13 +231,13 @@ void VhdlDocGen::writeOverview() endDot(t); // writePortLinks(t); - f.close(); + t.close(); createSVG(); } //------------------------------------------------------------------------------------------------------------------------------------------------------ -static void startDot(FTextStream &t) +static void startDot(std::ostream &t) { t << " digraph G { \n"; t << "rankdir=LR \n"; @@ -247,18 +245,18 @@ static void startDot(FTextStream &t) t << "stylesheet=\"doxygen.css\"\n"; } -static void endDot(FTextStream &t) +static void endDot(std::ostream &t) { t <<" } \n"; } -static void startTable(FTextStream &t,const QCString &className) +static void startTable(std::ostream &t,const QCString &className) { t << className <<" [ shape=none , fontname=\"arial\", fontcolor=\"blue\" , \n"; t << "label=<<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\">\n"; } -static void writeVhdlDotLink(FTextStream &t, +static void writeVhdlDotLink(std::ostream &t, const QCString &a,const QCString &b,const QCString &style) { t << a << "->" << b; @@ -288,7 +286,7 @@ static QCString formatBriefNote(const QCString &brief,ClassDef * cd) return vForm; } -static void writeVhdlEntityToolTip(FTextStream& t,ClassDef *cd) +static void writeVhdlEntityToolTip(std::ostream& t,ClassDef *cd) { QCString brief=cd->briefDescription(); @@ -309,7 +307,7 @@ static void writeVhdlEntityToolTip(FTextStream& t,ClassDef *cd) writeVhdlDotLink(t,dotn,node,"dotted"); } -static void writeColumn(FTextStream &t,const MemberDef *md,bool start) +static void writeColumn(std::ostream &t,const MemberDef *md,bool start) { QCString toolTip; @@ -392,13 +390,13 @@ static void writeColumn(FTextStream &t,const MemberDef *md,bool start) } } -static void endTable(FTextStream &t) +static void endTable(std::ostream &t) { t << "</TABLE>>\n"; t << "] \n"; } -static void writeClassToDot(FTextStream &t,ClassDef* cd) +static void writeClassToDot(std::ostream &t,ClassDef* cd) { t << "<TR><TD COLSPAN=\"2\" BGCOLOR=\"yellow\" "; t << "PORT=\""; @@ -432,9 +430,9 @@ static std::vector<const MemberDef*> getPorts(const ClassDef *cd) return portList; } -//writeColumn(FTextStream &t,QCString name,bool start) +//writeColumn(std::ostream &t,QCString name,bool start) -static void writeTable(const std::vector<const MemberDef*> &portList,FTextStream & t) +static void writeTable(const std::vector<const MemberDef*> &portList,std::ostream & t) { std::vector<const MemberDef *> inPorts; std::vector<const MemberDef *> outPorts; @@ -1691,7 +1689,7 @@ bool VhdlDocGen::writeVHDLTypeDocumentation(const MemberDef* mdef, const Definit return hasParams; } -void VhdlDocGen::writeTagFile(MemberDefMutable *mdef,FTextStream &tagFile) +void VhdlDocGen::writeTagFile(MemberDefMutable *mdef,std::ostream &tagFile) { tagFile << " <member kind=\""; if (VhdlDocGen::isGeneric(mdef)) tagFile << "generic"; @@ -1716,21 +1714,21 @@ void VhdlDocGen::writeTagFile(MemberDefMutable *mdef,FTextStream &tagFile) if (VhdlDocGen::isAlias(mdef)) tagFile << "alias"; if (VhdlDocGen::isCompInst(mdef)) tagFile << "configuration"; - tagFile << "\">" << endl; - tagFile << " <type>" << convertToXML(mdef->typeString()) << "</type>" << endl; - tagFile << " <name>" << convertToXML(mdef->name()) << "</name>" << endl; - tagFile << " <anchorfile>" << convertToXML(mdef->getOutputFileBase()) << Doxygen::htmlFileExtension << "</anchorfile>" << endl; - tagFile << " <anchor>" << convertToXML(mdef->anchor()) << "</anchor>" << endl; + tagFile << "\">\n"; + tagFile << " <type>" << convertToXML(mdef->typeString()) << "</type>\n"; + tagFile << " <name>" << convertToXML(mdef->name()) << "</name>\n"; + tagFile << " <anchorfile>" << convertToXML(mdef->getOutputFileBase()) << Doxygen::htmlFileExtension << "</anchorfile>\n"; + tagFile << " <anchor>" << convertToXML(mdef->anchor()) << "</anchor>\n"; if (VhdlDocGen::isVhdlFunction(mdef)) - tagFile << " <arglist>" << convertToXML(VhdlDocGen::convertArgumentListToString(mdef->argumentList(),TRUE)) << "</arglist>" << endl; + tagFile << " <arglist>" << convertToXML(VhdlDocGen::convertArgumentListToString(mdef->argumentList(),TRUE)) << "</arglist>\n"; else if (VhdlDocGen::isProcedure(mdef)) - tagFile << " <arglist>" << convertToXML(VhdlDocGen::convertArgumentListToString(mdef->argumentList(),FALSE)) << "</arglist>" << endl; + tagFile << " <arglist>" << convertToXML(VhdlDocGen::convertArgumentListToString(mdef->argumentList(),FALSE)) << "</arglist>\n"; else - tagFile << " <arglist>" << convertToXML(mdef->argsString()) << "</arglist>" << endl; + tagFile << " <arglist>" << convertToXML(mdef->argsString()) << "</arglist>\n"; mdef->writeDocAnchorsToTagFile(tagFile); - tagFile << " </member>" << endl; + tagFile << " </member>\n"; } /* writes a vhdl type declaration */ @@ -3051,7 +3049,7 @@ void FlowChart::delFlowList() flowList.clear(); } -void FlowChart::alignCommentNode(FTextStream &t,QCString com) +void FlowChart::alignCommentNode(std::ostream &t,QCString com) { uint max=0; QCString s; @@ -3087,7 +3085,7 @@ void FlowChart::alignCommentNode(FTextStream &t,QCString com) } -void FlowChart::buildCommentNodes(FTextStream & t) +void FlowChart::buildCommentNodes(std::ostream & t) { size_t size=flowList.size(); bool begin=false; @@ -3172,7 +3170,7 @@ void FlowChart::buildCommentNodes(FTextStream & t) }// for; } -void FlowChart::codify(FTextStream &t,const char *str) +void FlowChart::codify(std::ostream &t,const char *str) { if (str) { @@ -3398,7 +3396,7 @@ void FlowChart::createSVG() } } -void FlowChart::startDot(FTextStream &t) +void FlowChart::startDot(std::ostream &t) { t << " digraph G { \n"; t << "rankdir=TB \n"; @@ -3406,7 +3404,7 @@ void FlowChart::startDot(FTextStream &t) t << "stylesheet=\"doxygen.css\"\n"; } -void FlowChart::endDot(FTextStream &t) +void FlowChart::endDot(std::ostream &t) { t << " } \n"; } @@ -3417,10 +3415,8 @@ void FlowChart::writeFlowChart() QCString ov = Config_getString(HTML_OUTPUT); QCString fileName = ov+"/flow_design.dot"; - QFile f(fileName); - FTextStream t(&f); - - if (!f.open(IO_WriteOnly)) + std::ofstream t(fileName.str(),std::ofstream::out | std::ofstream::binary); + if (!t.is_open()) { err("Cannot open file %s for writing\n",fileName.data()); return; @@ -3437,7 +3433,7 @@ void FlowChart::writeFlowChart() { printUmlTree(); delFlowList(); - f.close(); + t.close(); return; } @@ -3451,11 +3447,11 @@ void FlowChart::writeFlowChart() FlowChart::endDot(t); delFlowList(); - f.close(); + t.close(); FlowChart::createSVG(); }// writeFlowChart -void FlowChart::writeShape(FTextStream &t,const FlowChart &fl) +void FlowChart::writeShape(std::ostream &t,const FlowChart &fl) { if (fl.type & EEND) return; QCString var; @@ -3557,7 +3553,7 @@ void FlowChart::writeShape(FTextStream &t,const FlowChart &fl) } -void FlowChart::writeEdge(FTextStream &t,const FlowChart &fl_from,const FlowChart &fl_to,int i) +void FlowChart::writeEdge(std::ostream &t,const FlowChart &fl_from,const FlowChart &fl_to,int i) { bool b=fl_from.type & STARTL; bool c=fl_to.type & STARTL; @@ -3575,7 +3571,7 @@ void FlowChart::writeEdge(FTextStream &t,const FlowChart &fl_from,const FlowChar writeEdge(t,fl_from.id,fl_to.id,i,b,c); } -void FlowChart::writeEdge(FTextStream &t,int fl_from,int fl_to,int i,bool bFrom,bool bTo) +void FlowChart::writeEdge(std::ostream &t,int fl_from,int fl_to,int i,bool bFrom,bool bTo) { QCString label,col; @@ -3767,7 +3763,7 @@ size_t FlowChart::getNextIfLink(const FlowChart &fl,size_t index) return getNextNode(endifNode,stamp); } -void FlowChart::writeFlowLinks(FTextStream &t) +void FlowChart::writeFlowLinks(std::ostream &t) { size_t size=flowList.size(); if (size<2) return; diff --git a/src/vhdldocgen.h b/src/vhdldocgen.h index 3a55b45..04a8489 100644 --- a/src/vhdldocgen.h +++ b/src/vhdldocgen.h @@ -31,7 +31,6 @@ class ClassDef; class MemberList; class MemberDef; class MemberDefMutable; -class FTextStream; class OutputList; class Definition; class GroupDef; @@ -142,7 +141,7 @@ class VhdlDocGen static QCString getClassTitle(const ClassDef*); static void writeInlineClassLink(const ClassDef*, OutputList &ol); - static void writeTagFile(MemberDefMutable *mdef,FTextStream &tagFile); + static void writeTagFile(MemberDefMutable *mdef,std::ostream &tagFile); static bool isConstraint(const MemberDef *mdef); static bool isConfig(const MemberDef *mdef); @@ -229,7 +228,7 @@ class VhdlDocGen // flowcharts static void createFlowChart(const MemberDef*); - //static void addFlowImage(const FTextStream &,const QCString &); + //static void addFlowImage(const std::ostream &,const QCString &); static void setFlowMember( const MemberDef *flowMember); static const MemberDef *getFlowMember(); @@ -289,13 +288,13 @@ class FlowChart //---------- create svg ------------------------------------------------------------- static void createSVG(); - static void startDot(FTextStream &t); - static void endDot(FTextStream &t); - static void codify(FTextStream &t,const char *str); - static void writeShape(FTextStream &t,const FlowChart &fl); - static void writeEdge(FTextStream &t,int fl_from,int fl_to,int i,bool bFrom=FALSE,bool bTo=FALSE); - static void writeEdge(FTextStream &t,const FlowChart &fl_from,const FlowChart &fl_to,int i); - static void writeFlowLinks(FTextStream &t); + static void startDot(std::ostream &t); + static void endDot(std::ostream &t); + static void codify(std::ostream &t,const char *str); + static void writeShape(std::ostream &t,const FlowChart &fl); + static void writeEdge(std::ostream &t,int fl_from,int fl_to,int i,bool bFrom=FALSE,bool bTo=FALSE); + static void writeEdge(std::ostream &t,const FlowChart &fl_from,const FlowChart &fl_to,int i); + static void writeFlowLinks(std::ostream &t); static QCString getNodeName(int n); static void colTextNodes(); @@ -318,8 +317,8 @@ class FlowChart static QCString convertNameToFileName(); static void printNode(const FlowChart& n); static void printFlowTree(); - static void buildCommentNodes(FTextStream &t); - static void alignCommentNode(FTextStream &t,QCString com); + static void buildCommentNodes(std::ostream &t); + static void alignCommentNode(std::ostream &t,QCString com); static void printUmlTree(); static QCString printPlantUmlNode(const FlowChart &flo,bool,bool); diff --git a/src/vhdljjparser.h b/src/vhdljjparser.h index 6942aa0..249842e 100755 --- a/src/vhdljjparser.h +++ b/src/vhdljjparser.h @@ -12,7 +12,6 @@ #include <assert.h> #include <ctype.h> -#include <qfile.h> #include "types.h" #include "entry.h" #include "vhdldocgen.h" diff --git a/src/xmldocvisitor.cpp b/src/xmldocvisitor.cpp index 7387a78..a356682 100644 --- a/src/xmldocvisitor.cpp +++ b/src/xmldocvisitor.cpp @@ -35,7 +35,7 @@ static void visitCaption(XmlDocVisitor *parent, const DocNodeList &children) for (const auto &n : children) n->accept(parent); } -static void visitPreStart(FTextStream &t, const char *cmd, bool doCaption, +static void visitPreStart(std::ostream &t, const char *cmd, bool doCaption, XmlDocVisitor *parent, const DocNodeList &children, const QCString &name, bool writeType, DocImage::Type type, const QCString &width, const QCString &height, const QCString &alt = QCString(""), bool inlineImage = FALSE) @@ -82,12 +82,12 @@ static void visitPreStart(FTextStream &t, const char *cmd, bool doCaption, t << ">"; } -static void visitPostEnd(FTextStream &t, const char *cmd) +static void visitPostEnd(std::ostream &t, const char *cmd) { - t << "</" << cmd << ">" << endl; + t << "</" << cmd << ">\n"; } -XmlDocVisitor::XmlDocVisitor(FTextStream &t,CodeOutputInterface &ci,const char *langExt) +XmlDocVisitor::XmlDocVisitor(std::ostream &t,CodeOutputInterface &ci,const char *langExt) : DocVisitor(DocVisitor_XML), m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE), m_langExt(langExt) { @@ -499,7 +499,7 @@ void XmlDocVisitor::visit(DocIncOperator *op) } else { - if (!m_hide) m_t << endl; + if (!m_hide) m_t << "\n"; } } @@ -590,7 +590,7 @@ void XmlDocVisitor::visitPre(DocPara *) void XmlDocVisitor::visitPost(DocPara *) { if (m_hide) return; - m_t << "</para>" << endl; + m_t << "</para>\n"; } void XmlDocVisitor::visitPre(DocRoot *) @@ -695,10 +695,10 @@ void XmlDocVisitor::visitPre(DocSection *s) if (m_hide) return; m_t << "<sect" << s->level() << " id=\"" << s->file(); if (!s->anchor().isEmpty()) m_t << "_1" << s->anchor(); - m_t << "\">" << endl; + m_t << "\">\n"; m_t << "<title>"; filter(convertCharEntitiesToUTF8(s->title())); - m_t << "</title>" << endl; + m_t << "</title>\n"; } void XmlDocVisitor::visitPost(DocSection *s) @@ -883,7 +883,7 @@ void XmlDocVisitor::visitPre(DocInternal *) void XmlDocVisitor::visitPost(DocInternal *) { if (m_hide) return; - m_t << "</internal>" << endl; + m_t << "</internal>\n"; } void XmlDocVisitor::visitPre(DocHRef *href) @@ -937,19 +937,7 @@ void XmlDocVisitor::visitPre(DocImage *img) bool ambig; if (url.isEmpty() && (fd=findFileDef(Doxygen::imageNameLinkedMap,img->name(),ambig))) { - QFile inImage(fd->absFilePath()); - QFile outImage(Config_getString(XML_OUTPUT)+"/"+baseName.data()); - if (inImage.open(IO_ReadOnly)) - { - if (outImage.open(IO_WriteOnly)) - { - char *buffer = new char[inImage.size()]; - inImage.readBlock(buffer,inImage.size()); - outImage.writeBlock(buffer,inImage.size()); - outImage.flush(); - delete[] buffer; - } - } + copyFile(fd->absFilePath(),Config_getString(XML_OUTPUT)+"/"+baseName.data()); } } @@ -1033,19 +1021,19 @@ void XmlDocVisitor::visitPre(DocSecRefItem *ref) void XmlDocVisitor::visitPost(DocSecRefItem *) { if (m_hide) return; - m_t << "</tocitem>" << endl; + m_t << "</tocitem>\n"; } void XmlDocVisitor::visitPre(DocSecRefList *) { if (m_hide) return; - m_t << "<toclist>" << endl; + m_t << "<toclist>\n"; } void XmlDocVisitor::visitPost(DocSecRefList *) { if (m_hide) return; - m_t << "</toclist>" << endl; + m_t << "</toclist>\n"; } //void XmlDocVisitor::visitPre(DocLanguage *l) @@ -1057,7 +1045,7 @@ void XmlDocVisitor::visitPost(DocSecRefList *) //void XmlDocVisitor::visitPost(DocLanguage *) //{ // if (m_hide) return; -// m_t << "</language>" << endl; +// m_t << "</language>\n"; //} void XmlDocVisitor::visitPre(DocParamSect *s) @@ -1083,14 +1071,14 @@ void XmlDocVisitor::visitPre(DocParamSect *s) void XmlDocVisitor::visitPost(DocParamSect *) { if (m_hide) return; - m_t << "</parameterlist>" << endl; + m_t << "</parameterlist>\n"; } void XmlDocVisitor::visitPre(DocParamList *pl) { if (m_hide) return; - m_t << "<parameteritem>" << endl; - m_t << "<parameternamelist>" << endl; + m_t << "<parameteritem>\n"; + m_t << "<parameternamelist>\n"; for (const auto ¶m : pl->parameters()) { if (!pl->paramTypes().empty()) @@ -1108,11 +1096,11 @@ void XmlDocVisitor::visitPre(DocParamList *pl) } else if (type->kind()==DocNode::Kind_Sep) { - m_t << "</parametertype>" << endl; + m_t << "</parametertype>\n"; m_t << "<parametertype>"; } } - m_t << "</parametertype>" << endl; + m_t << "</parametertype>\n"; } m_t << "<parametername"; if (pl->direction()!=DocParamSect::Unspecified) @@ -1141,17 +1129,17 @@ void XmlDocVisitor::visitPre(DocParamList *pl) { visit((DocLinkedWord*)param.get()); } - m_t << "</parametername>" << endl; + m_t << "</parametername>\n"; } - m_t << "</parameternamelist>" << endl; - m_t << "<parameterdescription>" << endl; + m_t << "</parameternamelist>\n"; + m_t << "<parameterdescription>\n"; } void XmlDocVisitor::visitPost(DocParamList *) { if (m_hide) return; - m_t << "</parameterdescription>" << endl; - m_t << "</parameteritem>" << endl; + m_t << "</parameterdescription>\n"; + m_t << "</parameteritem>\n"; } void XmlDocVisitor::visitPre(DocXRefItem *x) diff --git a/src/xmldocvisitor.h b/src/xmldocvisitor.h index 60270b8..66d0dd4 100644 --- a/src/xmldocvisitor.h +++ b/src/xmldocvisitor.h @@ -21,8 +21,8 @@ #include "docvisitor.h" #include <qcstring.h> +#include <iostream> -class FTextStream; class CodeOutputInterface; class QCString; @@ -30,7 +30,7 @@ class QCString; class XmlDocVisitor : public DocVisitor { public: - XmlDocVisitor(FTextStream &t,CodeOutputInterface &ci,const char *langExt); + XmlDocVisitor(std::ostream &t,CodeOutputInterface &ci,const char *langExt); //-------------------------------------- // visitor functions for leaf nodes @@ -153,7 +153,7 @@ class XmlDocVisitor : public DocVisitor // state variables //-------------------------------------- - FTextStream &m_t; + std::ostream &m_t; CodeOutputInterface &m_ci; bool m_insidePre; bool m_hide; diff --git a/src/xmlgen.cpp b/src/xmlgen.cpp index a4881af..512405c 100644 --- a/src/xmlgen.cpp +++ b/src/xmlgen.cpp @@ -15,8 +15,6 @@ #include <stdlib.h> -#include <qfile.h> - #include "xmlgen.h" #include "doxygen.h" #include "message.h" @@ -107,12 +105,12 @@ static const char *xmlSectionMapper(MemberListType ml) } -inline void writeXMLString(FTextStream &t,const char *s) +inline void writeXMLString(std::ostream &t,const char *s) { t << convertToXML(s); } -inline void writeXMLCodeString(FTextStream &t,const char *s, int &col) +inline void writeXMLCodeString(std::ostream &t,const char *s, int &col) { char c; while ((c=*s++)) @@ -146,28 +144,26 @@ inline void writeXMLCodeString(FTextStream &t,const char *s, int &col) } -static void writeXMLHeader(FTextStream &t) +static void writeXMLHeader(std::ostream &t) { - t << "<?xml version='1.0' encoding='UTF-8' standalone='no'?>" << endl;; + t << "<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n";; t << "<doxygen xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "; t << "xsi:noNamespaceSchemaLocation=\"compound.xsd\" "; t << "version=\"" << getDoxygenVersion() << "\" "; t << "xml:lang=\"" << theTranslator->trISOLang() << "\""; - t << ">" << endl; + t << ">\n"; } static void writeCombineScript() { QCString outputDirectory = Config_getString(XML_OUTPUT); QCString fileName=outputDirectory+"/combine.xslt"; - QFile f(fileName); - if (!f.open(IO_WriteOnly)) + std::ofstream t(fileName.str(),std::ofstream::out | std::ofstream::binary); + if (!t.is_open()) { err("Cannot open file %s for writing!\n",fileName.data()); return; } - FTextStream t(&f); - //t.setEncoding(FTextStream::UnicodeUTF8); t << "<!-- XSLT script to combine the generated output into a single file. \n" @@ -188,7 +184,7 @@ static void writeCombineScript() } -void writeXMLLink(FTextStream &t,const char *extRef,const char *compoundId, +void writeXMLLink(std::ostream &t,const char *extRef,const char *compoundId, const char *anchorId,const char *text,const char *tooltip) { t << "<ref refid=\"" << compoundId; @@ -207,7 +203,7 @@ void writeXMLLink(FTextStream &t,const char *extRef,const char *compoundId, class TextGeneratorXMLImpl : public TextGeneratorIntf { public: - TextGeneratorXMLImpl(FTextStream &t): m_t(t) {} + TextGeneratorXMLImpl(std::ostream &t): m_t(t) {} void writeString(const char *s,bool /*keepSpaces*/) const { writeXMLString(m_t,s); @@ -220,7 +216,7 @@ class TextGeneratorXMLImpl : public TextGeneratorIntf writeXMLLink(m_t,extRef,file,anchor,text,0); } private: - FTextStream &m_t; + std::ostream &m_t; }; //------------------------------------------------------------------------------------------- @@ -291,7 +287,7 @@ void XMLCodeGenerator::endCodeLine() m_t << "</highlight>"; m_normalHLNeedStartTag=TRUE; } - m_t << "</codeline>" << endl; // non DocBook + m_t << "</codeline>\n"; // non DocBook m_lineNumber = -1; m_refId.resize(0); m_external.resize(0); @@ -340,17 +336,17 @@ void XMLCodeGenerator::finish() void XMLCodeGenerator::startCodeFragment(const char *) { - m_t << " <programlisting>" << endl; + m_t << " <programlisting>\n"; } void XMLCodeGenerator::endCodeFragment(const char *) { - m_t << " </programlisting>" << endl; + m_t << " </programlisting>\n"; } //------------------------------------------------------------------------------------------- -static void writeTemplateArgumentList(FTextStream &t, +static void writeTemplateArgumentList(std::ostream &t, const ArgumentList &al, const Definition *scope, const FileDef *fileScope, @@ -360,50 +356,50 @@ static void writeTemplateArgumentList(FTextStream &t, indentStr.fill(' ',indent); if (al.hasParameters()) { - t << indentStr << "<templateparamlist>" << endl; + t << indentStr << "<templateparamlist>\n"; for (const Argument &a : al) { - t << indentStr << " <param>" << endl; + t << indentStr << " <param>\n"; if (!a.type.isEmpty()) { t << indentStr << " <type>"; linkifyText(TextGeneratorXMLImpl(t),scope,fileScope,0,a.type); - t << "</type>" << endl; + t << "</type>\n"; } if (!a.name.isEmpty()) { - t << indentStr << " <declname>" << convertToXML(a.name) << "</declname>" << endl; - t << indentStr << " <defname>" << convertToXML(a.name) << "</defname>" << endl; + t << indentStr << " <declname>" << convertToXML(a.name) << "</declname>\n"; + t << indentStr << " <defname>" << convertToXML(a.name) << "</defname>\n"; } if (!a.defval.isEmpty()) { t << indentStr << " <defval>"; linkifyText(TextGeneratorXMLImpl(t),scope,fileScope,0,a.defval); - t << "</defval>" << endl; + t << "</defval>\n"; } if (!a.typeConstraint.isEmpty()) { t << indentStr << " <typeconstraint>"; linkifyText(TextGeneratorXMLImpl(t),scope,fileScope,0,a.typeConstraint); - t << "</typeconstraint>" << endl; + t << "</typeconstraint>\n"; } - t << indentStr << " </param>" << endl; + t << indentStr << " </param>\n"; } - t << indentStr << "</templateparamlist>" << endl; + t << indentStr << "</templateparamlist>\n"; } } -static void writeMemberTemplateLists(const MemberDef *md,FTextStream &t) +static void writeMemberTemplateLists(const MemberDef *md,std::ostream &t) { writeTemplateArgumentList(t,md->templateArguments(),md->getClassDef(),md->getFileDef(),8); } -static void writeTemplateList(const ClassDef *cd,FTextStream &t) +static void writeTemplateList(const ClassDef *cd,std::ostream &t) { writeTemplateArgumentList(t,cd->templateArguments(),cd,0,4); } -static void writeXMLDocBlock(FTextStream &t, +static void writeXMLDocBlock(std::ostream &t, const QCString &fileName, int lineNr, const Definition *scope, @@ -428,7 +424,7 @@ static void writeXMLDocBlock(FTextStream &t, } -void writeXMLCodeBlock(FTextStream &t,FileDef *fd) +void writeXMLCodeBlock(std::ostream &t,FileDef *fd) { auto intf=Doxygen::parserManager->getCodeParser(fd->getDefFileExtension()); SrcLangExt langExt = getLanguageFromFileName(fd->getDefFileExtension()); @@ -453,7 +449,7 @@ void writeXMLCodeBlock(FTextStream &t,FileDef *fd) delete xmlGen; } -static void writeMemberReference(FTextStream &t,const Definition *def,const MemberDef *rmd,const char *tagName) +static void writeMemberReference(std::ostream &t,const Definition *def,const MemberDef *rmd,const char *tagName) { QCString scope = rmd->getScopeString(); QCString name = rmd->name(); @@ -472,7 +468,7 @@ static void writeMemberReference(FTextStream &t,const Definition *def,const Memb t << " endline=\"" << rmd->getEndBodyLine() << "\""; } } - t << ">" << convertToXML(name) << "</" << tagName << ">" << endl; + t << ">" << convertToXML(name) << "</" << tagName << ">\n"; } @@ -510,7 +506,7 @@ static QCString memberOutputFileBase(const MemberDef *md) } -static void generateXMLForMember(const MemberDef *md,FTextStream &ti,FTextStream &t,const Definition *def) +static void generateXMLForMember(const MemberDef *md,std::ostream &ti,std::ostream &t,const Definition *def) { // + declaration/definition arg lists @@ -558,7 +554,7 @@ static void generateXMLForMember(const MemberDef *md,FTextStream &ti,FTextStream ti << " <member refid=\"" << memberOutputFileBase(md) << "_1" << md->anchor() << "\" kind=\"" << memType << "\"><name>" - << convertToXML(md->name()) << "</name></member>" << endl; + << convertToXML(md->name()) << "</name></member>\n"; QCString scopeName; if (md->getClassDef()) @@ -788,7 +784,7 @@ static void generateXMLForMember(const MemberDef *md,FTextStream &ti,FTextStream t << "\""; } - t << ">" << endl; + t << ">\n"; if (md->memberType()!=MemberType_Define && md->memberType()!=MemberType_Enumeration @@ -799,33 +795,33 @@ static void generateXMLForMember(const MemberDef *md,FTextStream &ti,FTextStream stripQualifiers(typeStr); t << " <type>"; linkifyText(TextGeneratorXMLImpl(t),def,md->getBodyDef(),md,typeStr); - t << "</type>" << endl; - t << " <definition>" << convertToXML(md->definition()) << "</definition>" << endl; - t << " <argsstring>" << convertToXML(md->argsString()) << "</argsstring>" << endl; + t << "</type>\n"; + t << " <definition>" << convertToXML(md->definition()) << "</definition>\n"; + t << " <argsstring>" << convertToXML(md->argsString()) << "</argsstring>\n"; } if (md->memberType() == MemberType_Enumeration) { t << " <type>"; linkifyText(TextGeneratorXMLImpl(t),def,md->getBodyDef(),md,md->enumBaseType()); - t << "</type>" << endl; + t << "</type>\n"; } - t << " <name>" << convertToXML(md->name()) << "</name>" << endl; + t << " <name>" << convertToXML(md->name()) << "</name>\n"; if (md->memberType() == MemberType_Property) { if (md->isReadable()) - t << " <read>" << convertToXML(md->getReadAccessor()) << "</read>" << endl; + t << " <read>" << convertToXML(md->getReadAccessor()) << "</read>\n"; if (md->isWritable()) - t << " <write>" << convertToXML(md->getWriteAccessor()) << "</write>" << endl; + t << " <write>" << convertToXML(md->getWriteAccessor()) << "</write>\n"; } if (md->memberType()==MemberType_Variable && md->bitfieldString()) { QCString bitfield = md->bitfieldString(); if (bitfield.at(0)==':') bitfield=bitfield.mid(1); - t << " <bitfield>" << convertToXML(bitfield) << "</bitfield>" << endl; + t << " <bitfield>" << convertToXML(bitfield) << "</bitfield>\n"; } const MemberDef *rmd = md->reimplements(); @@ -833,22 +829,22 @@ static void generateXMLForMember(const MemberDef *md,FTextStream &ti,FTextStream { t << " <reimplements refid=\"" << memberOutputFileBase(rmd) << "_1" << rmd->anchor() << "\">" - << convertToXML(rmd->name()) << "</reimplements>" << endl; + << convertToXML(rmd->name()) << "</reimplements>\n"; } for (const auto &rbmd : md->reimplementedBy()) { t << " <reimplementedby refid=\"" << memberOutputFileBase(rbmd) << "_1" << rbmd->anchor() << "\">" - << convertToXML(rbmd->name()) << "</reimplementedby>" << endl; + << convertToXML(rbmd->name()) << "</reimplementedby>\n"; } if (md->isFriendClass()) // for friend classes we show a link to the class as a "parameter" { - t << " <param>" << endl; + t << " <param>\n"; t << " <type>"; linkifyText(TextGeneratorXMLImpl(t),def,md->getBodyDef(),md,md->name()); - t << "</type>" << endl; - t << " </param>" << endl; + t << "</type>\n"; + t << " </param>\n"; } else if (isFunc) //function { @@ -866,51 +862,51 @@ static void generateXMLForMember(const MemberDef *md,FTextStream &ti,FTextStream defArg = &(*defIt); ++defIt; } - t << " <param>" << endl; + t << " <param>\n"; if (!a.attrib.isEmpty()) { t << " <attributes>"; writeXMLString(t,a.attrib); - t << "</attributes>" << endl; + t << "</attributes>\n"; } if (!a.type.isEmpty()) { t << " <type>"; linkifyText(TextGeneratorXMLImpl(t),def,md->getBodyDef(),md,a.type); - t << "</type>" << endl; + t << "</type>\n"; } if (!a.name.isEmpty()) { t << " <declname>"; writeXMLString(t,a.name); - t << "</declname>" << endl; + t << "</declname>\n"; } if (defArg && !defArg->name.isEmpty() && defArg->name!=a.name) { t << " <defname>"; writeXMLString(t,defArg->name); - t << "</defname>" << endl; + t << "</defname>\n"; } if (!a.array.isEmpty()) { t << " <array>"; writeXMLString(t,a.array); - t << "</array>" << endl; + t << "</array>\n"; } if (!a.defval.isEmpty()) { t << " <defval>"; linkifyText(TextGeneratorXMLImpl(t),def,md->getBodyDef(),md,a.defval); - t << "</defval>" << endl; + t << "</defval>\n"; } if (defArg && defArg->hasDocumentation()) { t << " <briefdescription>"; writeXMLDocBlock(t,md->getDefFileName(),md->getDefLine(), md->getOuterScope(),md,defArg->docs); - t << "</briefdescription>" << endl; + t << "</briefdescription>\n"; } - t << " </param>" << endl; + t << " </param>\n"; } } } @@ -920,13 +916,13 @@ static void generateXMLForMember(const MemberDef *md,FTextStream &ti,FTextStream if (md->argumentList().empty()) // special case for "foo()" to // distinguish it from "foo". { - t << " <param></param>" << endl; + t << " <param></param>\n"; } else { for (const Argument &a : md->argumentList()) { - t << " <param><defname>" << a.type << "</defname></param>" << endl; + t << " <param><defname>" << a.type << "</defname></param>\n"; } } } @@ -935,14 +931,14 @@ static void generateXMLForMember(const MemberDef *md,FTextStream &ti,FTextStream { t << " <initializer>"; linkifyText(TextGeneratorXMLImpl(t),def,md->getBodyDef(),md,md->initializer()); - t << "</initializer>" << endl; + t << "</initializer>\n"; } if (md->excpString()) { t << " <exceptions>"; linkifyText(TextGeneratorXMLImpl(t),def,md->getBodyDef(),md,md->excpString()); - t << "</exceptions>" << endl; + t << "</exceptions>\n"; } if (md->memberType()==MemberType_Enumeration) // enum @@ -951,7 +947,7 @@ static void generateXMLForMember(const MemberDef *md,FTextStream &ti,FTextStream { ti << " <member refid=\"" << memberOutputFileBase(md) << "_1" << emd->anchor() << "\" kind=\"enumvalue\"><name>" - << convertToXML(emd->name()) << "</name></member>" << endl; + << convertToXML(emd->name()) << "</name></member>\n"; t << " <enumvalue id=\"" << memberOutputFileBase(md) << "_1" << emd->anchor() << "\" prot=\""; @@ -962,34 +958,34 @@ static void generateXMLForMember(const MemberDef *md,FTextStream &ti,FTextStream case Private: t << "private"; break; case Package: t << "package"; break; } - t << "\">" << endl; + t << "\">\n"; t << " <name>"; writeXMLString(t,emd->name()); - t << "</name>" << endl; + t << "</name>\n"; if (!emd->initializer().isEmpty()) { t << " <initializer>"; writeXMLString(t,emd->initializer()); - t << "</initializer>" << endl; + t << "</initializer>\n"; } - t << " <briefdescription>" << endl; + t << " <briefdescription>\n"; writeXMLDocBlock(t,emd->briefFile(),emd->briefLine(),emd->getOuterScope(),emd,emd->briefDescription()); - t << " </briefdescription>" << endl; - t << " <detaileddescription>" << endl; + t << " </briefdescription>\n"; + t << " <detaileddescription>\n"; writeXMLDocBlock(t,emd->docFile(),emd->docLine(),emd->getOuterScope(),emd,emd->documentation()); - t << " </detaileddescription>" << endl; - t << " </enumvalue>" << endl; + t << " </detaileddescription>\n"; + t << " </enumvalue>\n"; } } - t << " <briefdescription>" << endl; + t << " <briefdescription>\n"; writeXMLDocBlock(t,md->briefFile(),md->briefLine(),md->getOuterScope(),md,md->briefDescription()); - t << " </briefdescription>" << endl; - t << " <detaileddescription>" << endl; + t << " </briefdescription>\n"; + t << " <detaileddescription>\n"; writeXMLDocBlock(t,md->docFile(),md->docLine(),md->getOuterScope(),md,md->documentation()); - t << " </detaileddescription>" << endl; - t << " <inbodydescription>" << endl; + t << " </detaileddescription>\n"; + t << " <inbodydescription>\n"; writeXMLDocBlock(t,md->docFile(),md->inbodyLine(),md->getOuterScope(),md,md->inbodyDocumentation()); - t << " </inbodydescription>" << endl; + t << " </inbodydescription>\n"; if (md->getDefLine()!=-1) { t << " <location file=\"" @@ -1012,7 +1008,7 @@ static void generateXMLForMember(const MemberDef *md,FTextStream &ti,FTextStream << md->getDeclLine() << "\" declcolumn=\"" << md->getDeclColumn() << "\""; } - t << "/>" << endl; + t << "/>\n"; } //printf("md->getReferencesMembers()=%p\n",md->getReferencesMembers()); @@ -1027,7 +1023,7 @@ static void generateXMLForMember(const MemberDef *md,FTextStream &ti,FTextStream writeMemberReference(t,def,refmd,"referencedby"); } - t << " </memberdef>" << endl; + t << " </memberdef>\n"; } // namespace members are also inserted in the file scope, but @@ -1039,7 +1035,7 @@ static bool memberVisible(const Definition *d,const MemberDef *md) md->getNamespaceDef()==0; } -static void generateXMLSection(const Definition *d,FTextStream &ti,FTextStream &t, +static void generateXMLSection(const Definition *d,std::ostream &ti,std::ostream &t, const MemberList *ml,const char *kind,const char *header=0, const char *documentation=0) { @@ -1055,16 +1051,16 @@ static void generateXMLSection(const Definition *d,FTextStream &ti,FTextStream & } if (count==0) return; // empty list - t << " <sectiondef kind=\"" << kind << "\">" << endl; + t << " <sectiondef kind=\"" << kind << "\">\n"; if (header) { - t << " <header>" << convertToXML(header) << "</header>" << endl; + t << " <header>" << convertToXML(header) << "</header>\n"; } if (documentation) { t << " <description>"; writeXMLDocBlock(t,d->docFile(),d->docLine(),d,0,documentation); - t << "</description>" << endl; + t << "</description>\n"; } for (const auto &md : *ml) { @@ -1073,12 +1069,12 @@ static void generateXMLSection(const Definition *d,FTextStream &ti,FTextStream & generateXMLForMember(md,ti,t,d); } } - t << " </sectiondef>" << endl; + t << " </sectiondef>\n"; } -static void writeListOfAllMembers(const ClassDef *cd,FTextStream &t) +static void writeListOfAllMembers(const ClassDef *cd,std::ostream &t) { - t << " <listofallmembers>" << endl; + t << " <listofallmembers>\n"; for (auto &mni : cd->memberNameInfoLinkedMap()) { for (auto &mi : *mni) @@ -1110,14 +1106,14 @@ static void writeListOfAllMembers(const ClassDef *cd,FTextStream &t) t << " ambiguityscope=\"" << convertToXML(mi->ambiguityResolutionScope()) << "\""; } t << "><scope>" << convertToXML(cd->name()) << "</scope><name>" << - convertToXML(md->name()) << "</name></member>" << endl; + convertToXML(md->name()) << "</name></member>\n"; } } } - t << " </listofallmembers>" << endl; + t << " </listofallmembers>\n"; } -static void writeInnerClasses(const ClassLinkedRefMap &cl,FTextStream &t) +static void writeInnerClasses(const ClassLinkedRefMap &cl,std::ostream &t) { for (const auto &cd : cl) { @@ -1132,12 +1128,12 @@ static void writeInnerClasses(const ClassLinkedRefMap &cl,FTextStream &t) case Private: t << "private"; break; case Package: t << "package"; break; } - t << "\">" << convertToXML(cd->name()) << "</innerclass>" << endl; + t << "\">" << convertToXML(cd->name()) << "</innerclass>\n"; } } } -static void writeInnerNamespaces(const NamespaceLinkedRefMap &nl,FTextStream &t) +static void writeInnerNamespaces(const NamespaceLinkedRefMap &nl,std::ostream &t) { for (const auto &nd : nl) { @@ -1145,21 +1141,21 @@ static void writeInnerNamespaces(const NamespaceLinkedRefMap &nl,FTextStream &t) { t << " <innernamespace refid=\"" << nd->getOutputFileBase() << "\"" << (nd->isInline() ? " inline=\"yes\"" : "") - << ">" << convertToXML(nd->name()) << "</innernamespace>" << endl; + << ">" << convertToXML(nd->name()) << "</innernamespace>\n"; } } } -static void writeInnerFiles(const FileList &fl,FTextStream &t) +static void writeInnerFiles(const FileList &fl,std::ostream &t) { for (const auto &fd : fl) { t << " <innerfile refid=\"" << fd->getOutputFileBase() - << "\">" << convertToXML(fd->name()) << "</innerfile>" << endl; + << "\">" << convertToXML(fd->name()) << "</innerfile>\n"; } } -static void writeInnerPages(const PageLinkedRefMap &pl,FTextStream &t) +static void writeInnerPages(const PageLinkedRefMap &pl,std::ostream &t) { for (const auto &pd : pl) { @@ -1168,33 +1164,33 @@ static void writeInnerPages(const PageLinkedRefMap &pl,FTextStream &t) { t << "_" << pd->name(); } - t << "\">" << convertToXML(pd->title()) << "</innerpage>" << endl; + t << "\">" << convertToXML(pd->title()) << "</innerpage>\n"; } } -static void writeInnerGroups(const GroupList &gl,FTextStream &t) +static void writeInnerGroups(const GroupList &gl,std::ostream &t) { for (const auto &sgd : gl) { t << " <innergroup refid=\"" << sgd->getOutputFileBase() << "\">" << convertToXML(sgd->groupTitle()) - << "</innergroup>" << endl; + << "</innergroup>\n"; } } -static void writeInnerDirs(const DirList *dl,FTextStream &t) +static void writeInnerDirs(const DirList *dl,std::ostream &t) { if (dl) { for(const auto subdir : *dl) { t << " <innerdir refid=\"" << subdir->getOutputFileBase() - << "\">" << convertToXML(subdir->displayName()) << "</innerdir>" << endl; + << "\">" << convertToXML(subdir->displayName()) << "</innerdir>\n"; } } } -static void generateXMLForClass(const ClassDef *cd,FTextStream &ti) +static void generateXMLForClass(const ClassDef *cd,std::ostream &ti) { // + brief description // + detailed description @@ -1222,18 +1218,16 @@ static void generateXMLForClass(const ClassDef *cd,FTextStream &ti) ti << " <compound refid=\"" << classOutputFileBase(cd) << "\" kind=\"" << cd->compoundTypeString() - << "\"><name>" << convertToXML(cd->name()) << "</name>" << endl; + << "\"><name>" << convertToXML(cd->name()) << "</name>\n"; QCString outputDirectory = Config_getString(XML_OUTPUT); QCString fileName=outputDirectory+"/"+ classOutputFileBase(cd)+".xml"; - QFile f(fileName); - if (!f.open(IO_WriteOnly)) + std::ofstream t(fileName.str(),std::ofstream::out | std::ofstream::binary); + if (!t.is_open()) { err("Cannot open file %s for writing!\n",fileName.data()); return; } - FTextStream t(&f); - //t.setEncoding(FTextStream::UnicodeUTF8); writeXMLHeader(t); t << " <compounddef id=\"" @@ -1250,10 +1244,10 @@ static void generateXMLForClass(const ClassDef *cd,FTextStream &ti) if (cd->isFinal()) t << "\" final=\"yes"; if (cd->isSealed()) t << "\" sealed=\"yes"; if (cd->isAbstract()) t << "\" abstract=\"yes"; - t << "\">" << endl; + t << "\">\n"; t << " <compoundname>"; writeXMLString(t,cd->name()); - t << "</compoundname>" << endl; + t << "</compoundname>\n"; for (const auto &bcd : cd->baseClasses()) { t << " <basecompoundref "; @@ -1288,7 +1282,7 @@ static void generateXMLForClass(const ClassDef *cd,FTextStream &ti) { t << convertToXML(bcd.classDef->displayName()); } - t << "</basecompoundref>" << endl; + t << "</basecompoundref>\n"; } for (const auto &bcd : cd->subClasses()) { @@ -1310,7 +1304,7 @@ static void generateXMLForClass(const ClassDef *cd,FTextStream &ti) case Pure: t << "pure-virtual"; break; } t << "\">" << convertToXML(bcd.classDef->displayName()) - << "</derivedcompoundref>" << endl; + << "</derivedcompoundref>\n"; } const IncludeInfo *ii=cd->includeInfo(); @@ -1327,7 +1321,7 @@ static void generateXMLForClass(const ClassDef *cd,FTextStream &ti) } t << " local=\"" << (ii->local ? "yes" : "no") << "\">"; t << nm; - t << "</includes>" << endl; + t << "</includes>\n"; } } @@ -1348,25 +1342,25 @@ static void generateXMLForClass(const ClassDef *cd,FTextStream &ti) } } - t << " <briefdescription>" << endl; + t << " <briefdescription>\n"; writeXMLDocBlock(t,cd->briefFile(),cd->briefLine(),cd,0,cd->briefDescription()); - t << " </briefdescription>" << endl; - t << " <detaileddescription>" << endl; + t << " </briefdescription>\n"; + t << " <detaileddescription>\n"; writeXMLDocBlock(t,cd->docFile(),cd->docLine(),cd,0,cd->documentation()); - t << " </detaileddescription>" << endl; + t << " </detaileddescription>\n"; DotClassGraph inheritanceGraph(cd,Inheritance); if (!inheritanceGraph.isTrivial()) { - t << " <inheritancegraph>" << endl; + t << " <inheritancegraph>\n"; inheritanceGraph.writeXML(t); - t << " </inheritancegraph>" << endl; + t << " </inheritancegraph>\n"; } DotClassGraph collaborationGraph(cd,Collaboration); if (!collaborationGraph.isTrivial()) { - t << " <collaborationgraph>" << endl; + t << " <collaborationgraph>\n"; collaborationGraph.writeXML(t); - t << " </collaborationgraph>" << endl; + t << " </collaborationgraph>\n"; } t << " <location file=\"" << convertToXML(stripFromPath(cd->getDefFileName())) << "\" line=\"" @@ -1382,15 +1376,15 @@ static void generateXMLForClass(const ClassDef *cd,FTextStream &ti) t << " bodystart=\"" << cd->getStartBodyLine() << "\" bodyend=\"" << cd->getEndBodyLine() << "\""; } - t << "/>" << endl; + t << "/>\n"; writeListOfAllMembers(cd,t); - t << " </compounddef>" << endl; - t << "</doxygen>" << endl; + t << " </compounddef>\n"; + t << "</doxygen>\n"; - ti << " </compound>" << endl; + ti << " </compound>\n"; } -static void generateXMLForNamespace(const NamespaceDef *nd,FTextStream &ti) +static void generateXMLForNamespace(const NamespaceDef *nd,std::ostream &ti) { // + contained class definitions // + contained namespace definitions @@ -1405,28 +1399,26 @@ static void generateXMLForNamespace(const NamespaceDef *nd,FTextStream &ti) ti << " <compound refid=\"" << nd->getOutputFileBase() << "\" kind=\"namespace\"" << "><name>" - << convertToXML(nd->name()) << "</name>" << endl; + << convertToXML(nd->name()) << "</name>\n"; QCString outputDirectory = Config_getString(XML_OUTPUT); QCString fileName=outputDirectory+"/"+nd->getOutputFileBase()+".xml"; - QFile f(fileName); - if (!f.open(IO_WriteOnly)) + std::ofstream t(fileName.str(),std::ofstream::out | std::ofstream::binary); + if (!t.is_open()) { err("Cannot open file %s for writing!\n",fileName.data()); return; } - FTextStream t(&f); - //t.setEncoding(FTextStream::UnicodeUTF8); writeXMLHeader(t); t << " <compounddef id=\"" << nd->getOutputFileBase() << "\" kind=\"namespace\" " << (nd->isInline()?"inline=\"yes\" ":"") << "language=\"" - << langToString(nd->getLanguage()) << "\">" << endl; + << langToString(nd->getLanguage()) << "\">\n"; t << " <compoundname>"; writeXMLString(t,nd->name()); - t << "</compoundname>" << endl; + t << "</compoundname>\n"; writeInnerClasses(nd->getClasses(),t); writeInnerNamespaces(nd->getNamespaces(),t); @@ -1445,23 +1437,23 @@ static void generateXMLForNamespace(const NamespaceDef *nd,FTextStream &ti) } } - t << " <briefdescription>" << endl; + t << " <briefdescription>\n"; writeXMLDocBlock(t,nd->briefFile(),nd->briefLine(),nd,0,nd->briefDescription()); - t << " </briefdescription>" << endl; - t << " <detaileddescription>" << endl; + t << " </briefdescription>\n"; + t << " <detaileddescription>\n"; writeXMLDocBlock(t,nd->docFile(),nd->docLine(),nd,0,nd->documentation()); - t << " </detaileddescription>" << endl; + t << " </detaileddescription>\n"; t << " <location file=\"" << convertToXML(stripFromPath(nd->getDefFileName())) << "\" line=\"" << nd->getDefLine() << "\"" << " column=\"" - << nd->getDefColumn() << "\"/>" << endl ; - t << " </compounddef>" << endl; - t << "</doxygen>" << endl; + << nd->getDefColumn() << "\"/>\n" ; + t << " </compounddef>\n"; + t << "</doxygen>\n"; - ti << " </compound>" << endl; + ti << " </compound>\n"; } -static void generateXMLForFile(FileDef *fd,FTextStream &ti) +static void generateXMLForFile(FileDef *fd,std::ostream &ti) { // + includes files // + includedby files @@ -1481,26 +1473,24 @@ static void generateXMLForFile(FileDef *fd,FTextStream &ti) ti << " <compound refid=\"" << fd->getOutputFileBase() << "\" kind=\"file\"><name>" << convertToXML(fd->name()) - << "</name>" << endl; + << "</name>\n"; QCString outputDirectory = Config_getString(XML_OUTPUT); QCString fileName=outputDirectory+"/"+fd->getOutputFileBase()+".xml"; - QFile f(fileName); - if (!f.open(IO_WriteOnly)) + std::ofstream t(fileName.str(),std::ofstream::out | std::ofstream::binary); + if (!t.is_open()) { err("Cannot open file %s for writing!\n",fileName.data()); return; } - FTextStream t(&f); - //t.setEncoding(FTextStream::UnicodeUTF8); writeXMLHeader(t); t << " <compounddef id=\"" << fd->getOutputFileBase() << "\" kind=\"file\" language=\"" - << langToString(fd->getLanguage()) << "\">" << endl; + << langToString(fd->getLanguage()) << "\">\n"; t << " <compoundname>"; writeXMLString(t,fd->name()); - t << "</compoundname>" << endl; + t << "</compoundname>\n"; for (const auto &inc : fd->includeFileList()) { @@ -1511,7 +1501,7 @@ static void generateXMLForFile(FileDef *fd,FTextStream &ti) } t << " local=\"" << (inc.local ? "yes" : "no") << "\">"; t << inc.includeName; - t << "</includes>" << endl; + t << "</includes>\n"; } for (const auto &inc : fd->includedByFileList()) @@ -1523,23 +1513,23 @@ static void generateXMLForFile(FileDef *fd,FTextStream &ti) } t << " local=\"" << (inc.local ? "yes" : "no") << "\">"; t << inc.includeName; - t << "</includedby>" << endl; + t << "</includedby>\n"; } DotInclDepGraph incDepGraph(fd,FALSE); if (!incDepGraph.isTrivial()) { - t << " <incdepgraph>" << endl; + t << " <incdepgraph>\n"; incDepGraph.writeXML(t); - t << " </incdepgraph>" << endl; + t << " </incdepgraph>\n"; } DotInclDepGraph invIncDepGraph(fd,TRUE); if (!invIncDepGraph.isTrivial()) { - t << " <invincdepgraph>" << endl; + t << " <invincdepgraph>\n"; invIncDepGraph.writeXML(t); - t << " </invincdepgraph>" << endl; + t << " </invincdepgraph>\n"; } writeInnerClasses(fd->getClasses(),t); @@ -1559,24 +1549,24 @@ static void generateXMLForFile(FileDef *fd,FTextStream &ti) } } - t << " <briefdescription>" << endl; + t << " <briefdescription>\n"; writeXMLDocBlock(t,fd->briefFile(),fd->briefLine(),fd,0,fd->briefDescription()); - t << " </briefdescription>" << endl; - t << " <detaileddescription>" << endl; + t << " </briefdescription>\n"; + t << " <detaileddescription>\n"; writeXMLDocBlock(t,fd->docFile(),fd->docLine(),fd,0,fd->documentation()); - t << " </detaileddescription>" << endl; + t << " </detaileddescription>\n"; if (Config_getBool(XML_PROGRAMLISTING)) { writeXMLCodeBlock(t,fd); } - t << " <location file=\"" << convertToXML(stripFromPath(fd->getDefFileName())) << "\"/>" << endl; - t << " </compounddef>" << endl; - t << "</doxygen>" << endl; + t << " <location file=\"" << convertToXML(stripFromPath(fd->getDefFileName())) << "\"/>\n"; + t << " </compounddef>\n"; + t << "</doxygen>\n"; - ti << " </compound>" << endl; + ti << " </compound>\n"; } -static void generateXMLForGroup(const GroupDef *gd,FTextStream &ti) +static void generateXMLForGroup(const GroupDef *gd,std::ostream &ti) { // + members // + member groups @@ -1593,24 +1583,22 @@ static void generateXMLForGroup(const GroupDef *gd,FTextStream &ti) if (gd->isReference()) return; // skip external references ti << " <compound refid=\"" << gd->getOutputFileBase() - << "\" kind=\"group\"><name>" << convertToXML(gd->name()) << "</name>" << endl; + << "\" kind=\"group\"><name>" << convertToXML(gd->name()) << "</name>\n"; QCString outputDirectory = Config_getString(XML_OUTPUT); QCString fileName=outputDirectory+"/"+gd->getOutputFileBase()+".xml"; - QFile f(fileName); - if (!f.open(IO_WriteOnly)) + std::ofstream t(fileName.str(),std::ofstream::out | std::ofstream::binary); + if (!t.is_open()) { err("Cannot open file %s for writing!\n",fileName.data()); return; } - FTextStream t(&f); - //t.setEncoding(FTextStream::UnicodeUTF8); writeXMLHeader(t); t << " <compounddef id=\"" - << gd->getOutputFileBase() << "\" kind=\"group\">" << endl; - t << " <compoundname>" << convertToXML(gd->name()) << "</compoundname>" << endl; - t << " <title>" << convertToXML(gd->groupTitle()) << "</title>" << endl; + << gd->getOutputFileBase() << "\" kind=\"group\">\n"; + t << " <compoundname>" << convertToXML(gd->name()) << "</compoundname>\n"; + t << " <title>" << convertToXML(gd->groupTitle()) << "</title>\n"; writeInnerFiles(gd->getFiles(),t); writeInnerClasses(gd->getClasses(),t); @@ -1632,58 +1620,56 @@ static void generateXMLForGroup(const GroupDef *gd,FTextStream &ti) } } - t << " <briefdescription>" << endl; + t << " <briefdescription>\n"; writeXMLDocBlock(t,gd->briefFile(),gd->briefLine(),gd,0,gd->briefDescription()); - t << " </briefdescription>" << endl; - t << " <detaileddescription>" << endl; + t << " </briefdescription>\n"; + t << " <detaileddescription>\n"; writeXMLDocBlock(t,gd->docFile(),gd->docLine(),gd,0,gd->documentation()); - t << " </detaileddescription>" << endl; - t << " </compounddef>" << endl; - t << "</doxygen>" << endl; + t << " </detaileddescription>\n"; + t << " </compounddef>\n"; + t << "</doxygen>\n"; - ti << " </compound>" << endl; + ti << " </compound>\n"; } -static void generateXMLForDir(DirDef *dd,FTextStream &ti) +static void generateXMLForDir(DirDef *dd,std::ostream &ti) { if (dd->isReference()) return; // skip external references ti << " <compound refid=\"" << dd->getOutputFileBase() << "\" kind=\"dir\"><name>" << convertToXML(dd->displayName()) - << "</name>" << endl; + << "</name>\n"; QCString outputDirectory = Config_getString(XML_OUTPUT); QCString fileName=outputDirectory+"/"+dd->getOutputFileBase()+".xml"; - QFile f(fileName); - if (!f.open(IO_WriteOnly)) + std::ofstream t(fileName.str(),std::ofstream::out | std::ofstream::binary); + if (!t.is_open()) { err("Cannot open file %s for writing!\n",fileName.data()); return; } - FTextStream t(&f); - //t.setEncoding(FTextStream::UnicodeUTF8); writeXMLHeader(t); t << " <compounddef id=\"" - << dd->getOutputFileBase() << "\" kind=\"dir\">" << endl; - t << " <compoundname>" << convertToXML(dd->displayName()) << "</compoundname>" << endl; + << dd->getOutputFileBase() << "\" kind=\"dir\">\n"; + t << " <compoundname>" << convertToXML(dd->displayName()) << "</compoundname>\n"; writeInnerDirs(&dd->subDirs(),t); writeInnerFiles(dd->getFiles(),t); - t << " <briefdescription>" << endl; + t << " <briefdescription>\n"; writeXMLDocBlock(t,dd->briefFile(),dd->briefLine(),dd,0,dd->briefDescription()); - t << " </briefdescription>" << endl; - t << " <detaileddescription>" << endl; + t << " </briefdescription>\n"; + t << " <detaileddescription>\n"; writeXMLDocBlock(t,dd->docFile(),dd->docLine(),dd,0,dd->documentation()); - t << " </detaileddescription>" << endl; - t << " <location file=\"" << convertToXML(stripFromPath(dd->name())) << "\"/>" << endl; - t << " </compounddef>" << endl; - t << "</doxygen>" << endl; + t << " </detaileddescription>\n"; + t << " <location file=\"" << convertToXML(stripFromPath(dd->name())) << "\"/>\n"; + t << " </compounddef>\n"; + t << "</doxygen>\n"; - ti << " </compound>" << endl; + ti << " </compound>\n"; } -static void generateXMLForPage(PageDef *pd,FTextStream &ti,bool isExample) +static void generateXMLForPage(PageDef *pd,std::ostream &ti,bool isExample) { // + name // + title @@ -1703,24 +1689,22 @@ static void generateXMLForPage(PageDef *pd,FTextStream &ti,bool isExample) ti << " <compound refid=\"" << pageName << "\" kind=\"" << kindName << "\"><name>" << convertToXML(pd->name()) - << "</name>" << endl; + << "</name>\n"; QCString outputDirectory = Config_getString(XML_OUTPUT); QCString fileName=outputDirectory+"/"+pageName+".xml"; - QFile f(fileName); - if (!f.open(IO_WriteOnly)) + std::ofstream t(fileName.str(),std::ofstream::out | std::ofstream::binary); + if (!t.is_open()) { err("Cannot open file %s for writing!\n",fileName.data()); return; } - FTextStream t(&f); - //t.setEncoding(FTextStream::UnicodeUTF8); writeXMLHeader(t); t << " <compounddef id=\"" << pageName; - t << "\" kind=\"" << kindName << "\">" << endl; + t << "\" kind=\"" << kindName << "\">\n"; t << " <compoundname>" << convertToXML(pd->name()) - << "</compoundname>" << endl; + << "</compoundname>\n"; if (pd==Doxygen::mainPage.get()) // main page is special { @@ -1734,7 +1718,7 @@ static void generateXMLForPage(PageDef *pd,FTextStream &ti,bool isExample) title = Config_getString(PROJECT_NAME); } t << " <title>" << convertToXML(convertCharEntitiesToUTF8(title)) - << "</title>" << endl; + << "</title>\n"; } else { @@ -1742,14 +1726,14 @@ static void generateXMLForPage(PageDef *pd,FTextStream &ti,bool isExample) if (si) { t << " <title>" << convertToXML(filterTitle(convertCharEntitiesToUTF8(si->title()).str())) - << "</title>" << endl; + << "</title>\n"; } } writeInnerPages(pd->getSubPages(),t); const SectionRefs §ionRefs = pd->getSectionRefs(); if (pd->localToc().isXmlEnabled() && !sectionRefs.empty()) { - t << " <tableofcontents>" << endl; + t << " <tableofcontents>\n"; int level=1,l; bool inLi[5]={ FALSE, FALSE, FALSE, FALSE, FALSE }; int maxLevel = pd->localToc().xmlLevel(); @@ -1763,25 +1747,25 @@ static void generateXMLForPage(PageDef *pd,FTextStream &ti,bool isExample) { for (l=level;l<nextLevel;l++) { - if (l < maxLevel) t << " <tableofcontents>" << endl; + if (l < maxLevel) t << " <tableofcontents>\n"; } } else if (nextLevel<level) { for (l=level;l>nextLevel;l--) { - if (l <= maxLevel && inLi[l]) t << " </tocsect>" << endl; + if (l <= maxLevel && inLi[l]) t << " </tocsect>\n"; inLi[l]=FALSE; - if (l <= maxLevel) t << " </tableofcontents>" << endl; + if (l <= maxLevel) t << " </tableofcontents>\n"; } } if (nextLevel <= maxLevel) { - if (inLi[nextLevel]) t << " </tocsect>" << endl; + if (inLi[nextLevel]) t << " </tocsect>\n"; QCString titleDoc = convertToXML(si->title()); - t << " <tocsect>" << endl; - t << " <name>" << (si->title().isEmpty()?si->label():titleDoc) << "</name>" << endl; - t << " <reference>" << convertToXML(pageName) << "_1" << convertToXML(si->label()) << "</reference>" << endl; + t << " <tocsect>\n"; + t << " <name>" << (si->title().isEmpty()?si->label():titleDoc) << "</name>\n"; + t << " <reference>" << convertToXML(pageName) << "_1" << convertToXML(si->label()) << "</reference>\n"; inLi[nextLevel]=TRUE; level = nextLevel; } @@ -1789,19 +1773,19 @@ static void generateXMLForPage(PageDef *pd,FTextStream &ti,bool isExample) } while (level>1 && level <= maxLevel) { - if (inLi[level]) t << " </tocsect>" << endl; + if (inLi[level]) t << " </tocsect>\n"; inLi[level]=FALSE; - t << " </tableofcontents>" << endl; + t << " </tableofcontents>\n"; level--; } - if (level <= maxLevel && inLi[level]) t << " </tocsect>" << endl; + if (level <= maxLevel && inLi[level]) t << " </tocsect>\n"; inLi[level]=FALSE; - t << " </tableofcontents>" << endl; + t << " </tableofcontents>\n"; } - t << " <briefdescription>" << endl; + t << " <briefdescription>\n"; writeXMLDocBlock(t,pd->briefFile(),pd->briefLine(),pd,0,pd->briefDescription()); - t << " </briefdescription>" << endl; - t << " <detaileddescription>" << endl; + t << " </briefdescription>\n"; + t << " <detaileddescription>\n"; if (isExample) { writeXMLDocBlock(t,pd->docFile(),pd->docLine(),pd,0, @@ -1812,14 +1796,14 @@ static void generateXMLForPage(PageDef *pd,FTextStream &ti,bool isExample) writeXMLDocBlock(t,pd->docFile(),pd->docLine(),pd,0, pd->documentation()); } - t << " </detaileddescription>" << endl; + t << " </detaileddescription>\n"; - t << " <location file=\"" << convertToXML(stripFromPath(pd->getDefFileName())) << "\"/>" << endl; + t << " <location file=\"" << convertToXML(stripFromPath(pd->getDefFileName())) << "\"/>\n"; - t << " </compounddef>" << endl; - t << "</doxygen>" << endl; + t << " </compounddef>\n"; + t << "</doxygen>\n"; - ti << " </compound>" << endl; + ti << " </compound>\n"; } void generateXML() @@ -1839,8 +1823,8 @@ void generateXML() ResourceMgr::instance().copyResource("index.xsd",outputDirectory); QCString fileName=outputDirectory+"/compound.xsd"; - QFile f(fileName); - if (!f.open(IO_WriteOnly)) + std::ofstream t(fileName.str(),std::ofstream::out | std::ofstream::binary); + if (!t.is_open()) { err("Cannot open file %s for writing!\n",fileName.data()); return; @@ -1862,35 +1846,33 @@ void generateXML() s[len]='\0'; if (s.find("<!-- Automatically insert here the HTML entities -->")!=-1) { - FTextStream t(&f); HtmlEntityMapper::instance()->writeXMLSchema(t); } else { - f.writeBlock(startLine,len); + t.write(startLine,len); } } startLine=endLine; } - f.close(); + t.close(); fileName=outputDirectory+"/index.xml"; - f.setName(fileName); - if (!f.open(IO_WriteOnly)) + t.open(fileName.str(),std::ofstream::out | std::ofstream::binary); + if (!t.is_open()) { err("Cannot open file %s for writing!\n",fileName.data()); return; } - FTextStream t(&f); - //t.setEncoding(FTextStream::UnicodeUTF8); + //t.setEncoding(std::ostream::UnicodeUTF8); // write index header - t << "<?xml version='1.0' encoding='UTF-8' standalone='no'?>" << endl;; + t << "<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n";; t << "<doxygenindex xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "; t << "xsi:noNamespaceSchemaLocation=\"index.xsd\" "; t << "version=\"" << getDoxygenVersion() << "\" "; t << "xml:lang=\"" << theTranslator->trISOLang() << "\""; - t << ">" << endl; + t << ">\n"; for (const auto &cd : *Doxygen::classLinkedMap) { @@ -1935,8 +1917,8 @@ void generateXML() generateXMLForPage(Doxygen::mainPage.get(),t,FALSE); } - //t << " </compoundlist>" << endl; - t << "</doxygenindex>" << endl; + //t << " </compoundlist>\n"; + t << "</doxygenindex>\n"; writeCombineScript(); } diff --git a/src/xmlgen.h b/src/xmlgen.h index 27bb10b..58f9a64 100644 --- a/src/xmlgen.h +++ b/src/xmlgen.h @@ -19,7 +19,7 @@ class XMLCodeGenerator : public CodeOutputInterface { public: - XMLCodeGenerator(FTextStream &t) : m_t(t), m_lineNumber(-1), m_isMemberRef(FALSE), m_col(0), + XMLCodeGenerator(std::ostream &t) : m_t(t), m_lineNumber(-1), m_isMemberRef(FALSE), m_col(0), m_insideCodeLine(FALSE), m_normalHLNeedStartTag(TRUE), m_insideSpecialHL(FALSE) {} virtual ~XMLCodeGenerator() { } @@ -45,7 +45,7 @@ class XMLCodeGenerator : public CodeOutputInterface void finish(); private: - FTextStream &m_t; + std::ostream &m_t; QCString m_refId; QCString m_external; int m_lineNumber; |