Doxygen
Loading...
Searching...
No Matches
CitationManager Class Reference

Citation manager class. More...

#include <src/cite.h>

Classes

struct  Private

Public Member Functions

void insert (const QCString &label)
 Insert a citation identified by label into the database.
const CiteInfofind (const QCString &label) const
 Return the citation info for a given label.
void generatePage ()
 Generate the citations page.
void clear ()
 clears the database
bool isEmpty () const
 return TRUE if there are no citations.
QCString latexBibFiles ()
 lists the bibtex cite files in a comma separated list
QCString fileName () const
QCString anchorPrefix () const

Static Public Member Functions

static CitationManagerinstance ()

Private Member Functions

 CitationManager ()
 Create the database, with an expected maximum of size entries.
 ~CitationManager ()=default
void insertCrossReferencesForBibFile (const QCString &bibFile)
QCString getFormulas (const QCString &s)
QCString replaceFormulas (const QCString &s)

Private Attributes

std::unique_ptr< Privatep

Detailed Description

Citation manager class.

This class provides access do the database of bibliographic references through the bibtex backend.

Definition at line 84 of file cite.h.

Constructor & Destructor Documentation

◆ CitationManager()

CitationManager::CitationManager ( )
private

Create the database, with an expected maximum of size entries.

Definition at line 91 of file cite.cpp.

91 : p(new Private)
92{
93}
std::unique_ptr< Private > p
Definition cite.h:123

References p.

Referenced by instance(), and ~CitationManager().

◆ ~CitationManager()

CitationManager::~CitationManager ( )
privatedefault

Member Function Documentation

◆ anchorPrefix()

QCString CitationManager::anchorPrefix ( ) const

Definition at line 126 of file cite.cpp.

127{
128 return "CITEREF_";
129}

Referenced by DocAnchor::DocAnchor(), DocCite::DocCite(), LatexDocVisitor::operator()(), and TextDocVisitor::operator()().

◆ clear()

void CitationManager::clear ( )

clears the database

Definition at line 110 of file cite.cpp.

111{
112 p->entries.clear();
113}

References p.

Referenced by clearAll().

◆ fileName()

QCString CitationManager::fileName ( ) const

Definition at line 121 of file cite.cpp.

122{
123 return "citelist";
124}

Referenced by DocAnchor::DocAnchor(), DocCite::DocCite(), and generatePage().

◆ find()

const CiteInfo * CitationManager::find ( const QCString & label) const

Return the citation info for a given label.

Ownership of the info stays with the manager.

Definition at line 101 of file cite.cpp.

102{
103 if (auto it = p->entries.find(label.lower().str()); it != p->entries.end())
104 {
105 return it->second.get();
106 }
107 return nullptr;
108}
QCString lower() const
Definition qcstring.h:249
const std::string & str() const
Definition qcstring.h:552

References QCString::lower(), p, and QCString::str().

Referenced by DocAnchor::DocAnchor(), DocCite::DocCite(), DocCite::getText(), and insertCrossReferencesForBibFile().

◆ generatePage()

void CitationManager::generatePage ( )

Generate the citations page.

Definition at line 331 of file cite.cpp.

332{
333 //printf("** CitationManager::generatePage() count=%d\n",m_ordering.count());
334
335 // do not generate an empty citations page
336 if (isEmpty()) return; // nothing to cite
337
338 bool citeDebug = Debug::isFlagSet(Debug::Cite);
339
340 // 0. add cross references from the bib files to the cite dictionary
341 const StringVector &citeDataList = Config_getList(CITE_BIB_FILES);
342 for (const auto &bibdata : citeDataList)
343 {
344 QCString bibFile = getBibFile(bibdata);
346 }
347
348 // 1. generate file with markers and citations to OUTPUT_DIRECTORY
349 QCString outputDir = Config_getString(OUTPUT_DIRECTORY);
350 QCString citeListFile = outputDir+"/citelist.doc";
351 {
352 std::ofstream t = Portable::openOutputStream(citeListFile);
353 if (!t.is_open())
354 {
355 err("could not open file {} for writing\n",citeListFile);
356 }
357 t << "<!-- BEGIN CITATIONS -->\n";
358 t << "<!--\n";
359 for (const auto &it : p->entries)
360 {
361 t << "\\citation{" << it.second->label() << "}\n";
362 }
363 t << "-->\n";
364 t << "<!-- END CITATIONS -->\n";
365 t << "<!-- BEGIN BIBLIOGRAPHY -->\n";
366 t << "<!-- END BIBLIOGRAPHY -->\n";
367 t.close();
368 }
369
370 // 2. generate bib2xhtml
371 QCString bib2xhtmlFile = outputDir+"/bib2xhtml.pl";
372 ResourceMgr::instance().copyResource("bib2xhtml.pl",outputDir);
373
374 // 3. generate doxygen.bst
375 QCString doxygenBstFile = outputDir+"/doxygen.bst";
376 ResourceMgr::instance().copyResource("doxygen.bst",outputDir);
377
378 // 4. for all formats we just copy the bib files to as special output directory
379 // so bibtex can find them without path (bibtex doesn't support paths or
380 // filenames with spaces!)
381 // Strictly not required when only latex is generated
382 QCString bibOutputDir = outputDir+"/"+bibTmpDir;
383 QCString bibOutputFiles = "";
384 Dir thisDir;
385 if (!thisDir.exists(bibOutputDir.str()) && !thisDir.mkdir(bibOutputDir.str()))
386 {
387 err("Failed to create temporary output directory '{}', skipping citations\n",bibOutputDir);
388 return;
389 }
390 int i = 0;
391 for (const auto &bibdata : citeDataList)
392 {
393 QCString bibFile = getBibFile(bibdata);
394 FileInfo fi(bibFile.str());
395 if (fi.exists())
396 {
397 if (!bibFile.isEmpty())
398 {
399 ++i;
400 std::ifstream f_org = Portable::openInputStream(bibFile);
401 if (!f_org.is_open())
402 {
403 err("could not open file {} for reading\n",bibFile);
404 }
405 std::ofstream f_out = Portable::openOutputStream(bibOutputDir + bibTmpFile + QCString().setNum(i) + ".bib");
406 if (!f_out.is_open())
407 {
408 err("could not open file {}{}{:d}{} for reading\n",bibOutputDir,bibTmpFile,i,".bib");
409 }
410 QCString docs;
411 std::string lineStr;
412 while (getline(f_org,lineStr))
413 {
414 docs += lineStr + "\n";
415 }
416 docs = getFormulas(docs);
417 f_out << docs;
418 if (f_org.is_open()) f_org.close();
419 if (f_out.is_open()) f_out.close();
420 bibOutputFiles = bibOutputFiles + " " + bibTmpDir + bibTmpFile + QCString().setNum(i) + ".bib";
421 }
422 }
423 }
424
425 std::string oldDir = Dir::currentDirPath();
426 Dir::setCurrent(outputDir.str());
427
428 // 5. run bib2xhtml perl script on the generated file which will insert the
429 // bibliography in citelist.doc
430 QCString perlArgs = "\""+bib2xhtmlFile+"\" "+bibOutputFiles+" \""+ citeListFile+"\"";
431 if (citeDebug) perlArgs+=" -d";
432 int exitCode = Portable::system("perl",perlArgs);
433 if (exitCode!=0)
434 {
435 err("Problems running bibtex. Verify that the command 'perl --version' works from the command line. Exit code: {}\n",
436 exitCode);
437 }
438
439 Dir::setCurrent(oldDir);
440
441 // 6. read back the file
442 QCString doc;
443 {
444 std::ifstream f = Portable::openInputStream(citeListFile);
445 if (!f.is_open())
446 {
447 err("could not open file {} for reading\n",citeListFile);
448 }
449
450 bool insideBib=FALSE;
451 //printf("input=[%s]\n",qPrint(input));
452 std::string lineStr;
453 while (getline(f,lineStr))
454 {
455 QCString line(lineStr);
456 //printf("pos=%d s=%d line=[%s]\n",pos,s,qPrint(line));
457
458 if (line.find("<!-- BEGIN BIBLIOGRAPHY")!=-1) insideBib=TRUE;
459 else if (line.find("<!-- END BIBLIOGRAPH")!=-1) insideBib=FALSE;
460 // determine text to use at the location of the @cite command
461 if (insideBib && ((i=line.find("name=\"CITEREF_"))!=-1 || (i=line.find("name=\"#CITEREF_"))!=-1))
462 {
463 int j=line.find("\">[");
464 int j1=line.find("<!--[");
465 int k=line.find("]<!--");
466 int k1=line.find("]-->");
467 if (j!=-1 && k!=-1)
468 {
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);
473 QCString label = line.mid(ui+14,uj0-ui-14);
474 StringVector optList = split(line.mid(uj+5,uk-uj-5).str(),",");
475 QCString number = optList[0];
476 QCString shortAuthor = optList[1];
477 QCString year;
478 if (optList.size() == 3)
479 {
480 year = optList[2];
481 }
482 line = line.left(ui+14) + label + line.right(line.length()-uj0);
483 auto it = p->entries.find(label.lower().str());
484 //printf("label='%s' number='%s' => %p\n",qPrint(label),qPrint(number),it->second.get());
485 if (it!=p->entries.end())
486 {
487 it->second->setText(number);
488 it->second->setShortAuthor(shortAuthor);
489 it->second->setYear(year.stripWhiteSpace());
490 }
491 }
492 }
493 if (insideBib) doc+=line+"\n";
494 }
495 //printf("doc=[%s]\n",qPrint(doc));
496 }
497
498 // 7. place formulas back and run the conversion of \f$ ... \f$ to the internal required format
499 {
500 doc = replaceFormulas(doc);
501 Entry current;
502 bool needsEntry = false;
503 CommentScanner commentScanner;
504 int lineNr = 0;
505 int pos = 0;
506 GuardedSectionStack guards;
507 Protection prot = Protection::Public;
508 commentScanner.parseCommentBlock(
509 nullptr,
510 &current,
511 doc, // text
512 fileName(), // file
513 lineNr, // line of block start
514 false, // isBrief
515 false, // isJavaDocStyle
516 false, // isInBody
517 prot, // protection
518 pos, // position,
519 needsEntry,
520 false,
521 &guards
522 );
523 doc = current.doc;
524 }
525
526 // 8. add it as a page
528
529 // 9. for latex we just copy the bib files to the output and let
530 // latex do this work.
531 if (Config_getBool(GENERATE_LATEX))
532 {
533 // copy bib files to the latex output dir
534 QCString latexOutputDir = Config_getString(LATEX_OUTPUT)+"/";
535 i = 0;
536 for (const auto &bibdata : citeDataList)
537 {
538 QCString bibFile = getBibFile(bibdata);
539 FileInfo fi(bibFile.str());
540 if (fi.exists())
541 {
542 if (!bibFile.isEmpty())
543 {
544 // bug_700510, multiple times the same name were overwriting; creating new names
545 // also for names with spaces
546 ++i;
547 copyFile(bibFile,latexOutputDir + bibTmpFile + QCString().setNum(i) + ".bib");
548 }
549 }
550 else
551 {
552 err("bib file {} not found!\n",bibFile);
553 }
554 }
555 }
556
557 // 10. Remove temporary files
558 if (!citeDebug)
559 {
560 thisDir.remove(citeListFile.str());
561 thisDir.remove(doxygenBstFile.str());
562 thisDir.remove(bib2xhtmlFile.str());
563 // we might try to remove too many files as empty files didn't get a corresponding new file
564 // but the remove function does not emit an error for it and we don't catch the error return
565 // so no problem.
566 for (size_t j = 1; j <= citeDataList.size(); j++)
567 {
568 QCString bibFile = bibOutputDir + bibTmpFile + QCString().setNum(static_cast<int>(j)) + ".bib";
569 thisDir.remove(bibFile.str());
570 }
571 thisDir.rmdir(bibOutputDir.str());
572 }
573}
static QCString getBibFile(const QCString &inFile)
Definition cite.cpp:49
const char * bibTmpFile
Definition cite.cpp:36
const char * bibTmpDir
Definition cite.cpp:37
void insertCrossReferencesForBibFile(const QCString &bibFile)
Definition cite.cpp:131
QCString replaceFormulas(const QCString &s)
Definition cite.cpp:311
QCString fileName() const
Definition cite.cpp:121
bool isEmpty() const
return TRUE if there are no citations.
Definition cite.cpp:115
QCString getFormulas(const QCString &s)
Definition cite.cpp:236
bool parseCommentBlock(OutlineParserInterface *parser, Entry *curEntry, const QCString &comment, const QCString &fileName, int &lineNr, bool isBrief, bool isJavadocStyle, bool isInbody, Protection &prot, int &position, bool &newEntryNeeded, bool markdownEnabled, GuardedSectionStack *guards)
Invokes the comment block parser with the request to parse a single comment block.
@ Cite
Definition debug.h:41
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:132
static std::string currentDirPath()
Definition dir.cpp:342
bool mkdir(const std::string &path, bool acceptsAbsPath=true) const
Definition dir.cpp:295
bool remove(const std::string &path, bool acceptsAbsPath=true) const
Definition dir.cpp:314
bool rmdir(const std::string &path, bool acceptsAbsPath=true) const
Definition dir.cpp:309
static bool setCurrent(const std::string &path)
Definition dir.cpp:350
bool exists() const
Definition dir.cpp:257
QCString doc
documentation block (partly parsed)
Definition entry.h:200
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:163
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
Definition qcstring.h:260
QCString & setNum(short n)
Definition qcstring.h:459
QCString right(size_t len) const
Definition qcstring.h:234
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.
virtual QCString trCiteReferences()=0
std::stack< GuardedSection > GuardedSectionStack
Definition commentscan.h:48
#define Config_getList(name)
Definition config.h:38
#define Config_getBool(name)
Definition config.h:33
#define Config_getString(name)
Definition config.h:32
std::vector< std::string > StringVector
Definition containers.h:33
static void addRelatedPage(Entry *root)
Definition doxygen.cpp:328
Translator * theTranslator
Definition language.cpp:71
#define err(fmt,...)
Definition message.h:127
std::ifstream openInputStream(const QCString &name, bool binary=false, bool openAtEnd=false)
Definition portable.cpp:660
std::ofstream openOutputStream(const QCString &name, bool append=false)
Definition portable.cpp:649
int system(const QCString &command, const QCString &args, bool commandHasConsole=true)
Definition portable.cpp:106
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34
Protection
Definition types.h:32
StringVector split(const std::string &s, const std::string &delimiter)
split input string s by string delimiter delimiter.
Definition util.cpp:6568
bool copyFile(const QCString &src, const QCString &dest)
Copies the contents of file with name src to the newly created file with name dest.
Definition util.cpp:5809

References addRelatedPage(), bibTmpDir, bibTmpFile, Debug::Cite, Config_getBool, Config_getList, Config_getString, copyFile(), ResourceMgr::copyResource(), Dir::currentDirPath(), Entry::doc, err, Dir::exists(), FileInfo::exists(), FALSE, fileName(), QCString::find(), getBibFile(), getFormulas(), insertCrossReferencesForBibFile(), ResourceMgr::instance(), isEmpty(), QCString::isEmpty(), Debug::isFlagSet(), QCString::left(), QCString::length(), QCString::lower(), QCString::mid(), Dir::mkdir(), Portable::openInputStream(), Portable::openOutputStream(), p, CommentScanner::parseCommentBlock(), Dir::remove(), replaceFormulas(), QCString::right(), Dir::rmdir(), Dir::setCurrent(), QCString::setNum(), split(), QCString::str(), QCString::stripWhiteSpace(), Portable::system(), theTranslator, and TRUE.

Referenced by parseInput().

◆ getFormulas()

QCString CitationManager::getFormulas ( const QCString & s)
private

Definition at line 236 of file cite.cpp.

237{
238 if (s.isEmpty()) return s;
239 QCString result;
240 result.reserve(s.length()+32);
241 QCString formula;
242 formula.reserve(256);
243 bool insideFormula = false;
244 int citeFormulaCnt = 1;
245 const char *ps=s.data();
246 char c = 0;
247 while ((c=*ps++))
248 {
249 if (insideFormula)
250 {
251 switch (c)
252 {
253 case '\\':
254 formula+=c;
255 c = *ps++;
256 formula+=c;
257 break;
258 case '\n':
259 formula+=c;
260 result+='$';
261 result+=formula;
262 insideFormula = false;
263 formula.clear();
264 break;
265 case '$':
266 {
267 const size_t idLen = 30;
268 char id[idLen];
269 qsnprintf(id,idLen,"%s%06d",g_formulaMarker.c_str(),citeFormulaCnt);
270 p->formulaCite.emplace(citeFormulaCnt,std::string("\\f$") + formula.str() + "\\f$");
271 citeFormulaCnt++;
272 // need { and } due to the capitalization rules of bibtex.
273 result+='{';
274 result+=id;
275 result+='}';
276 insideFormula = false;
277 formula.clear();
278 }
279 break;
280 default:
281 formula+=c;
282 break;
283 }
284 }
285 else
286 {
287 switch (c)
288 {
289 case '\\':
290 result+=c;
291 c = *ps++;
292 result+=c;
293 break;
294 case '$':
295 insideFormula = true;
296 break;
297 default:
298 result+=c;
299 break;
300 }
301 }
302 }
303 if (insideFormula)
304 {
305 result+=formula;
306 formula.clear();
307 }
308 return result;
309}
static const std::string g_formulaMarker
Definition cite.cpp:234
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:166
void reserve(size_t size)
Reserve space for size bytes without changing the string contents.
Definition qcstring.h:185
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition qcstring.h:172
void clear()
Definition qcstring.h:182
#define qsnprintf
Definition qcstring.h:49

References QCString::clear(), QCString::data(), g_formulaMarker, QCString::isEmpty(), QCString::length(), p, qsnprintf, QCString::reserve(), and QCString::str().

Referenced by generatePage(), and ~CitationManager().

◆ insert()

void CitationManager::insert ( const QCString & label)

Insert a citation identified by label into the database.

Definition at line 95 of file cite.cpp.

96{
97 QCString lowerCaseLabel = label.lower();
98 p->entries.emplace(lowerCaseLabel.str(),std::make_unique<CiteInfoImpl>(lowerCaseLabel));
99}

References QCString::lower(), p, and QCString::str().

Referenced by addCite(), and insertCrossReferencesForBibFile().

◆ insertCrossReferencesForBibFile()

void CitationManager::insertCrossReferencesForBibFile ( const QCString & bibFile)
private

Definition at line 131 of file cite.cpp.

132{
133 // sanity checks
134 if (bibFile.isEmpty())
135 {
136 return;
137 }
138 FileInfo fi(bibFile.str());
139 if (!fi.exists())
140 {
141 err("bib file {} not found!\n",bibFile);
142 return;
143 }
144 std::ifstream f = Portable::openInputStream(bibFile);
145 if (!f.is_open())
146 {
147 err("could not open file {} for reading\n",bibFile);
148 return;
149 }
150
151 // search for citation cross references
152 QCString citeName;
153
154 std::string lineStr;
155 int lineCount = 0;
156 while (getline(f,lineStr))
157 {
158 int i = -1;
159 QCString line(lineStr);
160 lineCount++;
161 if (line.stripWhiteSpace().startsWith("@"))
162 {
163 // assumption entry like: "@book { name," or "@book { name" (spaces optional)
164 int j = line.find('{');
165 // when no {, go hunting for it
166 while (j==-1 && getline(f,lineStr))
167 {
168 line = lineStr;
169 lineCount++;
170 j = line.find('{');
171 }
172 // search for the name
173 citeName = "";
174 if (!f.eof() && j!=-1) // to prevent something like "@manual ," and no { found
175 {
176 int k = line.find(',',j);
177 j++;
178 // found a line "@....{.....,...." or "@.....{....."
179 // ^=j ^=k ^=j k=-1
180 while (!f.eof() && citeName.isEmpty())
181 {
182 if (k!=-1)
183 {
184 citeName = line.mid(static_cast<size_t>(j),static_cast<size_t>(k-j));
185 }
186 else
187 {
188 citeName = line.mid(static_cast<size_t>(j));
189 }
190 citeName = citeName.stripWhiteSpace();
191 j = 0;
192 if (citeName.isEmpty() && getline(f,lineStr))
193 {
194 line = lineStr;
195 lineCount++;
196 k = line.find(',');
197 }
198 }
199 }
200 //printf("citeName = #%s#\n",qPrint(citeName));
201 if (!citeName.isEmpty())
202 {
203 std::string lCiteName = citeName.lower().str();
204 auto it = p->citePosition.find(lCiteName);
205 if (it != p->citePosition.end())
206 {
207 warn(bibFile,lineCount,"multiple use of citation name '{}', (first occurrence: {}, line {})",
208 lCiteName,it->second.fileName,it->second.lineNr);
209 }
210 else
211 {
212 p->citePosition.emplace(lCiteName,CitePosition(bibFile,lineCount));
213 }
214 }
215 }
216 else if ((i=line.find("crossref"))!=-1 && !citeName.isEmpty()) /* assumption cross reference is on one line and the only item */
217 {
218 int j = line.find('{',i);
219 int k = line.find('}',i);
220 if (j>i && k>j)
221 {
222 QCString crossrefName = line.mid(static_cast<size_t>(j+1),static_cast<uint32_t>(k-j-1));
223 // check if the reference with the cross reference is used
224 // insert cross reference when cross reference has not yet been added.
225 if (find(citeName) && !find(crossrefName)) // not found yet
226 {
227 insert(crossrefName);
228 }
229 }
230 }
231 }
232}
const CiteInfo * find(const QCString &label) const
Return the citation info for a given label.
Definition cite.cpp:101
void insert(const QCString &label)
Insert a citation identified by label into the database.
Definition cite.cpp:95
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition qcstring.h:241
#define lineCount(s, len)
#define warn(file, line, fmt,...)
Definition message.h:97

References err, FileInfo::exists(), find(), QCString::find(), insert(), QCString::isEmpty(), lineCount, QCString::lower(), QCString::mid(), Portable::openInputStream(), p, QCString::startsWith(), QCString::str(), QCString::stripWhiteSpace(), and warn.

Referenced by generatePage(), and ~CitationManager().

◆ instance()

CitationManager & CitationManager::instance ( )
static

Definition at line 85 of file cite.cpp.

86{
87 static CitationManager ct;
88 return ct;
89}
CitationManager()
Create the database, with an expected maximum of size entries.
Definition cite.cpp:91

References CitationManager().

Referenced by addCite(), clearAll(), DocAnchor::DocAnchor(), DocCite::DocCite(), DocCite::getText(), LatexDocVisitor::operator()(), TextDocVisitor::operator()(), parseInput(), substituteLatexKeywords(), writeLatexMakefile(), and writeMakeBat().

◆ isEmpty()

bool CitationManager::isEmpty ( ) const

return TRUE if there are no citations.

Definition at line 115 of file cite.cpp.

116{
117 size_t numFiles = Config_getList(CITE_BIB_FILES).size();
118 return (numFiles==0 || p->entries.empty());
119}

References Config_getList, and p.

Referenced by generatePage(), substituteLatexKeywords(), writeLatexMakefile(), and writeMakeBat().

◆ latexBibFiles()

QCString CitationManager::latexBibFiles ( )

lists the bibtex cite files in a comma separated list

Definition at line 575 of file cite.cpp.

576{
577 QCString result;
578 const StringVector &citeDataList = Config_getList(CITE_BIB_FILES);
579 int i = 0;
580 for (const auto &bibdata : citeDataList)
581 {
582 QCString bibFile = getBibFile(bibdata);
583 FileInfo fi(bibFile.str());
584 if (fi.exists() && !bibFile.isEmpty())
585 {
586 if (i) result += ",";
587 i++;
588 result += bibTmpFile;
589 result += QCString().setNum(i);
590 }
591 }
592 return result;
593}

References bibTmpFile, Config_getList, FileInfo::exists(), getBibFile(), QCString::isEmpty(), QCString::setNum(), and QCString::str().

Referenced by substituteLatexKeywords().

◆ replaceFormulas()

QCString CitationManager::replaceFormulas ( const QCString & s)
private

Definition at line 311 of file cite.cpp.

312{
313 if (s.isEmpty()) return s;
314 QCString t;
315 int pos=0;
316 int i = -1;
317 while ((i=s.find(g_formulaMarker,pos))!=-1)
318 {
319 t += s.mid(pos,i-pos);
320 int markerSize = static_cast<int>( g_formulaMarker.length());
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;
325 }
326 t += s.mid(pos);
327 //printf("replaceFormulas(%s)=%s\n",qPrint(s),qPrint(t));
328 return t;
329}
int find(char c, int index=0, bool cs=TRUE) const
Definition qcstring.cpp:43

References QCString::data(), QCString::find(), g_formulaMarker, QCString::isEmpty(), QCString::mid(), and p.

Referenced by generatePage(), and ~CitationManager().

Member Data Documentation

◆ p

std::unique_ptr<Private> CitationManager::p
private

The documentation for this class was generated from the following files: