33#include <unordered_map>
81 std::map< std::string,std::unique_ptr<CiteInfoImpl> >
entries;
99 p->entries.emplace(lowerCaseLabel.
str(),std::make_unique<CiteInfoImpl>(lowerCaseLabel));
104 auto it =
p->entries.find(label.
lower().
str());
105 if (it!=
p->entries.end())
107 return it->second.get();
120 return (numFiles==0 ||
p->entries.empty());
143 err(
"bib file {} not found!\n",bibFile);
149 err(
"could not open file {} for reading\n",bibFile);
158 while (getline(f,lineStr))
166 int j = line.
find(
'{');
168 while (j==-1 && getline(f,lineStr))
176 if (!f.eof() && j!=-1)
178 int k = line.
find(
',',j);
182 while (!f.eof() && citeName.
isEmpty())
186 citeName = line.
mid(
static_cast<size_t>(j),
static_cast<size_t>(k-j));
190 citeName = line.
mid(
static_cast<size_t>(j));
194 if (citeName.
isEmpty() && getline(f,lineStr))
205 std::string lCiteName = citeName.
lower().
str();
206 auto it =
p->citePosition.find(lCiteName);
207 if (it !=
p->citePosition.end())
209 warn(bibFile,
lineCount,
"multiple use of citation name '{}', (first occurrence: {}, line {})",
210 lCiteName,it->second.fileName,it->second.lineNr);
218 else if ((i=line.
find(
"crossref"))!=-1 && !citeName.
isEmpty())
220 int j = line.
find(
'{',i);
221 int k = line.
find(
'}',i);
224 QCString crossrefName = line.
mid(
static_cast<size_t>(j+1),
static_cast<uint32_t
>(k-j-1));
227 if (
find(citeName) && !
find(crossrefName))
243 bool insideFormula =
false;
244 int citeFormulaCnt = 1;
245 const size_t tmpLen = 30;
247 const char *ps=s.
data();
265 insideFormula =
false;
271 p->formulaCite.emplace(citeFormulaCnt,std::string(
"\\f$") + formulaBuf.
get() +
"\\f$");
277 insideFormula =
false;
295 insideFormula =
true;
310 return growBuf.
get();
321 t += s.
mid(pos,i-pos);
323 int markerId = atoi(s.
mid(i+markerSize,6).
data());
324 auto it =
p->formulaCite.find(markerId);
325 if (it !=
p->formulaCite.end()) t += it->second;
326 pos = i + markerSize+6;
344 for (
const auto &bibdata : citeDataList)
352 QCString citeListFile = outputDir+
"/citelist.doc";
357 err(
"could not open file {} for writing\n",citeListFile);
359 t <<
"<!-- BEGIN CITATIONS -->\n";
361 for (
const auto &it :
p->entries)
363 t <<
"\\citation{" << it.second->label() <<
"}\n";
366 t <<
"<!-- END CITATIONS -->\n";
367 t <<
"<!-- BEGIN BIBLIOGRAPHY -->\n";
368 t <<
"<!-- END BIBLIOGRAPHY -->\n";
373 QCString bib2xhtmlFile = outputDir+
"/bib2xhtml.pl";
377 QCString doxygenBstFile = outputDir+
"/doxygen.bst";
389 err(
"Failed to create temporary output directory '{}', skipping citations\n",bibOutputDir);
393 for (
const auto &bibdata : citeDataList)
403 if (!f_org.is_open())
405 err(
"could not open file {} for reading\n",bibFile);
408 if (!f_out.is_open())
410 err(
"could not open file {}{}{:d}{} for reading\n",bibOutputDir,
bibTmpFile,i,
".bib");
414 while (getline(f_org,lineStr))
416 docs += lineStr +
"\n";
420 if (f_org.is_open()) f_org.close();
421 if (f_out.is_open()) f_out.close();
432 QCString perlArgs =
"\""+bib2xhtmlFile+
"\" "+bibOutputFiles+
" \""+ citeListFile+
"\"";
433 if (citeDebug) perlArgs+=
" -d";
437 err(
"Problems running bibtex. Verify that the command 'perl --version' works from the command line. Exit code: {}\n",
449 err(
"could not open file {} for reading\n",citeListFile);
452 bool insideBib=
FALSE;
455 while (getline(f,lineStr))
460 if (line.
find(
"<!-- BEGIN BIBLIOGRAPHY")!=-1) insideBib=
TRUE;
461 else if (line.
find(
"<!-- END BIBLIOGRAPH")!=-1) insideBib=
FALSE;
463 if (insideBib && ((i=line.
find(
"name=\"CITEREF_"))!=-1 || (i=line.
find(
"name=\"#CITEREF_"))!=-1))
465 int j=line.
find(
"\">[");
466 int j1=line.
find(
"<!--[");
467 int k=line.
find(
"]<!--");
468 int k1=line.
find(
"]-->");
471 size_t ui=
static_cast<size_t>(i);
472 size_t uj0=
static_cast<size_t>(j);
473 size_t uj=
static_cast<size_t>(j1);
474 size_t uk=
static_cast<size_t>(k1);
477 QCString number = optList[0].c_str();
478 QCString shortAuthor = optList[1].c_str();
480 if (optList.size() == 3)
482 year = optList[2].c_str();
485 auto it =
p->entries.find(label.
lower().
str());
487 if (it!=
p->entries.end())
489 it->second->setText(number);
490 it->second->setShortAuthor(shortAuthor);
495 if (insideBib) doc+=line+
"\n";
504 bool needsEntry =
false;
538 for (
const auto &bibdata : citeDataList)
554 err(
"bib file {} not found!\n",bibFile);
568 for (
size_t j = 1; j <= citeDataList.size(); j++)
582 for (
const auto &bibdata : citeDataList)
590 if (i) result +=
",";
static QCString getBibFile(const QCString &inFile)
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.
Class representing a string buffer optimized for growing.
void addStr(const QCString &s)
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
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.