Doxygen
Loading...
Searching...
No Matches
cite.h
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Copyright (C) 2020 by Dimitri van Heesch
4 * Based on a patch by David Munger
5 *
6 * Permission to use, copy, modify, and distribute this software and its
7 * documentation under the terms of the GNU General Public License is hereby
8 * granted. No representations are made about the suitability of this software
9 * for any purpose. It is provided "as is" without express or implied warranty.
10 * See the GNU General Public License for more details.
11 *
12 * Documents produced by Doxygen are derivative works derived from the
13 * input used in their production; they are not affected by this license.
14 *
15 */
16
17#ifndef CITE_H
18#define CITE_H
19
20#include <memory>
21
22#include "qcstring.h"
23#include "construct.h"
24
26{
27 public:
32
34 void setNoPar() { m_bits |= NOPAR_BIT; }
36
37 bool isUnknown() const { return (m_bits & TypeMask)==0; }
38 bool isNumber() const { return (m_bits & NUMBER)!=0; }
39 bool isShortAuthor() const { return (m_bits & SHORTAUTHOR)!=0; }
40 bool isYear() const { return (m_bits & YEAR)!=0; }
41
42 bool noPar() const { return (m_bits & NOPAR_BIT)!=0; }
43 bool noCite() const { return (m_bits & NOCITE_BIT)!=0; }
44
45 friend inline bool operator==(const CiteInfoOption &t1,const CiteInfoOption &t2) { return t1.m_bits==t2.m_bits; }
46 friend inline bool operator!=(const CiteInfoOption &t1,const CiteInfoOption &t2) { return !(operator==(t1,t2)); }
47
48 private:
49 CiteInfoOption(int bits) : m_bits(bits) {}
50
51 enum Bits
52 {
54 NUMBER = (1<<0),
55 SHORTAUTHOR = (1<<1),
56 YEAR = (1<<2),
57
58 TypeMask = 0x0000FFFF,
59 OptionMask = 0xFFFF0000,
60
61 NOPAR_BIT = (1<<16), //< Don't use square brackets
62 NOCITE_BIT = (1<<17) //< Don't create a link
63 };
64 unsigned int m_bits = UNKNOWN;
65};
66
67
68/// Citation-related data.
70{
72
73 virtual QCString label() const = 0;
74 virtual QCString text() const = 0;
75 virtual QCString shortAuthor() const = 0;
76 virtual QCString year() const = 0;
77};
78
79/**
80 * @brief Citation manager class.
81 * @details This class provides access do the database of bibliographic
82 * references through the bibtex backend.
83 */
85{
86 public:
87 static CitationManager &instance();
88
89 /** Insert a citation identified by \a label into the database */
90 void insert(const QCString &label);
91
92 /** Return the citation info for a given \a label.
93 * Ownership of the info stays with the manager.
94 */
95 const CiteInfo *find(const QCString &label) const;
96
97 /** Generate the citations page */
98 void generatePage();
99
100 /** clears the database */
101 void clear();
102
103 /** return TRUE if there are no citations.
104 */
105 bool isEmpty() const;
106
107 /** lists the bibtex cite files in a comma separated list
108 */
110
111 QCString fileName() const;
112 QCString anchorPrefix() const;
113
114 private:
115 /** Create the database, with an expected maximum of \a size entries */
117 ~CitationManager() = default;
119 void insertCrossReferencesForBibFile(const QCString &bibFile);
122 struct Private;
123 std::unique_ptr<Private> p;
124};
125
126#endif // CITE_H
void insertCrossReferencesForBibFile(const QCString &bibFile)
Definition cite.cpp:133
QCString anchorPrefix() const
Definition cite.cpp:128
std::unique_ptr< Private > p
Definition cite.h:123
const CiteInfo * find(const QCString &label) const
Return the citation info for a given label.
Definition cite.cpp:102
QCString latexBibFiles()
lists the bibtex cite files in a comma separated list
Definition cite.cpp:577
static CitationManager & instance()
Definition cite.cpp:86
void clear()
clears the database
Definition cite.cpp:112
QCString replaceFormulas(const QCString &s)
Definition cite.cpp:313
~CitationManager()=default
void insert(const QCString &label)
Insert a citation identified by label into the database.
Definition cite.cpp:96
CitationManager()
Create the database, with an expected maximum of size entries.
Definition cite.cpp:92
QCString fileName() const
Definition cite.cpp:123
bool isEmpty() const
return TRUE if there are no citations.
Definition cite.cpp:117
void generatePage()
Generate the citations page.
Definition cite.cpp:333
QCString getFormulas(const QCString &s)
Definition cite.cpp:238
static CiteInfoOption makeYear()
Definition cite.h:31
bool noPar() const
Definition cite.h:42
static CiteInfoOption makeNumber()
Definition cite.h:29
bool isNumber() const
Definition cite.h:38
CiteInfoOption(int bits)
Definition cite.h:49
@ SHORTAUTHOR
Definition cite.h:55
friend bool operator!=(const CiteInfoOption &t1, const CiteInfoOption &t2)
Definition cite.h:46
void setNoCite()
Definition cite.h:35
bool noCite() const
Definition cite.h:43
bool isUnknown() const
Definition cite.h:37
friend bool operator==(const CiteInfoOption &t1, const CiteInfoOption &t2)
Definition cite.h:45
void changeToNumber()
Definition cite.h:33
static CiteInfoOption makeShortAuthor()
Definition cite.h:30
CiteInfoOption()
Definition cite.h:28
bool isShortAuthor() const
Definition cite.h:39
unsigned int m_bits
Definition cite.h:64
bool isYear() const
Definition cite.h:40
void setNoPar()
Definition cite.h:34
This is an alternative implementation of QCString.
Definition qcstring.h:101
#define NON_COPYABLE(cls)
Macro to help implementing the rule of 5 for a non-copyable & movable class.
Definition construct.h:37
#define ABSTRACT_BASE_CLASS(cls)
Macro to implement rule of 5 for an abstract base class.
Definition construct.h:20
QCString s
Definition htmlgen.cpp:154
Citation-related data.
Definition cite.h:70
virtual QCString text() const =0
virtual QCString shortAuthor() const =0
virtual QCString label() const =0
virtual QCString year() const =0