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 if (
auto it =
p->entries.find(label.
lower().
str()); it !=
p->entries.end())
106 return it->second.get();
119 return (numFiles==0 ||
p->entries.empty());
142 err(
"bib file {} not found!\n",bibFile);
148 err(
"could not open file {} for reading\n",bibFile);
157 while (getline(f,lineStr))
165 int j = line.
find(
'{');
167 while (j==-1 && getline(f,lineStr))
175 if (!f.eof() && j!=-1)
177 int k = line.
find(
',',j);
181 while (!f.eof() && citeName.
isEmpty())
185 citeName = line.
mid(
static_cast<size_t>(j),
static_cast<size_t>(k-j));
189 citeName = line.
mid(
static_cast<size_t>(j));
193 if (citeName.
isEmpty() && getline(f,lineStr))
204 std::string lCiteName = citeName.
lower().
str();
205 auto it =
p->citePosition.find(lCiteName);
206 if (it !=
p->citePosition.end())
208 warn(bibFile,
lineCount,
"multiple use of citation name '{}', (first occurrence: {}, line {})",
209 lCiteName,it->second.fileName,it->second.lineNr);
217 else if ((i=line.
find(
"crossref"))!=-1 && !citeName.
isEmpty())
219 int j = line.
find(
'{',i);
220 int k = line.
find(
'}',i);
223 QCString crossrefName = line.
mid(
static_cast<size_t>(j+1),
static_cast<uint32_t
>(k-j-1));
226 if (
find(citeName) && !
find(crossrefName))
242 bool insideFormula =
false;
243 int citeFormulaCnt = 1;
244 const size_t tmpLen = 30;
246 const char *ps=s.
data();
264 insideFormula =
false;
270 p->formulaCite.emplace(citeFormulaCnt,std::string(
"\\f$") + formulaBuf.
get() +
"\\f$");
276 insideFormula =
false;
294 insideFormula =
true;
309 return growBuf.
get();
320 t += s.
mid(pos,i-pos);
322 int markerId = atoi(s.
mid(i+markerSize,6).
data());
323 auto it =
p->formulaCite.find(markerId);
324 if (it !=
p->formulaCite.end()) t += it->second;
325 pos = i + markerSize+6;
343 for (
const auto &bibdata : citeDataList)
351 QCString citeListFile = outputDir+
"/citelist.doc";
356 err(
"could not open file {} for writing\n",citeListFile);
358 t <<
"<!-- BEGIN CITATIONS -->\n";
360 for (
const auto &it :
p->entries)
362 t <<
"\\citation{" << it.second->label() <<
"}\n";
365 t <<
"<!-- END CITATIONS -->\n";
366 t <<
"<!-- BEGIN BIBLIOGRAPHY -->\n";
367 t <<
"<!-- END BIBLIOGRAPHY -->\n";
372 QCString bib2xhtmlFile = outputDir+
"/bib2xhtml.pl";
376 QCString doxygenBstFile = outputDir+
"/doxygen.bst";
388 err(
"Failed to create temporary output directory '{}', skipping citations\n",bibOutputDir);
392 for (
const auto &bibdata : citeDataList)
402 if (!f_org.is_open())
404 err(
"could not open file {} for reading\n",bibFile);
407 if (!f_out.is_open())
409 err(
"could not open file {}{}{:d}{} for reading\n",bibOutputDir,
bibTmpFile,i,
".bib");
413 while (getline(f_org,lineStr))
415 docs += lineStr +
"\n";
419 if (f_org.is_open()) f_org.close();
420 if (f_out.is_open()) f_out.close();
431 QCString perlArgs =
"\""+bib2xhtmlFile+
"\" "+bibOutputFiles+
" \""+ citeListFile+
"\"";
432 if (citeDebug) perlArgs+=
" -d";
436 err(
"Problems running bibtex. Verify that the command 'perl --version' works from the command line. Exit code: {}\n",
448 err(
"could not open file {} for reading\n",citeListFile);
451 bool insideBib=
FALSE;
454 while (getline(f,lineStr))
459 if (line.
find(
"<!-- BEGIN BIBLIOGRAPHY")!=-1) insideBib=
TRUE;
460 else if (line.
find(
"<!-- END BIBLIOGRAPH")!=-1) insideBib=
FALSE;
462 if (insideBib && ((i=line.
find(
"name=\"CITEREF_"))!=-1 || (i=line.
find(
"name=\"#CITEREF_"))!=-1))
464 int j=line.
find(
"\">[");
465 int j1=line.
find(
"<!--[");
466 int k=line.
find(
"]<!--");
467 int k1=line.
find(
"]-->");
470 size_t ui=
static_cast<size_t>(i);
471 size_t uj0=
static_cast<size_t>(j);
472 size_t uj=
static_cast<size_t>(j1);
473 size_t uk=
static_cast<size_t>(k1);
479 if (optList.size() == 3)
484 auto it =
p->entries.find(label.
lower().
str());
486 if (it!=
p->entries.end())
488 it->second->setText(number);
489 it->second->setShortAuthor(shortAuthor);
494 if (insideBib) doc+=line+
"\n";
503 bool needsEntry =
false;
537 for (
const auto &bibdata : citeDataList)
553 err(
"bib file {} not found!\n",bibFile);
567 for (
size_t j = 1; j <= citeDataList.size(); j++)
581 for (
const auto &bibdata : citeDataList)
587 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.