summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bufstr.h1
-rw-r--r--src/commentcnv.l1
-rw-r--r--src/commentscan.l2
-rw-r--r--src/defgen.cpp1
-rw-r--r--src/docbookgen.cpp1
-rw-r--r--src/doxygen.cpp1
-rw-r--r--src/formula.cpp72
-rw-r--r--src/formula.h11
-rw-r--r--src/index.cpp1
-rw-r--r--src/xmlgen.cpp1
10 files changed, 37 insertions, 55 deletions
diff --git a/src/bufstr.h b/src/bufstr.h
index ca733ad..fcdce6b 100644
--- a/src/bufstr.h
+++ b/src/bufstr.h
@@ -19,6 +19,7 @@
#define _BUFSTR_H
#include <cstdlib>
+#include <qcstring.h>
/*! @brief Buffer used to store strings
*
diff --git a/src/commentcnv.l b/src/commentcnv.l
index d3b5362..cacbffa 100644
--- a/src/commentcnv.l
+++ b/src/commentcnv.l
@@ -29,7 +29,6 @@
#include <stdlib.h>
#include <stack>
-#include <qtextstream.h>
#include <qglobal.h>
#include "bufstr.h"
diff --git a/src/commentscan.l b/src/commentscan.l
index c17d9f6..89b8052 100644
--- a/src/commentscan.l
+++ b/src/commentscan.l
@@ -2918,7 +2918,7 @@ static QCString addFormula(yyscan_t yyscanner)
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
QCString formLabel;
QCString fText=yyextra->formulaText.simplifyWhiteSpace();
- int id = FormulaManager::instance().addFormula(fText);
+ int id = FormulaManager::instance().addFormula(fText.str());
formLabel.sprintf("\\_form#%d",id);
for (int i=0;i<yyextra->formulaNewLines;i++) formLabel+="@_fakenl"; // add fake newlines to
// keep the warnings
diff --git a/src/defgen.cpp b/src/defgen.cpp
index 514c077..1cb09f5 100644
--- a/src/defgen.cpp
+++ b/src/defgen.cpp
@@ -36,7 +36,6 @@
#include <qdir.h>
#include <qfile.h>
-#include <qtextstream.h>
#define DEF_DB(x)
diff --git a/src/docbookgen.cpp b/src/docbookgen.cpp
index 984d685..4319dda 100644
--- a/src/docbookgen.cpp
+++ b/src/docbookgen.cpp
@@ -19,7 +19,6 @@
#include <qdir.h>
#include <qfile.h>
-#include <qtextstream.h>
#include "docbookgen.h"
#include "doxygen.h"
#include "message.h"
diff --git a/src/doxygen.cpp b/src/doxygen.cpp
index 70153ab..233861c 100644
--- a/src/doxygen.cpp
+++ b/src/doxygen.cpp
@@ -25,7 +25,6 @@
#include <sys/stat.h>
#include <qtextcodec.h>
#include <errno.h>
-#include <qtextstream.h>
#include <algorithm>
#include <unordered_map>
diff --git a/src/formula.cpp b/src/formula.cpp
index 8ba9729..629af45 100644
--- a/src/formula.cpp
+++ b/src/formula.cpp
@@ -22,13 +22,13 @@
#include "image.h"
#include <qfile.h>
-#include <qtextstream.h>
#include <qdir.h>
#include <map>
#include <vector>
#include <string>
#include <utility>
+#include <fstream>
// TODO: remove these dependencies
#include "doxygen.h" // for Doxygen::indexList
@@ -72,50 +72,40 @@ FormulaManager &FormulaManager::instance()
void FormulaManager::readFormulas(const char *dir,bool doCompare)
{
- QFile f(QCString(dir)+"/formula.repository");
- if (f.open(IO_ReadOnly)) // open repository
+ std::ifstream f(std::string(dir)+"/formula.repository");
+ if (f.is_open())
{
uint formulaCount=0;
msg("Reading formula repository...\n");
- QTextStream t(&f);
- QCString line;
+ std::string line;
int lineNr=1;
- while (!t.eof())
+ while (getline(f,line))
{
- line=t.readLine().utf8();
- // old format: \_form#<digits>:formula
- // new format: \_form#<digits>=<digits>x<digits>:formula
- int hi=line.find('#');
- int ei=line.find('=');
- int se=line.find(':'); // find name and text separator.
- if (hi==-1 || se==-1 || hi>se)
+ // format: \_form#<digits>=<digits>x<digits>:formula
+ size_t hi=line.find('#');
+ size_t ei=line.find('=');
+ size_t se=line.find(':'); // find name and text separator.
+ if (ei==std::string::npos || hi==std::string::npos || se==std::string::npos || hi>se || ei<hi || ei>se)
{
warn_uncond("%s/formula.repository is corrupted at line %d!\n",dir,lineNr);
break;
}
else
{
- QCString formName = line.left(se);
- QCString formText = line.right(line.length()-se-1);
+ std::string formName = line.substr(0,se); // '\_form#<digits>=<digits>x<digits>' part
+ std::string formText = line.substr(se+1); // 'formula' part
int w=-1,h=-1;
- if (ei!=-1 && ei>hi && ei<se) // new format
+ size_t xi=formName.find('x',ei);
+ if (xi!=std::string::npos)
{
- int xi=formName.find('x',ei);
- if (xi!=-1)
- {
- w=formName.mid(ei+1,xi-ei-1).toInt();
- h=formName.mid(xi+1).toInt();
- }
- formName = formName.left(ei);
- }
- else
- {
- ei=formName.length();
+ w=std::stoi(formName.substr(ei+1,xi-ei-1)); // digits from '=<digits>x' part as int
+ h=std::stoi(formName.substr(xi+1)); // digits from 'x<digits>' part as int
}
+ formName = formName.substr(0,ei); // keep only the '\_form#<digits>' part
if (doCompare)
{
- int formId = formName.mid(hi+1,ei-hi-1).toInt();
- QCString storedFormText = FormulaManager::instance().findFormula(formId);
+ int formId = stoi(formName.substr(hi+1));
+ std::string storedFormText = FormulaManager::instance().findFormula(formId);
if (storedFormText!=formText)
{
term("discrepancy between formula repositories! Remove "
@@ -123,13 +113,10 @@ void FormulaManager::readFormulas(const char *dir,bool doCompare)
}
formulaCount++;
}
- else
+ int id = addFormula(formText);
+ if (w!=-1 && h!=-1)
{
- int id = addFormula(formText);
- if (w!=-1 && h!=-1)
- {
- p->storeDisplaySize(id,w,h);
- }
+ p->storeDisplaySize(id,w,h);
}
}
lineNr++;
@@ -476,28 +463,27 @@ void FormulaManager::clear()
p->formulaMap.clear();
}
-int FormulaManager::addFormula(const char *formulaText)
+int FormulaManager::addFormula(const std::string &formulaText)
{
- std::string key = toStdString(formulaText);
- auto it = p->formulaMap.find(key);
+ auto it = p->formulaMap.find(formulaText);
if (it!=p->formulaMap.end()) // already stored
{
return it->second;
}
// store new formula
int id = (int)p->formulas.size();
- p->formulaMap.insert(std::pair<std::string,int>(key,id));
- p->formulas.push_back(key);
+ p->formulaMap.insert(std::pair<std::string,int>(formulaText,id));
+ p->formulas.push_back(formulaText);
return id;
}
-QCString FormulaManager::findFormula(int formulaId) const
+std::string FormulaManager::findFormula(int formulaId) const
{
if (formulaId>=0 && formulaId<(int)p->formulas.size())
{
- return p->formulas[formulaId].c_str();
+ return p->formulas[formulaId];
}
- return QCString();
+ return std::string();
}
bool FormulaManager::hasFormulas() const
diff --git a/src/formula.h b/src/formula.h
index 4bd90af..686cea2 100644
--- a/src/formula.h
+++ b/src/formula.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.
*
@@ -19,6 +19,7 @@
#define FORMULA_H
#include <memory>
+#include <string>
#include <qcstring.h>
/*! Manager class to handle formulas */
@@ -36,9 +37,9 @@ class FormulaManager
static FormulaManager &instance();
void readFormulas(const char *dir,bool doCompare=false);
void clear();
- int addFormula(const char *formulaText);
+ int addFormula(const std::string &formulaText);
void generateImages(const char *outputDir,Format format,HighDPI hd = HighDPI::Off) const;
- QCString findFormula(int formulaId) const;
+ std::string findFormula(int formulaId) const;
bool hasFormulas() const;
DisplaySize displaySize(int formulaId) const;
private:
diff --git a/src/index.cpp b/src/index.cpp
index 0984ac2..d9eb7ab 100644
--- a/src/index.cpp
+++ b/src/index.cpp
@@ -24,7 +24,6 @@
#include <array>
#include <assert.h>
-#include <qtextstream.h>
#include <qdir.h>
#include "message.h"
diff --git a/src/xmlgen.cpp b/src/xmlgen.cpp
index cf032d6..3f74da1 100644
--- a/src/xmlgen.cpp
+++ b/src/xmlgen.cpp
@@ -17,7 +17,6 @@
#include <qdir.h>
#include <qfile.h>
-#include <qtextstream.h>
#include "xmlgen.h"
#include "doxygen.h"