32#include <unordered_map>
80 std::map< std::string,std::unique_ptr<CiteInfoImpl> >
entries;
98 p->entries.emplace(lowerCaseLabel.
str(),std::make_unique<CiteInfoImpl>(lowerCaseLabel));
103 if (
auto it =
p->entries.find(label.
lower().
str()); it !=
p->entries.end())
105 return it->second.get();
118 return (numFiles==0 ||
p->entries.empty());
141 err(
"bib file {} not found!\n",bibFile);
147 err(
"could not open file {} for reading\n",bibFile);
156 while (getline(f,lineStr))
164 int j = line.
find(
'{');
166 while (j==-1 && getline(f,lineStr))
174 if (!f.eof() && j!=-1)
176 int k = line.
find(
',',j);
180 while (!f.eof() && citeName.
isEmpty())
184 citeName = line.
mid(
static_cast<size_t>(j),
static_cast<size_t>(k-j));
188 citeName = line.
mid(
static_cast<size_t>(j));
192 if (citeName.
isEmpty() && getline(f,lineStr))
203 std::string lCiteName = citeName.
lower().
str();
204 auto it =
p->citePosition.find(lCiteName);
205 if (it !=
p->citePosition.end())
207 warn(bibFile,
lineCount,
"multiple use of citation name '{}', (first occurrence: {}, line {})",
208 lCiteName,it->second.fileName,it->second.lineNr);
216 else if ((i=line.
find(
"crossref"))!=-1 && !citeName.
isEmpty())
218 int j = line.
find(
'{',i);
219 int k = line.
find(
'}',i);
222 QCString crossrefName = line.
mid(
static_cast<size_t>(j+1),
static_cast<uint32_t
>(k-j-1));
225 if (
find(citeName) && !
find(crossrefName))
243 bool insideFormula =
false;
244 int citeFormulaCnt = 1;
245 const char *ps=s.
data();
262 insideFormula =
false;
267 const size_t idLen = 30;
270 p->formulaCite.emplace(citeFormulaCnt,std::string(
"\\f$") + formula.
str() +
"\\f$");
276 insideFormula =
false;
295 insideFormula =
true;
319 t += s.
mid(pos,i-pos);
321 int markerId = atoi(s.
mid(i+markerSize,6).
data());
322 auto it =
p->formulaCite.find(markerId);
323 if (it !=
p->formulaCite.end()) t += it->second;
324 pos = i + markerSize+6;
342 for (
const auto &bibdata : citeDataList)
350 QCString citeListFile = outputDir+
"/citelist.doc";
355 err(
"could not open file {} for writing\n",citeListFile);
357 t <<
"<!-- BEGIN CITATIONS -->\n";
359 for (
const auto &it :
p->entries)
361 t <<
"\\citation{" << it.second->label() <<
"}\n";
364 t <<
"<!-- END CITATIONS -->\n";
365 t <<
"<!-- BEGIN BIBLIOGRAPHY -->\n";
366 t <<
"<!-- END BIBLIOGRAPHY -->\n";
371 QCString bib2xhtmlFile = outputDir+
"/bib2xhtml.pl";
375 QCString doxygenBstFile = outputDir+
"/doxygen.bst";
387 err(
"Failed to create temporary output directory '{}', skipping citations\n",bibOutputDir);
391 for (
const auto &bibdata : citeDataList)
401 if (!f_org.is_open())
403 err(
"could not open file {} for reading\n",bibFile);
406 if (!f_out.is_open())
408 err(
"could not open file {}{}{:d}{} for reading\n",bibOutputDir,
bibTmpFile,i,
".bib");
412 while (getline(f_org,lineStr))
414 docs += lineStr +
"\n";
418 if (f_org.is_open()) f_org.close();
419 if (f_out.is_open()) f_out.close();
430 QCString perlArgs =
"\""+bib2xhtmlFile+
"\" "+bibOutputFiles+
" \""+ citeListFile+
"\"";
431 if (citeDebug) perlArgs+=
" -d";
435 err(
"Problems running bibtex. Verify that the command 'perl --version' works from the command line. Exit code: {}\n",
447 err(
"could not open file {} for reading\n",citeListFile);
450 bool insideBib=
FALSE;
453 while (getline(f,lineStr))
458 if (line.
find(
"<!-- BEGIN BIBLIOGRAPHY")!=-1) insideBib=
TRUE;
459 else if (line.
find(
"<!-- END BIBLIOGRAPH")!=-1) insideBib=
FALSE;
461 if (insideBib && ((i=line.
find(
"name=\"CITEREF_"))!=-1 || (i=line.
find(
"name=\"#CITEREF_"))!=-1))
463 int j=line.
find(
"\">[");
464 int j1=line.
find(
"<!--[");
465 int k=line.
find(
"]<!--");
466 int k1=line.
find(
"]-->");
469 size_t ui=
static_cast<size_t>(i);
470 size_t uj0=
static_cast<size_t>(j);
471 size_t uj=
static_cast<size_t>(j1);
472 size_t uk=
static_cast<size_t>(k1);
478 if (optList.size() == 3)
483 auto it =
p->entries.find(label.
lower().
str());
485 if (it!=
p->entries.end())
487 it->second->setText(number);
488 it->second->setShortAuthor(shortAuthor);
493 if (insideBib) doc+=line+
"\n";
502 bool needsEntry =
false;
536 for (
const auto &bibdata : citeDataList)
552 err(
"bib file {} not found!\n",bibFile);
566 for (
size_t j = 1; j <= citeDataList.size(); j++)
580 for (
const auto &bibdata : citeDataList)
586 if (i) result +=
",";
static QCString getBibFile(const QCString &inFile)
static const std::string g_formulaMarker
void insertCrossReferencesForBibFile(const QCString &bibFile)
QCString anchorPrefix() const
std::unique_ptr< Private > p
const CiteInfo * find(const QCString &label) const
Return the citation info for a given label.
QCString latexBibFiles()
lists the bibtex cite files in a comma separated list
static CitationManager & instance()
void clear()
clears the database
QCString replaceFormulas(const QCString &s)
void insert(const QCString &label)
Insert a citation identified by label into the database.
CitationManager()
Create the database, with an expected maximum of size entries.
QCString fileName() const
bool isEmpty() const
return TRUE if there are no citations.
void generatePage()
Generate the citations page.
QCString getFormulas(const QCString &s)
void setText(const QCString &s)
QCString label() const override
QCString text() const override
QCString year() const override
CiteInfoImpl(const QCString &label, const QCString &text=QCString())
QCString shortAuthor() const override
void setYear(const QCString &s)
void setShortAuthor(const QCString &s)
class that provide information about the p[osition of a citation name
CitePosition(const QCString &fn, int l)
static bool isFlagSet(const DebugMask mask)
Class representing a directory in the file system.
static std::string currentDirPath()
bool mkdir(const std::string &path, bool acceptsAbsPath=true) const
bool remove(const std::string &path, bool acceptsAbsPath=true) const
bool rmdir(const std::string &path, bool acceptsAbsPath=true) const
static bool setCurrent(const std::string &path)
Represents an unstructured piece of information, about an entity found in the sources.
QCString doc
documentation block (partly parsed)
Minimal replacement for QFileInfo.
This is an alternative implementation of QCString.
int find(char c, int index=0, bool cs=TRUE) const
size_t length() const
Returns the length of the string, not counting the 0-terminator.
bool startsWith(const char *s) const
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
bool endsWith(const char *s) const
bool isEmpty() const
Returns TRUE iff the string is empty.
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
const std::string & str() const
QCString & setNum(short n)
QCString right(size_t len) const
void reserve(size_t size)
Reserve space for size bytes without changing the string contents.
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
QCString left(size_t len) const
static ResourceMgr & instance()
Returns the one and only instance of this class.
bool copyResource(const QCString &name, const QCString &targetDir) const
Copies a registered resource to a given target directory.
#define Config_getList(name)
#define Config_getBool(name)
#define Config_getString(name)
std::vector< std::string > StringVector
#define lineCount(s, len)
static void addRelatedPage(Entry *root)
Translator * theTranslator
#define warn(file, line, fmt,...)
std::ifstream openInputStream(const QCString &name, bool binary=false, bool openAtEnd=false)
std::ofstream openOutputStream(const QCString &name, bool append=false)
int system(const QCString &command, const QCString &args, bool commandHasConsole=true)
Portable versions of functions that are platform dependent.
std::map< std::string, std::unique_ptr< CiteInfoImpl > > entries
std::unordered_map< std::string, CitePosition > citePosition
std::unordered_map< int, std::string > formulaCite
StringVector split(const std::string &s, const std::string &delimiter)
split input string s by string delimiter delimiter.
bool copyFile(const QCString &src, const QCString &dest)
Copies the contents of file with name src to the newly created file with name dest.
A bunch of utility functions.